def grab_ions(match_list, conf): '''Takes peptides and returns a sorted list of their predicted ions''' output = [] for match in enumerate(match_list): consts = conf["other_constants"] masses = match[1]["orderedMasses"] bIons = PeptideDB.coarsen(PeptideDB.returnIons(masses, consts["B+"])) yIons = PeptideDB.coarsen(PeptideDB.returnIons(masses[::-1], consts["Y+"])) for bIon in bIons: output.append([int(bIon), int((match[0]*2)+1)]) for yIon in yIons: output.append([int(yIon), int(match[0])*2]) return sorted(output, key=lambda entry: entry[0])
else: peptides[(ions[match_index][1]+1)/2]["bCount"] += 1 peptides[(ions[match_index][1]+1)/2]["bSum"] += int(peak[1]) match_index += 1 if match_index == len(ions): break output = [] for entry in peptides: entry["spec"] = spectra["name"] output.append(entry) return output configurations = configs.readConfigs("mascotStyle.cfg") file_confs = configurations["data"] peptide_set = PeptideDB.returnPeptides(configurations) print "[+]"+str(len(peptide_set))+" mass entries generated." spectra_file = file_confs["spectra_file"] MGFFile = open(spectra_file, "rb") spectra_gen = MGFParse.MGFReader(MGFFile, configurations) score_mod = scorer.Score(configurations) top_scores = [] for spectrum in spectra_gen: print ("[+]Searching %s. \r" % (spectrum["name"])), tol = configurations["search_options"]["initial_tolerance"]*spectrum["trueMass"] m1Matches = match_masses(peptide_set, spectrum["trueMass"], tol) counter = count_matches(m1Matches, spectrum, configurations)