https://rosalind.info/problems/spec/
ROSALIND | Inferring Protein from Spectrum
It appears that your browser has JavaScript disabled. Rosalind requires your browser to be JavaScript enabled. Inferring Protein from Spectrum solved by 1741 Introduction to Mass Spectrometry In “Calculating Protein Mass”, we briefly mentioned an analy
rosalind.info
Problem
The prefix spectrum of a weighted string is the collection of all its prefix weights.
Given: A list LL of nn (n≤100n≤100) positive real numbers.
Return: A protein string of length n−1n−1 whose prefix spectrum is equal to LL (if multiple solutions exist, you may output any one of them). Consult the monoisotopic mass table.
Sample Dataset
3524.8542
3710.9335
3841.974
3970.0326
4057.0646
Sample Output
WMQS
이 문제는 prefix 스펙트럼을 이용하여 어떠한 단백질 서열의 prefix를 구하는 문제이다. 이 문제는 그냥 prefix 스펙트럼의 앞뒤 차이를 구해 아미노산 하나의 무게를 구해, 이 무게를 가진 아미노산을 이어붙이는 문제이다.
monoisotopic_mass_table={
'A':71.03711,
'C':103.00919,
'D':115.02694,
'E':129.04259,
'F':147.06841,
'G':57.02146,
'H':137.05891,
#'I':113.08406, 같은게 있음
'K':128.09496,
'L':113.08406,
'M':131.04049,
'N':114.04293,
'P':97.05276,
'Q':128.05858,
'R':156.10111,
'S':87.03203,
'T':101.04768,
'V':99.06841,
'W':186.07931,
'Y':163.06333
}
if __name__ == '__main__':
with open(r'파일경로','r') as f:
L=[]
for i in f.readlines():
L.append(float(i.rstrip()))
delta=[]
for j in range(len(L)-1):
delta.append(round(L[j+1]-L[j],4))
new_table={}
for k,v in monoisotopic_mass_table.items():
new_table[round(v,4)]=k
ans=''
for p in delta:
ans=ans+new_table[p]
print(ans)