PRTM: Calculating Protein Mass | Ben Cunningham

PRTM: Calculating Protein Mass

Problem by Rosalind · on July 23, 2012

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.

Sample Dataset

SKADYEK

Sample Output

821.392

R

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()
821.392