Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Practical 2 question 16 #19

Open
roddypr opened this issue Jul 20, 2017 · 1 comment
Open

Practical 2 question 16 #19

roddypr opened this issue Jul 20, 2017 · 1 comment

Comments

@roddypr
Copy link
Contributor

roddypr commented Jul 20, 2017

This question asks to generate the reverse complement of a sequence using "gsub". Using "gsub" is quite dangerous in this question. A better solution is to use "match", despite this not being the point of the exercise:

sequence <- "ATTACGACGCGATTCCCGGTTAATCGAATTCCCA"

# Complement of each nucleotide
dna_code               <- c("A","C","G","T")
complement_code <- c("T","G", "C","A")

# Complement of sequence
comp_seq <- complement_code[match(sequence, dna_code)]

# Reverse
rev_comp <- rev(rev_comp)

# paste together
rev_comp <- paste(rev_comp, collapse = "")

@yannickwurm
Copy link
Member

yannickwurm commented Jul 20, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants