PRTM: Calculating Protein Mass
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 of length at most 1000 aa.
Return: The total weight of . Consult the monoisotopic mass table.
library(readr) library(dplyr) f <- "prtm.txt" mmt <- read_csv("monoisotopic_mass_table.csv") p <- data_frame( acid = readLines(f) %>% strsplit(split = "") %>% unlist() ) %>% left_join(mmt, by = "acid") sum(p$mass) %>% round(3) %>% cat()