Dear all,

I want to create a new OBMol object for the ligand within a protein-ligand
complex.
The atoms can be copied successfully, but I have some trouble with the
bonds.

Since the residue name (ATP for example), residue number and chain id of
the ligand are known, I iterate all the atoms of the complex and insert the
selected ones into a new OBMol.

Codes:
- - -
void CopySelected(OBMol& new_mol, OBMol select_from, char selected_chain,
string selected_resn, unsigned int selected_res_num)
 {
   OBAtom *atom;
   OBResidue *res;

   FOR_ATOMS_OF_MOL(atom, select_from) {
     res = atom->GetResidue(true);

     string resn = res->GetName();
     int res_num = res->GetNum();
     char chain = res->GetChain();

     if ((resn == selected_resn)
         && (res_num == selected_res_num)
         && (chain == selected_chain)) {

       bool is_success = new_mol.InsertAtom((*atom));

       for (auto bond_itr = atom->BeginBonds();
            bond_itr != atom->EndBonds();
            bond_itr++) {
         new_mol.AddBond(*(*bond_itr));
       }
     }
   }
 }
- - -

However, when the new molecule is written into sdf or mol2 format, some of
the bonds are missing; the atom types are incorrect in mol2 file.

Is there any established method to create a new molecule from part of the
existing one while maintaining *all *the information? How can I improve my
function here?

  Thanks!


Eric
------------------------------------------------------------------------------
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to