This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bio.Iupac Problem In Biopython

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

2 answers

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"

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.

Log in to answer this question.