[Biopython] Getting aligned residues index

Michiel de Hoon mjldehoon at yahoo.com
Wed Jun 6 06:56:45 UTC 2018


With the new pairwise aligner in Bio.Align (which is in github but not in a release yet), you can do:
>>> from Bio.Align import PairwiseAligner
>>> pacrg_fasta = 'DUDEWHEREISMYCAR'
>>> model = 'MANWHEREISMYCAT'
>>> aligner = PairwiseAligner()
>>> alignments = aligner.align(pacrg_fasta, model)
>>> alignment = alignments[0]>>> path = alignment.path>>> for (x1, y1), (x2, y2) in zip(path[:-1], path[1:]):
...     if x1==x2 or y1==y2: continue  # this is a gap
...     for x, y in zip(range(x1,x2), range(y1,y2)):
...         print(x, y)
... 
4 3
5 4
6 5
7 6
8 7
9 8
10 9
11 10
12 11
13 12
14 13

Best,
-Michiel 

    On Wednesday, June 6, 2018 2:24 AM, Ahmad Abdelzaher <underoath006 at gmail.com> wrote:
 

 Hello,

I have the following code snippet: 

from Bio import pairwise2
pacrg_fasta = 'DUDEWHEREISMYCAR'
model = 'MANWHEREISMYCAT'
alignments = pairwise2.align.globalxx(pacrg_fasta, model)print(pairwise2.format_alignment(*alignments[0]))
The first matching letter is W. I want to be able to get the index of the matching residues in a tuple, for example (4,3) for W, how can I do that for all the matching residues? 
Regards. _______________________________________________
Biopython mailing list  -  Biopython at mailman.open-bio.org
http://mailman.open-bio.org/mailman/listinfo/biopython

   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20180606/c72255c5/attachment.html>


More information about the Biopython mailing list