Skip to content

Instantly share code, notes, and snippets.

@Ad115
Created June 5, 2018 03:26
Show Gist options
  • Save Ad115/d07c318a2f988845c57dcf98a02aa2e9 to your computer and use it in GitHub Desktop.
Save Ad115/d07c318a2f988845c57dcf98a02aa2e9 to your computer and use it in GitHub Desktop.
Introduction to BioPython's Seq objects.
from Bio.Seq import Seq
# Create sequence object
my_sequence = Seq("AGTACACTGGT")
# Show the sequence object
print("Sequence:", my_sequence)
# The sequence was created with a generic alphabet.
# The alphabet tells us whether it is a DNA, RNA or
# protein sequence and whether it is ambiguous or not.
print("Alphabet:", my_sequence.alphabet)
# We can easily get the complement
complement = my_sequence.complement()
print("Complement:", complement)
# Same with the reverse complement
rev_complement = my_sequence.reverse_complement()
print("Reverse complement:", rev_complement)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment