Skip to content

Instantly share code, notes, and snippets.

@meren
Last active August 29, 2015 14:05
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 meren/f321fa2e6643dc436528 to your computer and use it in GitHub Desktop.
Save meren/f321fa2e6643dc436528 to your computer and use it in GitHub Desktop.
from cogent.align.algorithm import nw_align as nw_align_cogent
from skbio.alignment import global_pairwise_align_nucleotide as nw_align_scikit
seq_1 = 'ATCGATCGATCG'
seq_2 = 'ATCGATATCGATCG'
print "Sequences: "
print " %s" % seq_1
print " %s" % seq_2
print
alignment = nw_align_scikit(seq_1, seq_2)
al_1, al_2 = [alignment.get_seq(_id).__str__() for _id in alignment.ids()]
print " nw alignment using scikit:"
print " %s" % al_1
print " %s" % al_2
print
al_1, al_2 = nw_align_cogent(seq_1, seq_2)
print " nw alignment using cogent:"
print " %s" % al_1
print " %s" % al_2
print
# meren ~ $ python -W ignore test.py
# Sequences:
# ATCGATCGATCG
# ATCGATATCGATCG
#
# nw alignment using scikit:
# ------ATCGATCGATCG
# ATCGATATCGATCG----
#
# nw alignment using cogent:
# ATCGAT--CGATCG
# ATCGATATCGATCG
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment