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)