def cyclic_spectra(peptide): out_spectrum = [0, total_mass(peptide)] peptide_2 = peptide + peptide for k in range(1, len(peptide)): for n in range(len(peptide)): subpep = peptide_2[n:n+k] out_spectrum.append(total_mass(subpep)) return sorted(out_spectrum)
def cyclic_spectra(peptide): out_spectrum = [0, total_mass(peptide)] peptide_2 = peptide + peptide for k in range(1, len(peptide)): for n in range(len(peptide)): subpep = peptide_2[n:n + k] out_spectrum.append(total_mass(subpep)) return sorted(out_spectrum)
def linear_spectrum(peptide): out_spectrum = [0] for i in range(0, len(peptide)): for j in range(i, len(peptide)): subpep = peptide[i:j + 1] out_spectrum.append(total_mass(subpep)) return sorted(out_spectrum)
def linear_spectrum(peptide): out_spectrum = [0] for i in range(0, len(peptide)): for j in range(i, len(peptide)): subpep = peptide[i:j+1] out_spectrum.append(total_mass(subpep)) return sorted(out_spectrum)
#N = 10 #spectrum = [0, 71, 113, 129, 147, 200, 218, 260, 313, 331, 347, 389, 460] #print(single_amino(spectrum)) candidates = single_amino(spectrum) #winner = '' #candidates = amino_table.keys() winner = '' winner_score = 0 while candidates: candidates = branching(candidates) new_candidates = [] for candidate in candidates: c_mass = total_mass(candidate) t_mass = spectrum[-1] if c_mass == t_mass: new_candidates.append(candidate) c_score = score(candidate, spectrum) if c_score > winner_score: winner = candidate #winner_score = c_score elif c_mass < t_mass: new_candidates.append(candidate) candidates = trim(new_candidates, spectrum, N) LW = [] for i in winner: LW += [str(amino_table[i])]