Skip to content

Instantly share code, notes, and snippets.

@elowy01
Last active June 28, 2022 15:21
Show Gist options
  • Save elowy01/79f13cade08bfc0bb7d4794649ad07af to your computer and use it in GitHub Desktop.
Save elowy01/79f13cade08bfc0bb7d4794649ad07af to your computer and use it in GitHub Desktop.
# global alignment between 2 sequences
from Bio import pairwise2
alignments = pairwise2.align.globalxx("ACCGT", "ACG") # returns a list of alignments
# you can format the alignments
from Bio.pairwise2 import format_alignment
print(format_alignment(*alignments[0]))
ACCGT
| ||
A-CG-
Score=3
# Local alignment
for a in pairwise2.align.localxx("ACCGT", "ACG"):
print(format_alignment(*a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment