Skip to content

Instantly share code, notes, and snippets.

@Vini2
Last active September 2, 2017 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vini2/e575a31e6a0db77adeee24085ce8b368 to your computer and use it in GitHub Desktop.
Save Vini2/e575a31e6a0db77adeee24085ce8b368 to your computer and use it in GitHub Desktop.
# Import pairwise2 module
from Bio import pairwise2
# Import format_alignment method
from Bio.pairwise2 import format_alignment
# Define two sequences to be aligned
X = "ACGGGT"
Y = "ACG"
# Get a list of the global alignments between the two sequences ACGGGT and ACG satisfying the given scoring
# A match score is the score of identical chars, else mismatch score.
# Same open and extend gap penalties for both sequences.
alignments = pairwise2.align.globalms(X, Y, 2, -1, -0.5, -0.1)
# Use format_alignment method to format the alignments in the list
for a in alignments:
print(format_alignment(*a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment