text: user12036: 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)
  ic_chain_bound.atom_to_internal_coordinates()
  
  # Generate back 3D coordinates from angles.
  ic_chain_bound.internal_to_atom_coordinates()
  
  but this fails with the following error:
  Traceback (most recent call last):
    File "test_biopython_internal_coords.py", line 97, in <module>
      main(args)
    File "test_biopython_internal_coords.py", line 89, in main
      ic_chain_bound.internal_to_atom_coordinates()
    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.
  Thanks!
  
  user10049: 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)
  
  print(pippo)
  
  
  io = PDBIO()
  
  io.set_structure(pippo)
  
  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 )
  
  user12036: 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.
  structure.atom_to_internal_coordinates()
  
  # 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
  
  structure.internal_to_atom_coordinates()
  
  
original_text: 12036: <p>I have been successfully using BioPython's functionality for extracting protein torsion angles using the <code>IC_Chain</code> module. However, I am currently looking to use the inverse functionality as follows:</p>
  <pre><code>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)
  ic_chain_bound.atom_to_internal_coordinates()
  
  # Generate back 3D coordinates from angles.
  ic_chain_bound.internal_to_atom_coordinates()
  </code></pre>
  <p>but this fails with the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;test_biopython_internal_coords.py&quot;, line 97, in &lt;module&gt;
      main(args)
    File &quot;test_biopython_internal_coords.py&quot;, line 89, in main
      ic_chain_bound.internal_to_atom_coordinates()
    File &quot;/software/anaconda/installation/envs/alphafold/lib/python3.7/site-packages/Bio/PDB/internal_coords.py&quot;, line 661, in internal_to_atom_coordinates
      verbose=verbose, start=start, fin=fin
    File &quot;software/anaconda/installation/envs/alphafold/lib/python3.7/site-packages/Bio/PDB/internal_coords.py&quot;, line 415, in assemble_residues
      Dict[AtomKey, numpy.array], ric.assemble(verbose=verbose)
    File &quot;/software/anaconda/installation/envs/alphafold/lib/python3.7/site-packages/Bio/PDB/internal_coords.py&quot;, line 1732, in assemble
      atomCoords = self.get_startpos()
    File &quot;/software/anaconda/installation/envs/alphafold/lib/python3.7/site-packages/Bio/PDB/internal_coords.py&quot;, line 1632, in get_startpos
      sp = self.residue.parent.internal_coord.initNCaC.get(self.rbase, None)
  AttributeError: 'NoneType' object has no attribute 'initNCaC'
  </code></pre>
  <p>Is this not the intended use? Could someone help me figure out why this is failing?</p>
  <p>I'm using <a href="https://pastebin.com/m3P8f8rM" rel="nofollow noreferrer">this PDB file</a> in my example, but the code previously failed for all other PDB files I tried.</p>
  <p>Thanks!</p>
   10049: <p>not able to grasp the question, tried to figure out a way to show the internal_coordinates:</p>
  <pre><code>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)
  
  print(pippo)
  
  
  io = PDBIO()
  
  io.set_structure(pippo)
  
  io.save('atom_coord.pdb',  preserve_atom_numbering=True) 
  
  </code></pre>
  <p>compare <code>example.pdb</code> to <code>internal</code> and <code>atom_coord.pdb</code>;</p>
  <p>have a look at <code>internal</code>  file contents if you comment out</p>
  <p><code>structure.atom_to_internal_coordinates(verbose = True)</code> (around line 17 of</p>
  <p>code, # Generate protein internal coordinates (angles). block-code )</p>
   12036: <p>It turns out that in order to generate the internal coordinates for a protein structure, one shouldn't manually create an <code>IC_Chain</code> object, but rather just use the <code>atom_to_internal_coordinates()</code> method of the structure and the <code>internal_to_atom_coordinates()</code> one for the inverse functionality.</p>
  <pre><code>structure.atom_to_internal_coordinates()
  
  # 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
  
  structure.internal_to_atom_coordinates()
  </code></pre>
  