
On Mar 14, 2011, at 1:44 PM, Jean Didier Pie Marechal wrote:
Dear all,
thanks a lot for your answers. I seem to have a problem though. When running the script, one way or another I always ends up with something like: a.residue.removeAtom(a) AttributeError: 'NoneType' object has no attribute 'removeAtom' AttributeError: 'NoneType' object has no attribute 'removeAtom'
File "M:\REUNIONS\dibuixos\Manipulate_structure\newres.py", line 20, in <module> a.residue.removeAtom(a)
So, it seems like the script I sent was mildly buggy. In particular, "a.residue" gets used even after the atom has been removed from the residue. So, you need to change this:
# withdraw atoms from their current residues for a in atoms: a.residue.removeAtom(a) if len(a.residue.atoms) == 0: a.molecule.deleteResidue(a.residue)
to: # withdraw atoms from their current residues for a in atoms: res = a.residue res.removeAtom(a) if len(res.atoms) == 0: a.molecule.deleteResidue(res) Sorry about that! --Eric