Changeset 42
- Timestamp:
- Aug 11, 2010, 4:09:24 PM (11 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mzcms/parsers.py
r41 r42 80 80 else: 81 81 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 82 98 83 99 def _parse_psms(self, dat_file): … … 117 133 return nativeid_psms 118 134 119 def _parse_spectra(self, dat file):135 def _parse_spectra(self, dat_file): 120 136 """Gets the data coming from the input file from Mascot dat 121 137 format … … 123 139 nativeid_spectra = defaultdict(dict) 124 140 nativeid = 1 125 for line in dat file:141 for line in dat_file: 126 142 nativeid_str = ''.join(("query", str(nativeid))) 127 143 query_line = SECTION_TEMPLATE.substitute(section=nativeid_str) … … 131 147 elif line.startswith("title="): 132 148 line = line.strip() 133 #TODO: handle fractions134 #fraction = int(re.search(fraction_regex, line).group(1))135 #current_id_mgf["Fraction"] = fraction136 149 try: 137 quoted_rawfn = re.search( rawfn_regex, line).group(1)150 quoted_rawfn = re.search(self.rawfn_regex, line).group(1) 138 151 except AttributeError: 139 152 sys.exit("It seems there is no raw: field in TITLE") … … 160 173 pkl_fn = self._parse_spectra_fn(dat_file) 161 174 frag_mode = self._parse_frag_mode(dat_file) 175 summspec = self._parse_summary(dat_file) 162 176 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) 165 178 for native_id, psms in nativeid_psms.items(): 166 179 for psm in psms:
Note: See TracChangeset
for help on using the changeset viewer.