Changeset 25


Ignore:
Timestamp:
Aug 11, 2010, 4:04:36 PM (10 years ago)
Author:
j@…
bzr:base-revision:
j@dannynavarro.net-20100806093012-l67phkga1smqy5lj
bzr:committer:
Danny Navarro <j@dannynavarro.net>
bzr:file-ids:

.bzrignore bzrignore-20100730084509-1oxl7srf8gii89tg-1
mzcms/models.py models.py-20100730084238-fjjwldiefr0w07zv-4
mzcms/parsers.py parsers.py-20100806092910-g1sxvv1o5b9umkof-1
bzr:mapping-version:
v4
bzr:repository-uuid:
724254b2-fbe6-419d-9466-c04ef4c9d29d
bzr:revision-id:
j@dannynavarro.net-20100806113756-c05d2haeot4rmaiy
bzr:revno:
25
bzr:revprop:branch-nick:
trunk
bzr:root:
trunk
bzr:timestamp:
2010-08-06 13:37:56.970999956 +0200
bzr:user-agent:
bzr2.1.2+bzr-svn1.0.3
svn:original-date:
2010-08-06T11:37:56.971000Z
Message:

Pseudocode for parse_dats

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/.bzrignore

    r5 r25  
    22*.egg-info
    33tags
     4.coverage
  • trunk/mzcms/models.py

    r24 r25  
    99class Experiment(Folder):
    1010    __parent__ = __name__ = None
    11     def __init__(self, proteins, peptides, spectra, psms):
     11    def __init__(self, subfolders):
    1212        super(Experiment, self).__init__()
    13         self['proteins'] = Proteins(proteins)
    14         self['peptides'] = Peptides(peptides)
    15         self['spectra'] = Spectra(spectra)
    16         self['psms'] = Psms(psms)
     13        for subfolder in subfolders:
     14            self[subfolder.name] = subfolder
    1715
    1816class Proteins(Folder):
     
    7472def appmaker(zodb_root):
    7573    if not 'app_root' in zodb_root:
    76         data = parse_dats('./dats')
    77         app_root = Experiment(data)
     74        folders = parse_dats('./dats', proteins_factory=Proteins,
     75                             peptides_factory=Peptides,
     76                             spectra_factory=Spectra,
     77                             psms_factory=Psms,
     78                             )
     79        app_root = Experiment(folders)
    7880        zodb_root['app_root'] = app_root
    7981        import transaction
  • trunk/mzcms/parsers.py

    r24 r25  
    3131RAWFN_REGEX = re.compile(r'raw%3a%20(.+raw)')
    3232
    33 class MascotParser(object):
    34     """Mascot Parser
    35     """
    36 
     33class DatParser(object):
     34    """Mascot Dat Parser
     35    """
    3736    def __init__(self, decoy_str, scans_in_title=False):
    3837        self.decoy_regex = re.compile(decoy_str)
     
    4746            if line.startswith("FILE="):
    4847                #XXX: There must be something in the standard library
    49                 # to normalize paths
     48                # to normalize this properly
    5049                full_path = line.strip().split('=')[1]
    5150                norm_path = full_path.replace("\\", "/")
     
    187186        writer.writerow(psm)
    188187
     188def parse_dats(dats_dir, proteins_factory=dict, peptides_factory=dict,
     189               spectra_factory=dict, psms_factory=dict):
     190    """Parses all the dat files in dats_dir
     191    """
     192    dats = get_dat_files(dats_dir)
     193    proteins = proteins_factory()
     194    peptides = peptides_factory()
     195    spectra = spectra_factory()
     196    psms = psms_factory()
     197    dat_parser = DatParser(decoy_str, scans_in_title)
     198    for dat in dats:
     199        dat_proteins, dat_peptides, dat_spectra, dat_psms = dat_parser.parse(file)
     200        proteins.update(dat_proteins)
     201        peptides.update(dat_peptides)
     202        spectra.update(dat_spectra)
     203        psms.update(dat_psms)
     204    return proteins, peptides, spectra, psms
     205
    189206def main():
    190207    usage = "usage: %prog [options] mascotresult1.dat [mascotresult2.dat ...]"
     
    227244                for arg in args:
    228245                    with open(arg) as in_file:
    229                         dat_parser = MascotParser(options.decoy_str,
     246                        dat_parser = DatParser(options.decoy_str,
    230247                                scans_in_title = options.scans_in_title)
    231248                        psms = dat_parser.parse(in_file)
Note: See TracChangeset for help on using the changeset viewer.