Changeset 54


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

TODO.txt todo.txt-20100730132122-uzfgrm72wgp87uwo-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-20100811081220-c0v3sed9b6pm51cc
bzr:revno:
54
bzr:revprop:branch-nick:
trunk
bzr:root:
trunk
bzr:timestamp:
2010-08-11 10:12:20.483999968 +0200
bzr:user-agent:
bzr2.1.2+bzr-svn1.0.3
svn:original-date:
2010-08-11T08:12:20.484000Z
Message:

filename filter to parse only dat files

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/TODO.txt

    r49 r54  
    55#. Parser to populate models
    66 #. Populate Spectra. Done.
    7  #. Populate Peptides
    8  #. Populate Psms
    9  #. Populate Proteins
     7 #. Populate Peptides. Done
     8 #. Populate Psms. Done
     9 #. Populate Proteins. Done
     10 #. Implement Update for proteins. Done
    1011 #. Modifications: Parse Unimod, Deltamass
    1112#. Test models
  • trunk/mzcms/models.py

    r53 r54  
    4949    if not 'app_root' in zodb_root:
    5050        app_root = Experiment()
     51        proteins = Folder()
     52        peptides = Folder()
     53        spectra = Folder()
    5154        zodb_root['app_root'] = app_root
    52         proteins = Folder()
    5355        app_root['proteins'] = proteins
    54         peptides = Folder()
    5556        app_root['peptides'] = peptides
    56         spectra = Folder()
    5757        app_root['spectra'] = spectra
    5858        psms = Folder()
  • trunk/mzcms/parsers.py

    r52 r54  
    77import csv
    88import urllib
     9import fnmatch
    910from optparse import OptionParser
    1011from string import Template
     
    260261        writer.writerow(psm)
    261262
     263# XXX: Use better defaults for containers and factories
    262264def parse_dats(dats_dir, proteins_container=dict, peptides_container=dict,
    263265               spectra_container=dict, psms_container=dict,
     
    277279    for root, dirs, files in os.walk(dats_dir):
    278280        for dat_fn in files:
    279             # TODO: exception for not dat files
    280             with open(os.path.join(root, dat_fn)) as dat_file:
    281                 ser_proteins, ser_peptides, \
    282                 ser_spectra, ser_psms = dat_parser.parse(dat_file)
    283                 for k, v in ser_proteins.items():
    284                     if k not in proteins:
    285                         proteins[str(k)] = v
    286                 transaction.savepoint()
    287                 for k, v in ser_peptides.items():
    288                     if not k in peptides:
    289                         peptides[str(k)] = v
    290                 transaction.savepoint()
    291                 for k, v in ser_spectra.items():
    292                     if k not in spectra:
    293                         spectra[str(k)] = v
    294                 transaction.savepoint()
    295                 for k, v in ser_psms.items():
    296                     if k not in psms:
    297                         psms[str(k)] = v
    298                 transaction.savepoint()
     281            if fnmatch.fnmatch(dat_fn, '*.dat'):
     282                with open(os.path.join(root, dat_fn)) as dat_file:
     283                    ser_proteins, ser_peptides, \
     284                    ser_spectra, ser_psms = dat_parser.parse(dat_file)
     285                    for k, v in ser_proteins.items():
     286                        if k not in proteins:
     287                            proteins[str(k)] = v
     288                    transaction.savepoint()
     289                    for k, v in ser_peptides.items():
     290                        if not k in peptides:
     291                            peptides[str(k)] = v
     292                    transaction.savepoint()
     293                    for k, v in ser_spectra.items():
     294                        if k not in spectra:
     295                            spectra[str(k)] = v
     296                    transaction.savepoint()
     297                    for k, v in ser_psms.items():
     298                        if k not in psms:
     299                            psms[str(k)] = v
     300                    transaction.savepoint()
    299301
    300302def main():
Note: See TracChangeset for help on using the changeset viewer.