[Biopython] Error in pdb superimposer: global name Bio not defined

Vivek Rai vivekraiiitkgp at gmail.com
Fri Nov 7 15:30:45 UTC 2014


Hi Sanjeev,

It's because of incorrect import. You have already brought all the
functions in local scope by importing them as `from Bio.PDB import *`
i.e., you can now directly use `super_imposer = Superimposer()`.

To use the code that you had been using, you need to just do `import Bio`.
Vivek Rai
https://vivekiitkgp.github.io


On Fri, Nov 7, 2014 at 8:25 PM, Sanjeev Sariya <s.sariya_work at ymail.com> wrote:
> Hi Team,
>
> I am trying to align 2 pdb files..
> When I try to create an object for Bio.PDB.Superimposer(), I get a strange
> error.
>
> Langauge specs:
> Python version - 2.7
>
> Bio.__version__ - 1.61 ## bio python version
>
> My code looks like:
>
> from Bio.PDB import *
> def alignPDB_file(refPDB, samplePDB): # function to align pdb file
>      ref_atoms,sample_atoms=[],[]
>
>      ref_model=PDBParser(QUIET=True).get_structure("reference",refPDB)[0] #
> get the 0th model
>      sam_model=PDBParser(QUIET=True).get_structure("sample",samplePDB)[0] #
> get the 0th model
>
>      for ref_chain in ref_model:
>           for ref_res in ref_chain:
>                if not "CA" in ref_res:continue
>                else:  ref_atoms.append(ref_res['CA'])
>
>      for sam_chain in sam_model:
>           for sam_res in sam_chain:
>                if not "CA" in sam_res: continue
>                else: sample_atoms.append(sam_res['CA'])
>
>      #super_imposer=Bio.PDB.Superimposer()
>      super_imposer = Bio.PDB.Superimposer()
>
>
> Error:
>     super_imposer = Bio.PDB.Superimposer()
> NameError: global name 'Bio' is not defined
>
> Kindly advise.
>
>
> _______________________________________________
> Biopython mailing list  -  Biopython at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython


More information about the Biopython mailing list