use of org.openscience.cdk.qsar.result.IDescriptorResult in project MetFragRelaunched by ipb-halle.
the class LinearRetentionTimeModel method calculateXLogpValues.
/**
* @param inchis
* @return
*/
public Double[] calculateXLogpValues(java.util.ArrayList<String> inchis) {
Double[] values = new Double[inchis.size()];
if (this.xlogp == null)
return values;
try {
for (int i = 0; i < inchis.size(); i++) {
DescriptorValue value = null;
boolean calculated = false;
int trials = 0;
while (!calculated) {
try {
trials++;
value = this.xlogp.calculate(MoleculeFunctions.getAtomContainerFromInChI(inchis.get(i)));
} catch (Exception e) {
if (trials == 10) {
break;
}
continue;
}
calculated = true;
}
if (value != null) {
IDescriptorResult result = value.getValue();
values[i] = Double.parseDouble(result.toString());
} else
values[i] = null;
}
} catch (Exception e) {
e.printStackTrace();
}
return values;
}
use of org.openscience.cdk.qsar.result.IDescriptorResult in project ambit-mirror by ideaconsult.
the class FunctionalGroupDescriptorTest method calculate.
protected void calculate(List<FunctionalGroup> groups, boolean verbose, IAtomContainer m, int hits) throws Exception {
d.setParameters(new Object[] { groups, verbose });
m = hadder.process(m);
DescriptorValue value = d.calculate(m);
IDescriptorResult v = value.getValue();
Assert.assertEquals(hits, value.getNames().length);
Assert.assertTrue(v instanceof VerboseDescriptorResult);
VerboseDescriptorResult verboseResult = (VerboseDescriptorResult) v;
IDescriptorResult r = verboseResult.getResult();
Assert.assertTrue(r instanceof IntegerArrayResult);
Assert.assertEquals(hits, ((IntegerArrayResult) r).length());
if (verbose) {
Assert.assertTrue(verboseResult.getExplanation() instanceof List);
Assert.assertTrue(((List) verboseResult.getExplanation()).get(0) instanceof IAtomContainer);
}
}
use of org.openscience.cdk.qsar.result.IDescriptorResult in project ambit-mirror by ideaconsult.
the class DescriptorValue2Property method getValue.
public Object getValue(DescriptorValue descriptor, Property property, int propertyIndex) {
if (descriptor.getException() != null) {
Throwable x = descriptor.getException();
while (x.getCause() != null) x = x.getCause();
return x;
}
IDescriptorResult result = descriptor.getValue();
Object value = Double.NaN;
if (result instanceof VerboseDescriptorResult)
result = ((VerboseDescriptorResult) result).getResult();
if (result instanceof DoubleResult)
value = ((DoubleResult) result).doubleValue();
else if (result instanceof IntegerResult)
value = ((IntegerResult) result).intValue();
else if (result instanceof BooleanResult) {
value = (((BooleanResult) result).booleanValue()) ? answer.YES.toString() : answer.NO.toString();
} else if (result instanceof ArrayResult)
value = ((ArrayResult) result).get(propertyIndex);
else if (result instanceof IntegerArrayResult)
value = ((IntegerArrayResult) result).get(propertyIndex);
else if (result instanceof DoubleArrayResult)
value = ((DoubleArrayResult) result).get(propertyIndex);
else if (result instanceof AbstractDescriptorResultType)
return ((AbstractDescriptorResultType) result).getValue();
return value;
}
use of org.openscience.cdk.qsar.result.IDescriptorResult in project cdk by cdk.
the class AminoAcidCountDescriptorTest method testAACount.
@Test
public void testAACount() throws Exception {
IBioPolymer protein = ProteinBuilderTool.createProtein("ARNDCFQEGHIPLKMSTYVW", SilentChemObjectBuilder.getInstance());
IDescriptorResult result = descriptor.calculate(protein).getValue();
Assert.assertTrue(result instanceof IntegerArrayResult);
IntegerArrayResult iaResult = (IntegerArrayResult) result;
for (int i = 0; i < iaResult.length(); i++) {
// all AAs are found at least once
Assert.assertTrue(iaResult.get(i) >= 1);
}
// glycine is in all of them, so 20 times
Assert.assertEquals(20, iaResult.get(8));
}
use of org.openscience.cdk.qsar.result.IDescriptorResult in project cdk by cdk.
the class AminoAcidCountDescriptorTest method testTCount.
@Test
public void testTCount() throws Exception {
IBioPolymer protein = ProteinBuilderTool.createProtein("TT", SilentChemObjectBuilder.getInstance());
IDescriptorResult result = descriptor.calculate(protein).getValue();
Assert.assertTrue(result instanceof IntegerArrayResult);
IntegerArrayResult iaResult = (IntegerArrayResult) result;
Assert.assertEquals(2, iaResult.get(8));
Assert.assertEquals(2, iaResult.get(16));
}
Aggregations