source: trunk/mzcms/models.py @ 21

Last change on this file since 21 was 21, checked in by j@…, 11 years ago

pseudocode for parsing

File size: 2.0 KB
Line 
1from persistent import Persistent
2from repoze.folder import Folder
3
4class Experiment(Folder):
5    __parent__ = __name__ = None
6
7class Proteins(Folder):
8    """A container for proteins objects"""
9    def __init__(self):
10        self.name = 'proteins'
11
12class Protein(Persistent):
13    """A Protein"""
14    def __init__(self, native_id, sequence, pep_refs):
15        self.sequence = str(native_id)
16        self.sequence = str(sequence)
17        self.pep_refs = tuple(pep_refs)
18
19class Peptides(Folder):
20    """A container for peptides"""
21    def __init__(self):
22        self.name = 'peptides'
23
24class Peptide(Persistent):
25    """A peptide"""
26    def __init__(self, sequence, mass):
27        self.sequence = str(sequence)
28        self.mass = float(mass)
29        self.length = len(sequence)
30
31class Spectra(Folder):
32    """A Container for spectra"""
33    def __init__(self):
34        self.name = 'spectra'
35
36
37class Spectrum(Persistent):
38    """A Spectrum"""
39    def __init__(self, scan, run, peaks, prec_mz, prec_charge):
40        self.scan = int(scan)
41        self.run = str(scan)
42        self.peaks = tuple(peaks)
43        self.prec_mz = float(prec_mz)
44        self.prec_charge = int(prec_charge)
45
46class Psms(Folder):
47    """A container for psms"""
48    def __init__(self):
49        self.name = 'psms'
50
51class Psm(Persistent):
52    """A Peptide to Spectrum Match"""
53    def __init__(self, score, rank, delta_mass, delta_score,
54                 sequence_rank2, pep_ref, spec_ref):
55        self.score = float(score)
56        self.rank = int(rank)
57        self.delta_mass = float(delta_mass)
58        self.delta_score = float(delta_score)
59        self.sequence_rank2 = str(sequence_rank2)
60        self.pep_ref = str(pep_ref)
61        self.spec_ref = str(spec_ref)
62
63def appmaker(zodb_root):
64    if not 'app_root' in zodb_root:
65        app_root = Experiment()
66#        folders = parse_results(files)
67#        for folder in folders:
68#            app_root[folder.name] = folder
69#        zodb_root['app_root'] = app_root
70        import transaction
71        transaction.commit()
72
73    return zodb_root['app_root']
Note: See TracBrowser for help on using the repository browser.