I'm trying to see how much "header" info I can get out of a PDB file, following the hints at The Biopython Structural Bioinformatics FAQ. I'm led to use the mmCIF version. but there seems something odd about the package/egg:
>>> from Bio.PDB import *
>>> cifFile = '.../path2/3VQ8.cif'
>>> mmcif_dict = MMCIF2Dict(cifFile)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'MMCIF2Dict' is not defined
I get a different error if I fully qualify the class:
>>> import Bio.PDB
>>> mmcif_dict = Bio.PDB.MMCIF2Dict(cifFile)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'MMCIF2Dict'
Note that most of Bio.PDB works as I expect:
>>> parser=PDBParser(PERMISSIVE=1)
>>> inf = '.../path2/3NF8.pdb'
>>> structure=parser.get_structure('3Nf8',inf)
>>> structure.header.keys()
['structure_method', 'head', 'journal_reference', 'compound',
'name', 'author', 'deposition_date', 'release_date', 'source',
'resolution', 'structure_reference']
and I have a recent version:
>>> Bio.__version__
'1.61'
which does have the MMCIF2Dict.py
file is inside the Bio egg, but MMCIF2Dict
isn't in the module:
>>> dir(Bio.PDB)
['AbstractPropertyMap', 'Atom', 'CaPPBuilder', 'Chain', 'DSSP', 'Dice',
'Entity', 'ExposureCN', 'FragmentMapper', 'HSExposure', 'HSExposureCA',
'HSExposureCB', 'Model', 'NeighborSearch', 'PDBExceptions', 'PDBIO',
'PDBList', 'PDBParser', 'PPBuilder', 'Polypeptide', 'Residue',
'ResidueDepth', 'Select', 'Selection', 'Structure',
'StructureAlignment', 'StructureBuilder', 'Superimposer', 'Vector',
'__builtins__', '__doc__', '__file__', '__name__', '__package__',
'__path__', 'calc_angle', 'calc_dihedral', 'extract', 'get_surface',
'is_aa', 'm2rotaxis', 'make_dssp_dict', 'mmCIF', 'parse_pdb_header',
'refmat', 'rotaxis', 'rotaxis2m', 'rotmat', 'standard_aa_names',
'to_one_letter_code', 'vector_to_axis']
Anyone have a clue?
You'll find the answer in Bio.PDB
's __init__.py
.
In short, from Bio.PDB import *
imports everything in __init__.py
's namespace. If you read __init__.py
, you can see that it imports MMCIFParser
, but not MMCIF2Dict
(at least not directly): MMCIFParser
imports MMCIF2Dict
and makes use of it there.
So, if you do from Bio.PDB import MMCIF2Dict; mmcif_dict = MMCIF2Dict.MMCIF2Dict(cifFile)
, it should work without complaint. However, from Bio.PDB import *
won't put MMCIF2Dict
into the current namespace.