Last active
September 27, 2018 19:26
-
-
Save lpantano/cc5254378e076dfa6310274f2879cb3b to your computer and use it in GitHub Desktop.
From a sequences generate 4 possible changes
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
mir = "CCCGGGGGGGGGGGGGGGGGGGGGCCC" | |
# generate different length +/-3 at both size | |
lapply(c(1,2,3,4,5,6,7), function(x){ | |
lapply(c(0,1,2,3,4,5,6,7), function(y){ | |
substr(mir, x, nchar(mir)-y) | |
}) %>% unlist() | |
}) %>% unlist() -> trim | |
# add non-tempaltes 3' A or U up to 3 | |
trim_add = expand.grid(trim, c("A","AA", "AAA", "U", "UU", "UUU", "")) %>% | |
apply(., 1, paste0, collapse = "") | |
# add non-template 5' A | |
trim_add_both = expand.grid(c("A", ""), trim_add) %>% | |
apply(., 1, paste0, collapse = "") | |
# add nucleotides changes at each position, different from the current nt | |
all = sapply(trim_add_both, function(x){ # move through all calculated sequences | |
lapply(1:nchar(x), function(y){ # move through the sequence | |
lapply(setdiff(c("A", "T", "C", "G"), substr(x, y, y)), function(n){ | |
t = x # copy the sequence | |
substr(t, y, y) <- n #change the new sequence nt at that position | |
t # return value | |
}) %>% unlist() | |
}) %>% unlist %>% c(x, .) # add the unchanged sequence to the list | |
}) %>% unlist | |
length(all) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment