[Biopython] Displaying pairwise2 output fails.

Wibowo Arindrarto w.arindrarto at gmail.com
Thu May 23 09:13:36 EDT 2013


Hi Ivan

On Thu, May 23, 2013 at 3:07 PM, Ivan Gregoretti <ivangreg at gmail.com> wrote:
> Hello Biopythonians,
>
> Are you able to display pairwise alignments? It fails in my system:
>
> from Bio import pairwise2
> for a in pairwise2.align.globalxx("ACCGT", "ACG"):
>     print format_alignment(*a)
>
> Traceback (most recent call last):
>   File "<stdin>", line 2, in <module>
> NameError: name 'format_alignment' is not defined

This happens because of the way Python namespacing works. With your
current import, you should write this:

print pairwise2.format_alignment ...

instead of this:

print format_alignment ...

The code you have will work if you import format_alignment explicitly, like so:

from Bio.pairwise2 import format_alignment

Hope that helps :),
Bow


More information about the Biopython mailing list