Skip to content

Instantly share code, notes, and snippets.

@bryan-lunt
Created January 26, 2013 06:12
Show Gist options
  • Save bryan-lunt/4640508 to your computer and use it in GitHub Desktop.
Save bryan-lunt/4640508 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
'''
Created on Jan 18, 2013
@author: lunt
'''
import sys
import Bio.pairwise2 as PW
def printall(alignments):
print "one set"
for a in alignments:
sys.stderr.write( PW.format_alignment(*a) )
sys.stderr.write('\n')
def main():
seq1 = "AAAABBBAAAACCCCCCCCCCCCCCAAAABBBAAAA"
seq2 = "AABBBAAAACCCCAAAABBBAA"
breaks = set([11])
nogaps = lambda x,y: -2000 -y #There really should not be inserts with respect to the database sequence.
specificgaps = lambda x,y: (-2 -y) if x in breaks else (-2000 -y) #This makes it very expensive to open a gap anywhere but in the middle of the CCs
alignments = PW.align.globalmc(seq1,seq2,1,-1,nogaps,specificgaps)
printall(alignments)
breaks = set([3])
#now, it should break after the first B in seq2, if it doesnt: there is a problem
alignments = PW.align.globalmc(seq1,seq2,1,-1,nogaps,specificgaps)
printall(alignments)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment