<html><head></head><body><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:10px;"><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:10px;"><div>The pairwise aligner makes use of a trace matrix as described in detail in e.g. Biological Sequence Analysis by Richard Durbin et al.</div><div>Each alignment corresponds to a path through this trace matrix, consisting of horizontal, vertical, and diagonal segments. Horizontal and vertical segments are gaps; diagonal segments are sequence alignments. The path you got are the vertices in the trace matrix connecting the segments.</div><div>In your example:</div><div><br></div><div><span> ((0, 0), (182, 0), (188, 6), (193, 6)) means</span></div><div><span><br></span></div><div><span><span> (0, 0) - (182, 0)</span></span>: a gap of 182 amino acids<br></div><div><br></div><div><span><span><span>(182, 0), (188, 6)</span></span>: an alignment of 6 amino acids (amino acids 182-188 in one sequence against amino acids 0-6 in the other sequence)<br></span></div><div><div><span><span><span><span><br></span></span></span></span></div><div><span><span><span><span>(188, 6), (193, 6)): a gap of 6 amino acids.</span></span></span></span></div><div><span><span><span><span><br></span></span></span></span></div><div><span><span><span><span>Try a few simple examples and compare to Richard Durbin's book; that should make things clear.<br></span></span></span></span></div><div><span><span><span><span><br></span></span></span></span></div><div><span><span><span><span>Best,</span></span></span></span></div><div><span><span><span><span>-Michiel<br></span></span></span></span></div><div><span><span></span></span><br></div><div><br></div><span><span><div><br></div></span></span><br></div><div><br></div>
        
        </div><div id="yahoo_quoted_9824357579" class="yahoo_quoted">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                
                <div>
                    On Saturday, October 6, 2018, 1:01:06 AM GMT+9, Peter Cock <p.j.a.cock@googlemail.com> wrote:
                </div>
                <div><br></div>
                <div><br></div>
                <div><div dir="ltr">Yes, if you look at the code which makes that string<br clear="none">it does it via the path structure:<br clear="none"><br clear="none"><a shape="rect" href="https://github.com/biopython/biopython/blob/biopython-172/Bio/Align/__init__.py#L991" target="_blank">https://github.com/biopython/biopython/blob/biopython-172/Bio/Align/__init__.py#L991</a><br clear="none"><br clear="none">What do you want out of the alignment object? Two strings<br clear="none">with gap characters inserted? Something else?<br clear="none"><br clear="none">Peter<br clear="none"><br clear="none">On Thu, Oct 4, 2018 at 9:48 PM John Berrisford <<a shape="rect" ymailto="mailto:jmb@ebi.ac.uk" href="mailto:jmb@ebi.ac.uk">jmb@ebi.ac.uk</a>> wrote:<br clear="none">><br clear="none">> Hi<br clear="none">><br clear="none">><br clear="none">><br clear="none">> How do I get the alignment out of Align.PairwiseAligner?<br clear="none">><br clear="none">><br clear="none">><br clear="none">> I have the following code<br clear="none">><br clear="none">><br clear="none">><br clear="none">> aligner = Align.PairwiseAligner()<br clear="none">><br clear="none">> alignments = aligner.align(self.sequence1, self.sequence2)<br clear="none">> for alignment in sorted(alignments):<br clear="none">><br clear="none">> logging.debug(alignment)<br clear="none">> logging.debug(alignment.score)<br clear="none">> logging.debug(alignment.target)<br clear="none">> logging.debug(alignment.query)<br clear="none">> logging.debug(alignment.path)<br clear="none">> logging.debug(dir(alignment))<br clear="none">><br clear="none">><br clear="none">><br clear="none">> my example<br clear="none">><br clear="none">> Query 193 residues long.<br clear="none">><br clear="none">> Target 6 residues long.<br clear="none">><br clear="none">><br clear="none">><br clear="none">> out of this I can get the<br clear="none">><br clear="none">> alignment – which appears to be a line separated string of query, alignment, target.<br clear="none">><br clear="none">> In my example:<br clear="none">><br clear="none">> MEKLEVGIYTRAREGEIACGDACLVKRVEGVIFLAVGDGIGHGPEAARAAEIAIASMESSMNTGLVNIFQLCHRELRGTRGAVAALCRVDRRQGLWQAAIVGNIHVKILSAKGIITPLATPGILGYNYPHQLLIAKGSYQEGDLFLIHSDGIQEGAVPLALLANYRLTAEELVRLIGEKYGRRDDDVAVIVAR<br clear="none">><br clear="none">> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|XX|XX-----<br clear="none">><br clear="none">> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------RANDOM-----<br clear="none">><br clear="none">> score – the alignment score (I can also get this with aligner.score)<br clear="none">><br clear="none">> target – self.sequence2<br clear="none">><br clear="none">> query – self.sequence1<br clear="none">><br clear="none">> path – I think this is what I want, but I don’t know how to interpret this – it is something the following in the above example: ((0, 0), (182, 0), (188, 6), (193, 6))<br clear="none">><br clear="none">> is this documented somewhere?<br clear="none">><br clear="none">> It looks like 0-181 no alignment, 182 to 187 adds a score of 6. 188 to 193 keeps the score at 6.<br clear="none">><br clear="none">><br clear="none">><br clear="none">><br clear="none">><br clear="none">> when I dir(alignment) I only see the above options<br clear="none">><br clear="none">> ['__class__', '__cmp__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt_<br clear="none">><br clear="none">> _', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subc<br clear="none">><br clear="none">> lasshook__', '__weakref__', '_format_psl', 'path', 'query', 'score', 'target']<br clear="none">><br clear="none">><br clear="none">><br clear="none">> what I’m after is the middle row of the alignment (above). Is the only option to split alignment on carriage return?<br clear="none">><br clear="none">><br clear="none">><br clear="none">> Thanks<br clear="none">><br clear="none">><br clear="none">><br clear="none">> John<br clear="none">><br clear="none">><br clear="none">><br clear="none">> --<br clear="none">><br clear="none">> John Berrisford<br clear="none">><br clear="none">> PDBe<br clear="none">><br clear="none">> European Bioinformatics Institute (EMBL-EBI)<br clear="none">><br clear="none">> European Molecular Biology Laboratory<br clear="none">><br clear="none">> Wellcome Trust Genome Campus<br clear="none">><br clear="none">> Hinxton<br clear="none">><br clear="none">> Cambridge CB10 1SD UK<br clear="none">><br clear="none">> Tel: +44 1223 492529<br clear="none">><br clear="none">><br clear="none">><br clear="none">> <a shape="rect" href="http://www.pdbe.org" target="_blank">http://www.pdbe.org</a><br clear="none">><br clear="none">> <a shape="rect" href="http://www.facebook.com/proteindatabank" target="_blank">http://www.facebook.com/proteindatabank</a><br clear="none">><br clear="none">> <a shape="rect" href="http://twitter.com/PDBeurope" target="_blank">http://twitter.com/PDBeurope</a><br clear="none">><br clear="none">><br clear="none">><br clear="none">> _______________________________________________<br clear="none">> Biopython mailing list  -  <a shape="rect" ymailto="mailto:Biopython@mailman.open-bio.org" href="mailto:Biopython@mailman.open-bio.org">Biopython@mailman.open-bio.org</a><br clear="none">> <a shape="rect" href="http://mailman.open-bio.org/mailman/listinfo/biopython" target="_blank">http://mailman.open-bio.org/mailman/listinfo/biopython</a><div class="yqt3233127428" id="yqtfd84567"><br clear="none"><br clear="none">_______________________________________________<br clear="none">Biopython mailing list  -  <a shape="rect" ymailto="mailto:Biopython@mailman.open-bio.org" href="mailto:Biopython@mailman.open-bio.org">Biopython@mailman.open-bio.org</a><br clear="none"><a shape="rect" href="http://mailman.open-bio.org/mailman/listinfo/biopython" target="_blank">http://mailman.open-bio.org/mailman/listinfo/biopython</a></div></div></div>
            </div>
        </div></div></body></html>