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> 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 > https://simonduerr.eu > _______________________________________________ > OpenBabel-discuss mailing list > 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