NullPointerException on pKaPlugin, logPPlugin and logDPlugin

User dfeb81947d

27-11-2009 14:03:39

Dear support,


I have a problem when I use pKaPlugin, logPPlugin and logDPlugin.


When I use JChem 5.1.4, there are no error, and calculation goes well. But If I'm using the latest version of JChem (JChem 5.2.6), I got NullPointerException.


Maybe there is something I do wrong. Molecules are in the zip file attached.


I don't know where I am wrong according to the documentation/javadoc about the change between 5.1.4 and 5.2.6.


Please, can you help me?


 


Thank you in advance.


Best Regards,


Jack


Here is my code:




private static final pKaPlugin pka = new pKaPlugin();
private static final logPPlugin logp = new logPPlugin();
private static final logDPlugin logd = new logDPlugin()

[...]

logp.setlogPMethod(logPPlugin.METHOD_WEIGHTED);
logp.setWeightOfMethods(1, 2, 1, 0);
logp.setCloridIonConcentration(0.2);
logp.setNaKIonConcentration(0.2);
logp.setUserTypes("logPTrue");
pka.setpH(7.4);
Properties prop = new Properties();
prop.setProperty("mode", "macro");
pka.setParameters(prop);
pka.setBasicpKaLowerLimit(-10);
pka.setAcidicpKaUpperLimit(20);

[...]

private static void calcLogDPlugin(Molecule mol, int id) {
try {
logd.setMolecule(mol);
logd.run();
System.out.println(id+" => logD = "+logd.calclogD(7.4));
} catch (Exception e) {
e.printStackTrace();
}
}

private static void calcLogP(Molecule m, int id) {
try {
logp.setMolecule(m);
logp.run();
System.out.println(id+" => LogP = "+logp.getlogPTrue());
} catch (Exception e) {
e.printStackTrace();
}
}

private static void calcPKa(Molecule mol, int id) {
try {
pka.setMolecule(mol);
pka.run();
double[] acidic_pka = pka.getMacropKaValues(pKaPlugin.ACIDIC);
if (acidic_pka != null && acidic_pka.length > 0) {
double res = returnPkaValue(acidic_pka);
if (!Double.isNaN(res)) {
System.out.println(id+" => pKa = "+res);
} else {
double[] basic_pka = pka.getMacropKaValues(pKaPlugin.BASIC);
if (basic_pka != null && basic_pka.length > 0) {
System.out.println(id+" => pka = "+basic_pka);
}
}
}

} catch (Exception e) {
e.printStackTrace();
}

}

/* return the pKa the nearest from 7.4 */
private static double returnPkaValue(double[] tabpka) {
double min = tabpka[0];
for (double d : tabpka) {
if (!Double.isNaN(d)) {
if(Math.abs((d-7.4))<Math.abs((min-7.4))) { min = d; }
}
}
return min;
}

Here are the Exceptions:


java.lang.NullPointerException
at chemaxon.calculations.Ionizer.setDegIndex(Ionizer.java:4676)
at chemaxon.calculations.Ionizer.assignAtom(Ionizer.java:1495)
at chemaxon.calculations.Ionizer.calcpKa(Ionizer.java:1332)
at chemaxon.calculations.Ionizer.calculatepKa(Ionizer.java:4094)
at chemaxon.calculations.Ionizer.calculatepKa(Ionizer.java:4065)
at chemaxon.marvin.calculations.pKaPlugin.run(pKaPlugin.java:661)
at TestDescriptors.calcPKa(TestDescriptors.java:161)
at TestDescriptors.main(TestDescriptors.java:85)


java.lang.NullPointerException
at chemaxon.calculations.Ionizer.setDegIndex(Ionizer.java:4676)
at chemaxon.calculations.Ionizer.assignAtom(Ionizer.java:1495)
at chemaxon.calculations.Ionizer.calcpKa(Ionizer.java:1332)
at chemaxon.calculations.logD.isNewpKaCalc(logD.java:529)
at chemaxon.calculations.logD.calcNewMicroSpecSet(logD.java:569)
at chemaxon.calculations.logD.calclogD(logD.java:318)
at chemaxon.marvin.calculations.logDPlugin.run(logDPlugin.java:466)
at TestDescriptors.calcLogDPlugin(TestDescriptors.java:195)
at TestDescriptors.main(TestDescriptors.java:86)


java.lang.NullPointerException
at chemaxon.calculations.Ionizer.setDegIndex(Ionizer.java:4676)
at chemaxon.calculations.Ionizer.assignAtom(Ionizer.java:1495)
at chemaxon.calculations.Ionizer.calcpKa(Ionizer.java:1332)
at chemaxon.calculations.Ionizer.calculatepKa(Ionizer.java:4094)
at chemaxon.calculations.logP.calclogPTrue(logP.java:4066)
at chemaxon.marvin.calculations.logPPlugin.run(logPPlugin.java:454)
at TestDescriptors.calcLogPForMolecule(TestDescriptors.java:110)
at TestDescriptors.main(TestDescriptors.java:87)

 

User 851ac690a0

30-11-2009 07:26:06

Hi,


 


I was able to reproduce the same exceptions with your code.


This is a bug in the 5.2.6 version.


 


The  fixed version will appear soon, in the 5.3 version.


 


Jozsi