[BioPython] deleting and inserting 'chains' in Bio.PDB

Christian Meesters meesters at uni-mainz.de
Mon Aug 20 11:15:39 EDT 2007


Hi,

I'd like delete and insert subunits in my structure object. But the
following code does not work:

>>> parser = PDBParser()
>>> s = parser.get_structure('name','name.pdb')
>>> cs = [chain for chain in s.get_chains()]
>>> cs
[<Chain id=A>, <Chain id=B>, <Chain id=C>, <Chain id=D>, <Chain id=E>,
<Chain id=F>]
>>> c = cs[0]
>>> c
<Chain id=A>
>>> c.id
'A'
>>> c.get_id()
'A'
>>> s.detach_child('A')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/python-support/python2.5/Bio/PDB/Entity.py", line 70,
in detach_child
    child=self.child_dict[id] 
KeyError: 'A'
>>> s.detach_child("<Chain id=A>")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/python-support/python2.5/Bio/PDB/Entity.py", line 70,
in detach_child
    child=self.child_dict[id] 
KeyError: '<Chain id=A>'

Can somebody give me a hint of what I'm missing?

Thanks,
Christian


More information about the BioPython mailing list