<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10px"><div id="yui_3_16_0_ym19_1_1528267431350_14551"><span id="yui_3_16_0_ym19_1_1528267431350_14550">With the new pairwise aligner in Bio.Align (which is in github but not in a release yet), you can do:</span></div><div id="yui_3_16_0_ym19_1_1528267431350_14529"><span><br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_14527"><font face="Courier New, courier, monaco, monospace, sans-serif"><span id="yui_3_16_0_ym19_1_1528267431350_14546">>>> from Bio.Align import PairwiseAligner<br id="yui_3_16_0_ym19_1_1528267431350_14526"></span></font></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_14597"><font face="Courier New, courier, monaco, monospace, sans-serif"><span id="yui_3_16_0_ym19_1_1528267431350_14546">>>> pacrg_fasta = 'DUDEWHEREISMYCAR'<br id="yui_3_16_0_ym19_1_1528267431350_14549">>>> model = 'MANWHEREISMYCAT'</span></font></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_14602"><font face="Courier New, courier, monaco, monospace, sans-serif"><span id="yui_3_16_0_ym19_1_1528267431350_14546"><br></span></font></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_14623"><font face="Courier New, courier, monaco, monospace, sans-serif"><span id="yui_3_16_0_ym19_1_1528267431350_14546">>>> aligner = PairwiseAligner()<br id="yui_3_16_0_ym19_1_1528267431350_14626">>>> alignments = aligner.align(pacrg_fasta, model)<br id="yui_3_16_0_ym19_1_1528267431350_14663">>>> alignment = alignments[0]</span></font></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_14790"><font face="Courier New, courier, monaco, monospace, sans-serif"><span id="yui_3_16_0_ym19_1_1528267431350_14546">>>> path = alignment.path</span></font></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_14716"><font face="Courier New, courier, monaco, monospace, sans-serif"><span id="yui_3_16_0_ym19_1_1528267431350_14546">>>> for (x1, y1), (x2, y2) in zip(path[:-1], path[1:]):<br id="yui_3_16_0_ym19_1_1528267431350_14769">... if x1==x2 or y1==y2: continue # this is a gap<br id="yui_3_16_0_ym19_1_1528267431350_14770">... for x, y in zip(range(x1,x2), range(y1,y2)):<br id="yui_3_16_0_ym19_1_1528267431350_14771">... print(x, y)<br id="yui_3_16_0_ym19_1_1528267431350_14772">... <br id="yui_3_16_0_ym19_1_1528267431350_14773">4 3<br id="yui_3_16_0_ym19_1_1528267431350_14774">5 4<br id="yui_3_16_0_ym19_1_1528267431350_14775">6 5<br id="yui_3_16_0_ym19_1_1528267431350_14776">7 6<br id="yui_3_16_0_ym19_1_1528267431350_14777">8 7<br id="yui_3_16_0_ym19_1_1528267431350_14778">9 8<br id="yui_3_16_0_ym19_1_1528267431350_14779">10 9<br id="yui_3_16_0_ym19_1_1528267431350_14780">11 10<br id="yui_3_16_0_ym19_1_1528267431350_14781">12 11<br id="yui_3_16_0_ym19_1_1528267431350_14782">13 12<br id="yui_3_16_0_ym19_1_1528267431350_14783">14 13</span></font></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_14855"><span id="yui_3_16_0_ym19_1_1528267431350_14546"><br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_14856"><span id="yui_3_16_0_ym19_1_1528267431350_14546"><br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_14911"><span id="yui_3_16_0_ym19_1_1528267431350_14546">Best,<br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1528267431350_15005"><span id="yui_3_16_0_ym19_1_1528267431350_14546">-Michiel</span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> On Wednesday, June 6, 2018 2:24 AM, Ahmad Abdelzaher <underoath006@gmail.com> wrote:<br></font></div> <br><br> <div class="y_msg_container"><div id="yiv8520618335"><div dir="ltr">Hello,<br><div><br></div><div>I have the following code snippet: </div><div><br></div><div><br></div><div><div>from Bio import pairwise2</div><div><br></div><div>pacrg_fasta = 'DUDEWHEREISMYCAR'</div><div><br></div><div>model = 'MANWHEREISMYCAT'</div><div><br></div><div>alignments = pairwise2.align.globalxx(pacrg_fasta, model)</div><div>print(pairwise2.format_alignment(*alignments[0]))</div></div><div><br></div><div>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? </div><div><br></div><div>Regards. </div></div></div>_______________________________________________<br>Biopython mailing list - <a ymailto="mailto:Biopython@mailman.open-bio.org" href="mailto:Biopython@mailman.open-bio.org">Biopython@mailman.open-bio.org</a><br><a href="http://mailman.open-bio.org/mailman/listinfo/biopython" target="_blank">http://mailman.open-bio.org/mailman/listinfo/biopython</a><br><br></div> </div> </div> </div></div></body></html>