Skip to content

Practical 2 question 16 #19

@roddypr

Description

@roddypr

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 = "")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions