Protein Molecular Weight

Intermediate Bioinformatics Protein Mass Spectrometry Molecular Weight
Significance:

Mass spectrometry identifies proteins by matching observed masses against predicted ones, so
computing a peptide's monoisotopic mass is the bridge between a sequence database and a real
spectrum. The water term matters: forming each peptide bond releases a water molecule, so the
whole peptide weighs one water more than the sum of its residues.

Statement

Given a protein string, compute its monoisotopic molecular weight in daltons.

Sum the monoisotopic residue mass of each amino acid, then add the mass of one water molecule
(18.01056) for the intact peptide.

Use these residue masses:

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

Print the total rounded to three decimal places. Your answer is compared numerically with a
tolerance of 0.01.

Input — read from standard input
Variable Type Description
protein
line 1
str The protein sequence in single-letter amino acid codes
1 <= length <= 1000, uppercase standard amino acid letters

These variables are already read for you in the starter code on the right.

Output

float the monoisotopic peptide mass, rounded to 3 decimal places

Sample Cases
Sample 1
Input
SKADYEK
Expected Output
839.402
The seven residues sum to 821.392, plus one water (18.011) gives 839.402.
Sample 2
Input
A
Expected Output
89.048
A single alanine residue plus water.

Submit also runs your code against 4 hidden test cases. Hidden inputs are never shown — if one fails you'll get its number and a description of the mismatch, not the data.

Constraints
  • 1 <= length(protein) <= 1000
  • Only the 20 standard amino acid letters appear
  • Remember to add one water mass (18.01056) to the residue total
Further Reading
  • Store the table as a dictionary and sum with a comprehension.
  • L and I have the same monoisotopic mass — that is correct, not a typo.

My Notes
Log in to save personal notes.
Console output will appear here when you click Run Code or Submit...
Expected: protein (str)
Next Problem
Genome Assembly via de Bruijn Graphs