This is a test version of Biostars. For the public version, visit https://www.biostars.org.
generate all combinations of strings from regular expression in R

Hi,

I have a regular expreesion - C|T|G,C|T,T,C,G,A,G,A|G,A|G|C,A|T|G|C of sequence motif. How can I generate all possible strings out of that in R ?

EDIT ========

the regx pattern is this [C|T|G][C|T]TCGAG[A|G][A|G|C][A|T|G|C] and not the above one.

Thanks, Chirag.

regularexpression r

try this in python 3:

import exrex
print(list(exrex.generate ('(C|T|G)(C|T)TCGAG(A|G)(A|G|C)(A|T|G|C)')))

try one of the following in R:

assertr::col_concat(expand.grid(c("C","T","G"),c ("C","T"), "TCGAG", c("A","G"),c("A","G","C"),c("A","T","G","C")), sep = "")
tidyr::unite("all",data=expand.grid(c("C","T","G"),c ("C","T"), "TCGAG", c("A","G"),c("A","G","C"),c("A","T","G","C")),1:6,sep = "")
Reduce(paste0,expand.grid(c("C","T","G"),c ("C","T"), "TCGAG", c("A","G"),c("A","G","C"),c("A","T","G","C")))

0 answers

No answers yet.

Log in to answer this question.