Question: Error with biopython pairwise aligner
0
gravatar for john
22 months ago by
john70
European Union
john70 wrote:

I try to use the pairwise aligner provided by biopython. But I fail to get the examples working. When I execute the following code:

>>> from Bio import Align
>>> aligner = Align.PairwiseAligner()

The second lines returns the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'PairwiseAligner'

I run with Python 2.7.15 and Biopython 1.71

Thank you

biopython • 1.5k views
ADD COMMENTlink written 22 months ago by john70
2

try Bio.pairwise2. http://biopython.org/DIST/docs/api/Bio.pairwise2-module.html

ADD REPLYlink written 22 months ago by Eric Lim1.7k

it has not the same functionality

ADD REPLYlink written 22 months ago by john70

Python 2.7.15

Why? You should move to Python3. I'm facing the same problem with both py2.7.15 and py3+, so I don't know what the problem is.

a = Align.PairwiseAlignment()

doesn't work either.

ADD REPLYlink modified 22 months ago • written 22 months ago by RamRS27k
3
gravatar for Joe
22 months ago by
Joe16k
United Kingdom
Joe16k wrote:

The Align submodule doesn't appear to contain any such class/function (testing with Py2.7 and Py3) with BioPython 1.70/1.71, though it does appear that there should be such an object according to the docs: https://biopython.org/DIST/docs/api/Bio.Align.PairwiseAlignment-class.html

>>> from Bio import Align
>>> Align.
Align.Alphabet               Align.__delattr__(           Align.__getattribute__(      Align.__package__            Align.__setattr__(
Align.MultipleSeqAlignment(  Align.__dict__               Align.__hash__(              Align.__path__               Align.__sizeof__(
Align.Seq(                   Align.__doc__                Align.__init__(              Align.__reduce__(            Align.__str__(
Align.SeqRecord(             Align.__file__               Align.__name__               Align.__reduce_ex__(         Align.__subclasshook__(
Align.__class__(             Align.__format__(            Align.__new__(               Align.__repr__(              Align.print_function

As Eric suggested, what you might want is Bio.pairwise2.

Under biopython 1.72, the very latest version in conda, the objects exist. I at least get an error that appears sensible!

>>> import Bio
>>> from Bio import Align
>>> Bio.__version__
'1.72'
>>> Align.
Align.Alphabet               Align.SeqRecord(             Align.__file__               Align.__new__(               Align.__setattr__(           Align.sys
Align.MultipleSeqAlignment(  Align._RestrictedDict(       Align.__format__(            Align.__package__            Align.__sizeof__(
Align.PairwiseAligner(       Align.__class__(             Align.__getattribute__(      Align.__path__               Align.__str__(
Align.PairwiseAlignment(     Align.__delattr__(           Align.__hash__(              Align.__reduce__(            Align.__subclasshook__(
Align.PairwiseAlignments(    Align.__dict__               Align.__init__(              Align.__reduce_ex__(         Align._aligners
Align.Seq(                   Align.__doc__                Align.__name__               Align.__repr__(              Align.print_function
>>> a = Align.PairwiseAlignment()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() takes exactly 5 arguments (1 given)

And PairwiseAligner doen't throw any errors when assigned to variable:

>>> aligner = Align.PairwiseAligner()
>>> aligner
Pairwise aligner, implementing the Needleman-Wunsch, Smith-Waterman, Gotoh, and Waterman-Smith-Beyer global and local alignment algorithms
>>>

In short, I would suggest updating to the bleeding edge version, 1.72. If you're using conda this is fairly straightforward:

conda install -c anaconda biopython
ADD COMMENTlink modified 22 months ago • written 22 months ago by Joe16k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1930 users visited in the last hour