source: trunk/mzcms/models.py @ 22

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

initialize Experiment parent

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