[Biopython] getting alignment out of Align.PairwiseAligner

John Berrisford jmb at ebi.ac.uk
Thu Oct 4 19:25:56 UTC 2018


Hi

 

How do I get the alignment out of Align.PairwiseAligner?

 

I have the following code

 

aligner = Align.PairwiseAligner()

alignments = aligner.align(self.sequence1, self.sequence2)
for alignment in sorted(alignments):
logging.debug(alignment)
logging.debug(alignment.score)
logging.debug(alignment.target)
logging.debug(alignment.query)
logging.debug(alignment.path)
logging.debug(dir(alignment))

 

my example

Query 193 residues long. 

Target 6 residues long.

 

out of this I can get the 

alignment - which appears to be a line separated string of query, alignment,
target. 

In my example:

MEKLEVGIYTRAREGEIACGDACLVKRVEGVIFLAVGDGIGHGPEAARAAEIAIASMESSMNTGLVNIFQLCHREL
RGTRGAVAALCRVDRRQGLWQAAIVGNIHVKILSAKGIITPLATPGILGYNYPHQLLIAKGSYQEGDLFLIHSDGI
QEGAVPLALLANYRLTAEELVRLIGEKYGRRDDDVAVIVAR

----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------------------------|XX|XX-----

----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------------------------RANDOM-----

score - the alignment score (I can also get this with aligner.score)

target - self.sequence2

query - self.sequence1

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))

is this documented somewhere?

It looks like 0-181 no alignment, 182 to 187 adds a score of 6. 188 to 193
keeps the score at 6.

 

 

when I dir(alignment) I only see the above options

['__class__', '__cmp__', '__delattr__', '__dict__', '__dir__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__gt_

_', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str__', '__subc

lasshook__', '__weakref__', '_format_psl', 'path', 'query', 'score',
'target']

 

what I'm after is the middle row of the alignment (above). Is the only
option to split alignment on carriage return? 

 

Thanks

 

John

 

--

John Berrisford

PDBe

European Bioinformatics Institute (EMBL-EBI)

European Molecular Biology Laboratory

Wellcome Trust Genome Campus

Hinxton

Cambridge CB10 1SD UK

Tel: +44 1223 492529

 

 <http://www.pdbe.org/> http://www.pdbe.org

 <http://www.facebook.com/proteindatabank>
http://www.facebook.com/proteindatabank

 <http://twitter.com/PDBeurope> http://twitter.com/PDBeurope

 

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


More information about the Biopython mailing list