Dear Qianzhen,

To to map the atom id to the labels you should iterate over the PDB's
residues, like:

    idToAtomicLabel = {}
    for res in openbabel.OBResidueIter(mol):
      for atom in openbabel.OBResidueAtomIter(res):
        idToAtomicLabel[atom.GetId()] = res.GetAtomID(atom).strip()

Best,
Henrique

On Thu, Feb 25, 2021 at 7:31 AM 邵乾真 <shaoqz0...@gmail.com> wrote:

> Dear Open Babel support team,
>
> I tried to protonate a ligand from a PDB file and save a protonated PDB
> that keeps the atom label (e.g.: C2A) and residue name.
> The PDB openbabel exported just leaves element type (e.g.: C) but not the
> original atom label (e.g.: C2A). And the residue name was changed to 'UNL'
> but not the original '4CO'.
> Detail:
>
> I tried using both the command line:
> obabel XXX.pdb -o pdb -O XXX2.pdb --p 7.0
> and also python API:
>
> mol = next(pybel.readfile('pdb', path))
> mol.OBMol.AddHydrogens(False, True, ph)
> mol.write('pdb', out_path, overwrite=True)
>
> This is an original pdb line:
> ATOM 2 C2A 4CO 371 66.999 58.130 14.636 1.00 0.00
> This is one after openbabel:
> HETATM 2 C UNL 1 66.999 58.130 14.636 1.00 0.00 C
>
>
> Is there any way I can keep the atom label at least?
>
>
> All the Best,
>
> Qianzhen
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>


-- 
Henrique Musseli Cezar
Instituto de Física
Universidade de São Paulo
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to