Bio.Iupac Problem In Biopython
2
2
Entering edit mode
13.1 years ago
Saifalharthi ▴ 20

i was testing this simple code


from Bio.Alphabet import IUPAC
from Bio import Seq
my_prot=Seq("AGTACACTGGT",IUPAC.protein)

and it gives me this error

TypeError: 'module' object is not callable

can anyone explain why this is happening?

PS: this is an Example from the BioPython's Cookbook

python biopython • 4.5k views
ADD COMMENT
6
Entering edit mode
13.1 years ago

Try using

from Bio.Seq import Seq

like in

from Bio.Alphabet import IUPAC
from Bio.Seq import Seq
my_prot=Seq("AGTACACTGGT",IUPAC.protein)
print my_prot
print "Could be, but I would think it is DNA"
ADD COMMENT
1
Entering edit mode
ADD REPLY
0
Entering edit mode

thanks man , i guess the document is old

ADD REPLY
0
Entering edit mode
5.2 years ago
cronywalls ▴ 10

This error statement TypeError: 'module' object is not callable is raised as you are being confused about the Class name and Module name. The problem is in the import line . You are importing a module, not a class. This happend because the module name and class name have the same name .

If you have a class "MyClass" in a file called "MyClass.py" , then you should import :

from MyClass import MyClass

In Python , a script is a module, whose name is determined by the filename . So when you start out your file MyClass.py with import MyClass you are creating a loop in the module structure.

ADD COMMENT

Login before adding your answer.

Traffic: 2441 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6