카테고리 없음

Calculating Protein Mass(단백질 질량 계산)

곰탱이장 2024. 8. 15. 20:46

https://rosalind.info/problems/prtm/

 

ROSALIND | Calculating Protein Mass

It appears that your browser has JavaScript disabled. Rosalind requires your browser to be JavaScript enabled. Calculating Protein Mass solved by 13002 Chaining the Amino Acids Figure 1. Formation of a peptide bond Figure 2. Outermost acids In “Translati

rosalind.info

Problem

In a weighted alphabet, every symbol is assigned a positive real number called a weight. A string formed from a weighted alphabet is called a weighted string, and its weight is equal to the sum of the weights of its symbols.

The standard weight assigned to each member of the 20-symbol amino acid alphabet is the monoisotopic mass of the corresponding amino acid.

Given: A protein string PP of length at most 1000 aa.

Return: The total weight of PP. Consult the monoisotopic mass table.

Sample Dataset

SKADYEK

Sample Output

821.392

 

 이 문제는 주어진 단백질들의 질량 테이블을 이용하여 펩타이드의 질량을 구하는 문제이다. 문제 자체는 쉽다. 그저 테이블을 파이썬으로 구현하는 방법이 여러 가지이다. 필자는 https://rosalind.info/glossary/monoisotopic-mass-table/ 이 url의 테이블 부분을 통째로 복사해 입력하면 딕셔너리로 만들어주는 함수를 만들어 사용했다.

def mmt():
    for i in range(20):
        aa,mass=input().split('   ')#아미노산,질량구분
        table[aa]=float(mass)
    return
table={}
mmt()

pep=input()
s=0
for i in pep:
    s = s+table[i]
print(s)