Hi Noel,

thank you for your message.

I finally got around to prepare a self contained example which you can run 
directly on colab

https://colab.research.google.com/drive/1MJ8UBs7YgmIkfduQrf9axXQZy3o3gcMd?usp=sharing


If you uncomment the mol.endModify() line at the end all the residues in the 
mol OBMol become unlinked.  If the line is commented the PDB file is written 
out correctly and can be reread by OpenBabel.


We figured out a workaround in the meantime, where we save the file to disk and 
reload it because afterwards we are making some modifications (like changing 
torsion angles).

If we do not call endModify and eg try to set a new torsion directly on "mol" 
we get a segmentation fault.


Best and thanks for your help,

Simon


Simon Dürr
Doctoral Assistant
Laboratory of Computational Biochemistry and Chemistry
EPFL SB ISIC LCBC
BCH 4105  (Bât. BCH)
CH-1015 Lausanne
phone: +41 78 607 2524
i...@simonduerr.eu<mailto:i...@simonduerr.eu>
https://simonduerr.eu<https://simonduerr.eu/>

________________________________
From: Noel O'Boyle <baoille...@gmail.com>
Sent: Saturday, October 17, 2020 4:13:31 PM
To: Dürr Simon Leonard
Cc: openbabel-discuss@lists.sourceforge.net
Subject: Re: [Open Babel] mol.EndModify() and upgrade to ob3.0

Hi Simon,

I'm finding it a bit confusing to work out what's going on here. If you could 
either provide the simplest possible self-contained example, or else describe 
what you want to do. At the back of my mind is the fact that molA += molB is 
how you add one molecule to another in Open Babel - it is not expected that 
users copy over each atom one-by-one.

Regards,
Noel

On Thu, 15 Oct 2020 at 13:41, Dürr Simon Leonard 
<simon.du...@epfl.ch<mailto:simon.du...@epfl.ch>> wrote:

Hi,


I am currently upgrading our code from openbabel 2.4.2 to openbabel 3.0 (using 
the python bindings).


I am having trouble with the EndModify command.


What the code is doing:

  1.  Load a pdb file and a mol2 file of an amino acid (aa_mol)  into seperate 
obMols
  2.  Set both ObMol to BeginModify()
  3.  Calculate a rotation vector and remove overlapping atoms via DeleteAtom() 
from aa_mol and pdb obmol
  4.  Then create a new obatom in the pdb file and copy all information and 
remake the bonds
new_atom.SetId(id)
new_atom.SetVector(frag_atom.GetVector())
new_atom.SetAtomicNum(frag_atom.GetAtomicNum())
new_atom.SetType(frag_atom.GetType())
new_atom.SetSpinMultiplicity(frag_atom.GetSpinMultiplicity())
new_atom.SetFormalCharge(frag_atom.GetFormalCharge())
#new_atom.SetImplicitValence(frag_atom.GetImplicitValence()) #old 2.4.2 
replaced with line below
new_atom.SetImplicitHCount(frag_atom.GetImplicitHCount())
new_atom.SetPartialCharge(frag_atom.GetPartialCharge())
for obbond in openbabel.OBMolBondIter(fragment):
begin_atom = obbond.GetBeginAtom()
end_atom = obbond.GetEndAtom()
mol.AddBond(obbond.GetBeginAtomIdx() + prevAtoms, obbond.GetEndAtomIdx() + 
prevAtoms, obbond.GetBondOrder(), obbond.GetFlags())

5. Renumber the atoms so that the newly inserted atoms are at the desired 
location

6. Make a bond between the fragment and the CA atom in the pdb file

7. Set name of residue.

8. Set Dihedral angle.


Now this code was working perfectly fine in ob2.4.2, but now in 3.0 it does not 
anymore.

I get a Segmentation fault when setting the Dihedral angle.


If I move the mol.EndModify() before the SetTorsion command the segmentation 
fault disappears but all the atoms become unlinked (Residue UNL).

If I write out a PDB file just before the EndModify command everything looks 
alright (correct CONECT statements, positions, order etc.).


Any ideas where the problem is?


Thank you for your help,

Simon


Simon Dürr
i...@simonduerr.eu<mailto:i...@simonduerr.eu>
https://simonduerr.eu<https://simonduerr.eu/>

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

Reply via email to