Hi Noel,
here you go:
public void testCase3() {
IteratingMolFileReader imfr = new IteratingMolFileReader("input_conformes.sdf");
OBForceField ff;
while(imfr.hasNext()) {
ff = OBForceField.Default();
mol =MoleculeConvertingFactory.convertCDKMoltoBabelMol(imfr.readNextMol());
ff.SetParameterFile("MMFF94");
ff.Setup(mol);
ff.ConjugateGradients(1000);
}
}
Same Problem,BUT if i do skip 4 molecules each time ( there are 5
conformations each) like this:
public void testCase4() {
IteratingMolFileReader imfr = new
IteratingMolFileReader("MOMO_working_corina_3d_deionisiert.sdf_socger_out.sdf");
OBForceField ff = OBForceField.Default();
while(imfr.hasNext()) {
imfr.readNextMol(); //skipping mols
imfr.readNextMol();
imfr.readNextMol();
imfr.readNextMol();
mol =MoleculeConvertingFactory.convertCDKMoltoBabelMol(imfr.readNextMol());
ff.SetParameterFile("MMFF94");
ff.Setup(mol);
ff.ConjugateGradients(1000);
}
}
It works perfectly well. I have really small molecules by now for the test
cases and still the same error as long as i have conformations in the file ..
The parsing should be fine, I exported like 1300 molecules and they all had
rmsd 0.0, which means they were exactly the same also had same bond numbers,
and atoms, but i attached the classes if you want to take a look.
Also, the error always says 0x0 rip=0x114791639, no matter what file or
molecules conformation cause it.
Greetings,
Alex
Here is my converting class:
public static OBMol convertCDKMoltoBabelMol(Molecule mol) {
//generate new OBMol
OBMol obMol = new OBMol();
//adding all atoms
for (int i = 0; i < mol.getAtomCount(); i++) {
obMol.AddAtom(parseCDKAtom((Atom) mol.getAtom(i)));
}
//adding all bonds
for (int i = 0; i < mol.getBondCount(); i++) {
obMol.AddBond(parseCDKBond((Bond) mol.getBond(i), i, obMol, mol));
}
//calculating all properties
return autoCompleteMol(obMol);
}
public static OBAtom parseCDKAtom(Atom atom) {
OBAtom obAtom = new OBAtom();
obAtom.SetVector(atom.getPoint3d().x, atom.getPoint3d().y,
atom.getPoint3d().z);
obAtom.SetAtomicNum(atom.getAtomicNumber());
obAtom.SetPartialCharge(atom.getCharge());
obAtom.SetFormalCharge(atom.getFormalCharge());
obAtom.SetHyb(atom.getHybridization());
return obAtom;
}
public static OBBond parseCDKBond(Bond bond, int index, OBMol obmol, Molecule
mol) {
OBBond obBond = new OBBond();
obBond.Set(index + 1, obmol.GetAtom(mol.getAtomNumber(bond.getAtom(0)) +
1), obmol.GetAtom(mol.getAtomNumber(bond.getAtom(1)) + 1), (int)
bond.getOrder(), 0);
return obBond;
}
Am 15.04.2010 um 17:57 schrieb Noel O'Boyle:
> Hi Alex,
>
> Can you reduce the code down to as few lines as possible that exhibit
> the problem? In particular, since the code behind Forcefield is not
> given, it is difficult to figure out where the problem is.
>
> - Noel
>
> On 15 April 2010 15:30, Alexander Klenner
> <[email protected]> wrote:
>> Hi all,
>>
>> I have a very strange problem using the java OpenBabel library. I have an
>> SDF File with severals molecules where every molecule has x conformers. I am
>> using a class to parse these molecules from iMolecule class from CDK
>> (Chemistry Development Kit) to openBabel. I need to do this since all our
>> programs are working with CDK and the goal is to pass the CDK mols directly
>> to openBabel without i/o operations.
>>
>> I am using the OpenBabel forcefield (OBForceField) to minimize the
>> conformers. And here is the strangest thing happening: If I read a second
>> conformer from the sdf of a molecule and parse it to OpenBabel and the
>> corresponding forcefield I get this error:
>>
>> Invalid memory access of location 0x0 rip=0x1149a2639
>>
>> I only get this error if I parse two different conformations of the same
>> molecule in a raw to the forcefield(i.e. they only differ in coordinates). I
>> can minimize hundreds of structures without problems. Also I can alter
>> between conformations like mol1,mol2,mol1, ... that also works fine, but
>> whenever I have two conformations of one molecule in my sdf file in a raw(
>> like mol1_conf1, mol1_conf2,...), the program will terminate and give the
>> error message mentioned above. I have absolutely no idea why conformations
>> of the same molecule can cause an error like this...
>>
>> I am always dealing with new instances and the CDK-Reader knows nothing
>> about the molecule it read before. Theres just no way I can imagine why this
>> can happen.
>>
>> Here is the code of the method I use:
>>
>> -----------
>>
>> public void testCase() throws IOException, Exception {
>>
>>
>> System.load("/Users/aklenner/Modlab/Java-Projekte/OpenBable/openbabel-2.2.3/scripts/java/libopenbabel.jnilib");
>>
>> IteratingMolFileReader imfr = new
>> IteratingMolFileReader("input_confomers.sdf");
>> ForceField ff=null;
>> OBMol mol=null;
>>
>> while(imfr.hasNext()) {
>>
>> mol
>> =MoleculeConvertingFactory.convertCDKMoltoBabelMol(imfr.readNextMol());
>> ff = new ForceField("MMFF94",mol);
>> ff.ConjugateGradient(1000, true);
>>
>> }
>>
>> }
>> -----------
>> MoleculeConvertingFactory.convertCDKMoltoBabelMol() returns an OBMol;
>> ForceField is just a container for the OBForceField
>> and ConjugateGradient just calls the same method for OBForceField. I also
>> tried to use the 'native' classes without the container- same problem.
>>
>> Again, if 'input_confomers.sdf' only has one conformation each or the
>> conformations are altered the minimization works perfect.
>>
>> Any idea or help is appreciated,
>>
>> Thanks,
>>
>> Alex
>>
>>
>> --
>> ETH Zurich
>> Dipl.-Bioinf. Alexander G. Klenner
>> Institute of Pharmaceutical Sciences
>> HCI G 496
>> Wolfgang-Pauli-Str. 10
>> 8093 Zürich
>> SWITZERLAND
>>
>> +41 44 633 74 23 phone
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> OpenBabel-scripting mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/openbabel-scripting
>>
--
ETH Zurich
Dipl.-Bioinf. Alexander G. Klenner
Institute of Pharmaceutical Sciences
HCI G 496
Wolfgang-Pauli-Str. 10
8093 Zürich
SWITZERLAND
+41 44 633 74 23 phone
Am 15.04.2010 um 17:57 schrieb Noel O'Boyle:
> Hi Alex,
>
> Can you reduce the code down to as few lines as possible that exhibit
> the problem? In particular, since the code behind Forcefield is not
> given, it is difficult to figure out where the problem is.
>
> - Noel
>
> On 15 April 2010 15:30, Alexander Klenner
> <[email protected]> wrote:
>> Hi all,
>>
>> I have a very strange problem using the java OpenBabel library. I have an
>> SDF File with severals molecules where every molecule has x conformers. I am
>> using a class to parse these molecules from iMolecule class from CDK
>> (Chemistry Development Kit) to openBabel. I need to do this since all our
>> programs are working with CDK and the goal is to pass the CDK mols directly
>> to openBabel without i/o operations.
>>
>> I am using the OpenBabel forcefield (OBForceField) to minimize the
>> conformers. And here is the strangest thing happening: If I read a second
>> conformer from the sdf of a molecule and parse it to OpenBabel and the
>> corresponding forcefield I get this error:
>>
>> Invalid memory access of location 0x0 rip=0x1149a2639
>>
>> I only get this error if I parse two different conformations of the same
>> molecule in a raw to the forcefield(i.e. they only differ in coordinates). I
>> can minimize hundreds of structures without problems. Also I can alter
>> between conformations like mol1,mol2,mol1, ... that also works fine, but
>> whenever I have two conformations of one molecule in my sdf file in a raw(
>> like mol1_conf1, mol1_conf2,...), the program will terminate and give the
>> error message mentioned above. I have absolutely no idea why conformations
>> of the same molecule can cause an error like this...
>>
>> I am always dealing with new instances and the CDK-Reader knows nothing
>> about the molecule it read before. Theres just no way I can imagine why this
>> can happen.
>>
>> Here is the code of the method I use:
>>
>> -----------
>>
>> public void testCase() throws IOException, Exception {
>>
>>
>> System.load("/Users/aklenner/Modlab/Java-Projekte/OpenBable/openbabel-2.2.3/scripts/java/libopenbabel.jnilib");
>>
>> IteratingMolFileReader imfr = new
>> IteratingMolFileReader("input_confomers.sdf");
>> ForceField ff=null;
>> OBMol mol=null;
>>
>> while(imfr.hasNext()) {
>>
>> mol
>> =MoleculeConvertingFactory.convertCDKMoltoBabelMol(imfr.readNextMol());
>> ff = new ForceField("MMFF94",mol);
>> ff.ConjugateGradient(1000, true);
>>
>> }
>>
>> }
>> -----------
>> MoleculeConvertingFactory.convertCDKMoltoBabelMol() returns an OBMol;
>> ForceField is just a container for the OBForceField
>> and ConjugateGradient just calls the same method for OBForceField. I also
>> tried to use the 'native' classes without the container- same problem.
>>
>> Again, if 'input_confomers.sdf' only has one conformation each or the
>> conformations are altered the minimization works perfect.
>>
>> Any idea or help is appreciated,
>>
>> Thanks,
>>
>> Alex
>>
>>
>> --
>> ETH Zurich
>> Dipl.-Bioinf. Alexander G. Klenner
>> Institute of Pharmaceutical Sciences
>> HCI G 496
>> Wolfgang-Pauli-Str. 10
>> 8093 Zürich
>> SWITZERLAND
>>
>> +41 44 633 74 23 phone
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> OpenBabel-scripting mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/openbabel-scripting
>>
--
ETH Zurich
Dipl.-Bioinf. Alexander G. Klenner
Institute of Pharmaceutical Sciences
HCI G 496
Wolfgang-Pauli-Str. 10
8093 Zürich
SWITZERLAND
+41 44 633 74 23 phone
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
OpenBabel-scripting mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-scripting