Guest User

Untitled

a guest
Jun 22nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. library(tidyverse)
  2.  
  3.  
  4. # Function ----------------------------------------------------------------
  5.  
  6. convert <- function(three_aa_seq = NULL) {
  7.  
  8. pep_dat <- structure(list(full = c(
  9. "Alanine", "Arginine", "Asparagine",
  10. "Aspartate", "Cysteine", "Glutamine", "Glutamate", "Glycine",
  11. "Histidine", "Isoleucine", "Leucine", "Lysine", "Methionine",
  12. "Phenylalanine", "Proline", "Serine", "Threonine", "Tryptophan",
  13. "Tyrosine", "Valine"
  14. ), three = c(
  15. "Ala", "Arg", "Asn", "Asp",
  16. "Cys", "Gln", "Glu", "Gly", "His", "Ile", "Leu", "Lys", "Met",
  17. "Phe", "Pro", "Ser", "Thr", "Trp", "Tyr", "Val"
  18. ), one = c(
  19. "A",
  20. "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
  21. "P", "S", "T", "W", "Y", "V"
  22. )), .Names = c("full", "three", "one"), class = c("tbl_df", "tbl", "data.frame"), row.names = c(
  23. NA,
  24. -20L
  25. ))
  26. str_split(three_aa_seq, pattern = "-")[[1]] %>%
  27. as.tibble() %>%
  28. rename(three = value) %>%
  29. inner_join(pep_dat, by = "three") %>%
  30. pull(one) %>%
  31. paste(., collapse = "")
  32. }
  33.  
  34. tribble(
  35. ~ pep_name, ~ three_seq,
  36. "PA_19", "His-Ser-Leu-Gly-Lys-Trp-Leu-Gly-His-Pro-Asp-Lys-Phe",
  37. "PA_20", "Thr-Ala-Pro-Arg-Ser-Leu-Arg-Arg-Ser-Ser-Cys-Phe-Gly-Gly-Arg-Met-Asp-Arg-Ile-Gly-Ala-Gln-Ser-Gly-Leu-Gly-Cys-Asn-Ser-Phe-Arg-Tyr"
  38. ) %>%
  39. mutate(pep = convert(three_aa_seq = three_seq))
Add Comment
Please, Sign In to add comment