Module 8

Reverse complement

The most common sequence operation.

Reverse complement

The reverse complement is the complement read backwards. It is one of the most common operations in bioinformatics.

Python
def complement(seq):
    comp = ""
    for base in seq:
        if base == "A": comp += "T"
        elif base == "T": comp += "A"
        elif base == "G": comp += "C"
        elif base == "C": comp += "G"
    return comp

seq = "ATGC"
print(complement(seq)[::-1])
GCAT
Your task

Reverse complement

  • Compute the reverse complement of ATGC.