[Biopython] Displaying pairwise2 output fails.

Ivan Gregoretti ivangreg at gmail.com
Thu May 23 13:32:52 UTC 2013


Thank you Bow. I did try many variations to try to load
format_alignment() but I was unsuccessful; "from Bio.pairwise2 import
format_alignment" did not cross my mind.

Ivan

Ivan Gregoretti, PhD
Bioinformatics




On Thu, May 23, 2013 at 9:13 AM, Wibowo Arindrarto
<w.arindrarto at gmail.com> wrote:
> 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