use of org.openscience.cdk.qsar.result.IntegerArrayResult in project ambit-mirror by ideaconsult.
the class AtomEnvironmentGeneratorTest method testAtomTypeMatrixDescriptor.
public void testAtomTypeMatrixDescriptor() throws Exception {
FileWriter w = new FileWriter(new File("F:/nina/Ideaconsult/Proposals/2014-columndb/ae.txt"));
AtomEnvironmentMatrixDescriptor gen = new AtomEnvironmentMatrixDescriptor();
InputStream in = AtomEnvironmentGeneratorTest.class.getClassLoader().getResourceAsStream("ambit2/descriptors/3d/test.sdf");
IIteratingChemObjectReader<IAtomContainer> reader = new IteratingSDFReader(new InputStreamReader(in), SilentChemObjectBuilder.getInstance());
while (reader.hasNext()) {
IAtomContainer mol = reader.next();
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
// atom list - bug?
try {
if (hAdder == null)
hAdder = CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance());
hAdder.addImplicitHydrogens(mol);
} catch (Exception x) {
}
CDKHueckelAromaticityDetector.detectAromaticity(mol);
DescriptorValue value = gen.calculate(mol);
System.out.println("Value");
for (int i = 0; i < value.getNames().length; i++) {
if (((IntegerArrayResult) value.getValue()).get(i) > 0) {
System.out.println(value.getNames()[i] + " = " + ((IntegerArrayResult) value.getValue()).get(i));
}
String[] split = value.getNames()[i].split("_");
w.append(String.format("%d\t%s\t%s\t%s\n", (i + 1), split[0].replace("L", ""), split[1], split.length < 3 ? "" : split[2]));
}
System.out.println("End Value");
w.flush();
}
w.close();
reader.close();
}
use of org.openscience.cdk.qsar.result.IntegerArrayResult 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.IntegerArrayResult 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.IntegerArrayResult 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.IntegerArrayResult 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