Changeset 50
- Timestamp:
- Aug 11, 2010, 4:11:43 PM (11 years ago)
- bzr:base-revision:
- j@dannynavarro.net-20100810125413-6bt7tb040xha3bsg
- bzr:committer:
- Danny Navarro <j@dannynavarro.net>
- bzr:file-ids:
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-20100810130148-y2rxfm2tv9v7mbl9
- bzr:revno:
- 50
- bzr:revprop:branch-nick:
- trunk
- bzr:root:
- trunk
- bzr:timestamp:
- 2010-08-10 15:01:48.036999941 +0200
- bzr:user-agent:
- bzr2.1.2+bzr-svn1.0.3
- svn:original-date:
- 2010-08-10T13:01:48.037000Z
- Location:
- trunk/mzcms
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mzcms/models.py
r45 r50 24 24 self.native_id = str(native_id) 25 25 self.sequence = str(sequence) 26 self.pep_refs = tuple(pep_refs)26 self.pep_refs = pep_refs 27 27 28 28 class Peptides(Folder): … … 60 60 class Psm(Persistent): 61 61 """A Peptide to Spectrum Match""" 62 def __init__(self, score, rank, delta_mass, delta_score, 63 sequence_rank2, pep_ref, spec_ref): 62 def __init__(self, score, rank, delta_mass, pep_ref, spec_ref): 64 63 self.score = float(score) 65 64 self.rank = int(rank) 66 65 self.delta_mass = float(delta_mass) 67 self.delta_score = float(delta_score)68 self.sequence_rank2 = str(sequence_rank2)69 self.pep_ref = str(pep_ref)70 self.spec_ref = s tr(spec_ref)66 #self.delta_score = float(delta_score) 67 #self.sequence_rank2 = str(sequence_rank2) 68 self.pep_ref = pep_ref 69 self.spec_ref = spec_ref 71 70 72 71 def appmaker(zodb_root): -
trunk/mzcms/parsers.py
r45 r50 53 53 scan_str=r'FinneganScanNumber%3a%20(\d+)%20', 54 54 rawfn_str=r'RawFile%3a%20(.+raw)', 55 decoy_str=r'^ IPI:REV_:IPI',56 contaminant_str=r'^ IPI:CON_:IPI',55 decoy_str=r'^REV_IPI', 56 contaminant_str=r'^CON_IPI', 57 57 # XXX: Fix default factories 58 58 ): … … 64 64 self.rawfn_regex = re.compile(rawfn_str) 65 65 self.protein_factory = protein_factory 66 self.peptide_factory = p rotein_factory66 self.peptide_factory = peptide_factory 67 67 self.spectrum_factory=spectrum_factory 68 68 self.psm_factory=psm_factory … … 131 131 is_target = check_target(prot_ids, 132 132 self.non_target_regexes) 133 if is_target and rank == 1 or rank == 2:133 if is_target and (rank == 1 or rank == 2): 134 134 mascot_psm = MascotPsm( 135 135 rank=rank, … … 173 173 nativeid_psms = self._parse_psms(dat_file) 174 174 extraspec = self._parse_extraspec(dat_file) 175 proteins = dict() 175 176 spectra = dict() 177 peptides = dict() 178 psms = dict() 176 179 for summ, extra in izip(summspec, extraspec): 177 spectrum = self.spectrum_factory(prec_mz=summ[0], 178 prec_charge=summ[1], 179 run=extra[0], 180 scan=extra[1], 181 peaks="TBI") 180 spectrum = self.spectrum_factory( 181 prec_mz=summ[0], 182 prec_charge=summ[1], 183 run=extra[0], 184 scan=extra[1], 185 peaks="TBI" 186 ) 182 187 spectra[(spectrum.scan, spectrum.run)] = spectrum 188 for nativeid, m_psms in nativeid_psms.iteritems(): 189 for m_psm in m_psms: 190 peptide = self.peptide_factory( 191 sequence=m_psm.pep_seq, 192 mass=m_psm.pep_mass 193 ) 194 if peptide.sequence not in peptides: 195 peptides[peptide.sequence] = peptide 196 run, spec = extraspec[nativeid - 1] 197 spec_id = spec, run 198 psm = self.psm_factory( 199 score=m_psm.score, 200 rank=m_psm.rank, 201 delta_mass=m_psm.delta_mass, 202 pep_ref=peptide, 203 spec_ref=spectra[spec_id] 204 ) 205 psms[(peptide.sequence, spec_id)] = psm 206 for prot_id in m_psm.prot_ids: 207 if prot_id not in proteins: 208 protein = self.protein_factory( 209 native_id=prot_id, 210 sequence="TBI", 211 pep_refs=[peptide] 212 ) 213 proteins[prot_id] = protein 214 else: 215 if peptide not in proteins[prot_id].pep_refs: 216 proteins[prot_id].pep_refs.append(peptide) 183 217 import ipdb; ipdb.set_trace() 184 218 return proteins, peptides, spectra, psms … … 197 231 for prot_id in prot_ids: 198 232 for regex in regexes: 199 if not re.match(regex, prot_id): 200 return True 233 if re.match(regex, prot_id): 234 return False 235 return True 201 236 202 237 def apply_mods(peptide_str, mod_str): … … 244 279 # TODO: exception for not dat files 245 280 with open(os.path.join(root, dat_fn)) as dat_file: 246 dat_proteins, dat_peptides, \247 dat_spectra, dat_psms = dat_parser.parse(dat_file)248 proteins.update( dat_proteins)249 peptides.update( dat_peptides)250 spectra.update( dat_spectra)251 psms.update( dat_psms)281 ser_proteins, ser_peptides, \ 282 ser_spectra, ser_psms = dat_parser.parse(dat_file) 283 proteins.update(ser_proteins) 284 peptides.update(ser_peptides) 285 spectra.update(ser_spectra) 286 psms.update(ser_psms) 252 287 return proteins, peptides, spectra, psms 253 288
Note: See TracChangeset
for help on using the changeset viewer.