User a9d76a1173
06-06-2014 21:02:45
Following code runs OK as a unit test. However, the method doesn't work when ran through a javafx task thread. It seem to block the task thread. With a finally block, it always return 100.0.
public static Double calcLogP(String smiles) {
Double clogP = 100.0;
try {
logPPlugin plugin = new logPPlugin();
// set logP calculation method
plugin.setlogPMethod(logPPlugin.METHOD_WEIGHTED);
// set method weights
plugin.setWeightOfMethods(1, 2, 1, 0);
// set parameters
plugin.setCloridIonConcentration(0.2);
plugin.setNaKIonConcentration(0.2);
// set result types
plugin.setUserTypes("logPTrue");
Molecule m = MolImporter.importMol(smiles);
m.dearomatize();
Hydrogenize.addHAtoms(m);
// set the input molecule
plugin.setMolecule(m);
// run the calculation
plugin.run();
// get the overal logP value
clogP = plugin.getlogPTrue();
if (clogP.isInfinite() || clogP.isNaN())
{
clogP = 100.0;
}
} catch (Exception e) {
LOGGER.error("An error occured while calculating LogP",e);
}
return clogP;
}