Menu

#903 SetName appends residue number to residue name in MOL2

2.3.x
open
nobody
None
4
2013-11-22
2013-11-22
Hannes
No

The following Python code renames the first residue in a PDB
file. The renaming works except that OpenBabel appends a '1',
obviously the residue number, to the new name in the mol2 output. Openbabel should not arbitrarily change a user's naming choices.

import pybel

mol = pybel.readfile('pdb', 'test.pdb').next()

obmol = mol.OBMol
res1 = obmol.GetResidue(0)
res1.SetName('FOOBAR') # appends '1' to 'FOOBAR'

mol.write('mol2', 'test.mol2', overwrite = True)

Discussion