Created
December 31, 2019 22:07
-
-
Save dnanto/c0b4ad65b70057554477822b5a6926e2 to your computer and use it in GitHub Desktop.
calculate the reverse complement of a BTOP string (uses tidyverse)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comp <- set_names( | |
as.list(str_split("TAACGRYSWMKVHDBN", "", simplify = 1)), | |
str_split("ATUGCYRSWKMBDHVN", "", simplify = T) | |
) | |
revcomp_btop <- function(btop) | |
{ | |
str_replace_all(btop, "([A-Z-])([A-Z-])", " \\2 \\1 ") %>% | |
str_split(" ", simplify = T) %>% | |
rev() %>% | |
sapply(function(ele) { code <- comp[[ele]]; ifelse(is.null(code), ele, code); }, USE.NAMES = F) %>% | |
str_c(collapse = "") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment