Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'module' object is not callable - Bio.IUPAC

When I try,

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

Why do I encounter the following error:

TypeError: 'module' object is not callable

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

like image 892
Saif al Harthi Avatar asked Jan 20 '23 02:01

Saif al Harthi


1 Answers

In the BioPython source code the "Seq" class is located in the file "Seq.py" in the path "/Seq/Seq.py"

Meaning... You need to import Seq (a file) which means its a "Module" and then call the class "Seq" within the 'Module' 'Seq'

So try this:

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

If you are ever confused in Python about what you are importing and what you are calling you can do this:

import Bio.Seq
print type(Bio.Seq)
>>> <type 'module'>
print type(Bio.Seq.Seq)
>>> <type 'classobj'>
like image 144
Ben DeMott Avatar answered Jan 29 '23 13:01

Ben DeMott