def sequencePeptide(N, spectrum): leaderPeptide = '' leadershipBoard = [] for number in masses.values(): for number_ in masses.values(): if sum(str(number) + '-' + str(number_)) < max(spectrum): leadershipBoard.append(str(number) + '-' + str(number_)) leadershipBoard = trim(leadershipBoard, spectrum, N) while len(leadershipBoard) != 0: leadershipBoard_further = [] for peptide in leadershipBoard: for number in masses.values(): peptide_new = peptide + '-' + str(number) if sum(peptide_new) == max(spectrum): if leaderPeptide != '': score_new = score(peptide_new.split('-'), spectrum) if leaderPeptideScore < score_new: leaderPeptide = peptide_new leaderPeptideScore = score_new else: leaderPeptide = peptide_new leaderPeptideScore = linearScore(leaderPeptide.split('-'), spectrum) elif sum(peptide_new) < max(spectrum): leadershipBoard_further.append(peptide_new) leadershipBoard = [] for peptide in leadershipBoard_further: leadershipBoard.append(peptide) leadershipBoard = trim(leadershipBoard, spectrum, N) # if len(peptide_new.split('-')) == 19: # count = 1 return leaderPeptide
def linearScore(peptide, spectrum): linear_spectrum = linearSpectrum(peptide) return score(spectrum, linear_spectrum)