Changeset 42


Ignore:
Timestamp:
Aug 11, 2010, 4:09:24 PM (10 years ago)
Author:
j@…
bzr:base-revision:
j@dannynavarro.net-20100809124849-61iz4u0uppej4zrn
bzr:committer:
Danny Navarro <j@dannynavarro.net>
bzr:file-ids:

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-20100809132407-1fe2wb5blanid09e
bzr:revno:
42
bzr:revprop:branch-nick:
trunk
bzr:root:
trunk
bzr:timestamp:
2010-08-09 15:24:07.388000011 +0200
bzr:user-agent:
bzr2.1.2+bzr-svn1.0.3
svn:original-date:
2010-08-09T13:24:07.388000Z
Message:

Added parse method for summary section

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mzcms/parsers.py

    r41 r42  
    8080                else:
    8181                    return frag_line
     82
     83    def _parse_summary(self, dat_file):
     84        """Parse summary section
     85        """
     86        summspec = list()
     87        summary_section = SECTION_TEMPLATE.substitute(section="summary")
     88        for line in dat_file:
     89            if line.strip() == summary_section:
     90                break
     91        for line in dat_file:
     92            if line.startswith('qexp'):
     93                r_mz, r_charge = line.strip().split('=')[1].split(',')
     94                mz = float(r_mz)
     95                charge = int(r_charge.rstrip('+'))
     96                summspec.append((mz, charge))
     97        return summspec
    8298
    8399    def _parse_psms(self, dat_file):
     
    117133                return nativeid_psms
    118134
    119     def _parse_spectra(self, datfile):
     135    def _parse_spectra(self, dat_file):
    120136        """Gets the data coming from the input file from Mascot dat
    121137           format
     
    123139        nativeid_spectra = defaultdict(dict)
    124140        nativeid = 1
    125         for line in datfile:
     141        for line in dat_file:
    126142            nativeid_str = ''.join(("query", str(nativeid)))
    127143            query_line = SECTION_TEMPLATE.substitute(section=nativeid_str)
     
    131147            elif line.startswith("title="):
    132148                line = line.strip()
    133                 #TODO: handle fractions
    134                 #fraction = int(re.search(fraction_regex, line).group(1))
    135                 #current_id_mgf["Fraction"] = fraction
    136149                try:
    137                     quoted_rawfn = re.search(rawfn_regex, line).group(1)
     150                    quoted_rawfn = re.search(self.rawfn_regex, line).group(1)
    138151                except AttributeError:
    139152                    sys.exit("It seems there is no raw: field in TITLE")
     
    160173        pkl_fn = self._parse_spectra_fn(dat_file)
    161174        frag_mode = self._parse_frag_mode(dat_file)
     175        summspec = self._parse_summary(dat_file)
    162176        nativeid_psms = self._parse_psms(dat_file)
    163         import ipdb; ipdb.set_trace()
    164         nativeid_spectra = self._parse_spectra(dat_file)
     177        extraspec = self._parse_spectra(dat_file)
    165178        for native_id, psms in nativeid_psms.items():
    166179            for psm in psms:
Note: See TracChangeset for help on using the changeset viewer.