I have been successfully using BioPython's functionality for extracting protein torsion angles using the IC_Chain module. However, I am currently looking to use the inverse functionality as follows:

from Bio.PDB import PDBParser, internal_coords

# Read PDB entry.
parser = PDBParser(PERMISSIVE=1, QUIET=1)
structure = parser.get_structure('', 'example.pdb')

# Generate protein internal coordinates (angles).
ic_chain_bound = internal_coords.IC_Chain(structure)

# Generate back 3D coordinates from angles.

but this fails with the following error:

Traceback (most recent call last):
  File "test_biopython_internal_coords.py", line 97, in <module>
  File "test_biopython_internal_coords.py", line 89, in main
  File "/software/anaconda/installation/envs/alphafold/lib/python3.7/site-packages/Bio/PDB/internal_coords.py", line 661, in internal_to_atom_coordinates
    verbose=verbose, start=start, fin=fin
  File "software/anaconda/installation/envs/alphafold/lib/python3.7/site-packages/Bio/PDB/internal_coords.py", line 415, in assemble_residues
    Dict[AtomKey, numpy.array], ric.assemble(verbose=verbose)
  File "/software/anaconda/installation/envs/alphafold/lib/python3.7/site-packages/Bio/PDB/internal_coords.py", line 1732, in assemble
    atomCoords = self.get_startpos()
  File "/software/anaconda/installation/envs/alphafold/lib/python3.7/site-packages/Bio/PDB/internal_coords.py", line 1632, in get_startpos
    sp = self.residue.parent.internal_coord.initNCaC.get(self.rbase, None)
AttributeError: 'NoneType' object has no attribute 'initNCaC'

Is this not the intended use? Could someone help me figure out why this is failing?

I'm using this PDB file in my example, but the code previously failed for all other PDB files I tried.



2 Answers 2


not able to grasp the question, tried to figure out a way to show the internal_coordinates:

from Bio.PDB import PDBParser, PICIO, PDBIO

# Read PDB entry.
parser = PDBParser(PERMISSIVE=1, QUIET=1)
structure = parser.get_structure('', 'example.pdb')

print(dir(structure)) # 'atom_to_internal_coordinates' and
                      # 'internal_to_atom_coordinates' seems
                      # to be structure methods

# Generate protein internal coordinates (angles).

structure.atom_to_internal_coordinates(verbose = True)

PICIO.write_PIC(structure[0]['A'], 'internal')

# Generate back 3D coordinates from angles.

pippo = PICIO.read_PIC('internal')

pippo.internal_to_atom_coordinates(verbose = True)


io = PDBIO()


io.save('atom_coord.pdb',  preserve_atom_numbering=True) 

compare example.pdb to internal and atom_coord.pdb;

have a look at internal file contents if you comment out

structure.atom_to_internal_coordinates(verbose = True) (around line 17 of

code, # Generate protein internal coordinates (angles). block-code )


It turns out that in order to generate the internal coordinates for a protein structure, one shouldn't manually create an IC_Chain object, but rather just use the atom_to_internal_coordinates() method of the structure and the internal_to_atom_coordinates() one for the inverse functionality.


# Now you have access to the bond angles and lengths
# of the first chain of structure as follows:
chain = list(structure.get_chains())[0]
ic_chain = chain.internal_coord

# Dictionary mapping 3 AtomKeys to a Hedron 
# (with len12, len23, angle fields):
# ic_chain.hedra

# Dictionary mapping 4 AtomKeys to a Dihedraon
# (with angle field for torsion angles):
# ic_chain.dihedra


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.