Use reverseComplement() in the Biostrings package. B.
On Mar 8, 2015, at 10:08 PM, saran wai <darwinm13s...@hotmail.com> wrote: > Hi I'm new to R programming and trying to write program for Reverse and > Complementary Base. the objective is to Design A DNA primer. So I have a DNA > sequence with base A T C G and A complement to T; T=A;C=G;G=C. I just figure > out How to Reverse It Already. but for the Complement i can only make it > answer for just 1 base but cant be all of the sequence. and i dont know how > to combine reverse and complement function. here is my code and im totallt > confuse with it. Cn someone help me with this problem? You will be my life > savior! thank you! strReverse <- function(x) sapply(lapply(strsplit(x, > NULL), rev), paste, collapse="") strReverse(c("ATCGGTCAATCGA")) > complement.base = function(base){ if(base == 'A' | base == 'a') > print("T") if(base == 'T' | base == 't') print("A") if(base == 'G' | base > == 'g') print("C") if(base == 'C' | base == 'c') print("G")} > complement.base(base="A") > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.