use of org.openscience.cdk.qsar.result.DoubleArrayResult in project ambit-mirror by ideaconsult.
the class SizeDescriptor method calculate.
/*
* (non-Javadoc)
*
* @see
* org.openscience.cdk.qsar.IDescriptor#calculate(org.openscience.cdk.interfaces
* .AtomContainer)
*/
public DescriptorValue calculate(IAtomContainer container) {
try {
double[] eval = doCalculation(container);
// double min = eval[0];
DoubleArrayResult value = new DoubleArrayResult(eval.length);
for (int i = 0; i < eval.length; i++) value.add(eval[i]);
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), value, getDescriptorNames());
} catch (Exception x) {
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), null, getDescriptorNames(), x);
}
}
use of org.openscience.cdk.qsar.result.DoubleArrayResult in project ambit-mirror by ideaconsult.
the class AtomCountRelativeDescriptor method calculateCounts.
@Override
public DescriptorValue calculateCounts(IAtomContainer container) throws CDKException {
int nAllAtoms = countAtoms(container, "*");
DoubleArrayResult result = new DoubleArrayResult();
if (elementName.equals("")) {
for (int i = 0; i < elements.length; i++) {
int nAt = countAtoms(container, elements[i]);
result.add((percentFactor * nAt) / nAllAtoms);
}
} else {
int nAt = countAtoms(container, elementName);
result.add((percentFactor * nAt) / nAllAtoms);
}
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), result, getDescriptorNames());
}
use of org.openscience.cdk.qsar.result.DoubleArrayResult 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.DoubleArrayResult in project ambit-mirror by ideaconsult.
the class EccentricBasedMadanIndicesDescriptor method calculate.
public DescriptorValue calculate(IAtomContainer container) {
if (container == null) {
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(Double.NaN), getDescriptorNames(), new CDKException("The supplied AtomContainer was NULL"));
}
if (container.getAtomCount() == 0) {
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(Double.NaN), getDescriptorNames(), new CDKException("The supplied AtomContainer did not have any atoms"));
}
int[] degree = TopologicalUtilities.getAtomTopDegrees(container);
int[][] D = GraphMatrices.getTopDistanceMatrix(container);
int[] Veec = GraphMatrices.getVertexEccentricity(D);
int[] ddv = TopologicalUtilities.DistanceDegreeVector(container);
int[][] AM = GraphMatrices.getAdjacencyMatrix(container);
// this is the name by Dragon for Eccentric
double CSI = 0.0;
// connectivity index
// Eccentric distance sum index
double EDC = 0.0;
// Adjacency eccentric distance sum index
double AEDS = 0.0;
// Connectivity eccentricity index
double CEI = 0.0;
double madanIndex = 1.0;
for (int i = 0; i < container.getAtomCount(); i++) {
double a = degree[i] * Veec[i];
double b = Veec[i] * ddv[i];
double c = 1.0 * (Veec[i] * ddv[i]) / degree[i];
double d = 1.0 * degree[i] / Veec[i];
CSI += a;
EDC += b;
AEDS += c;
CEI += d;
for (int j = 0; j < container.getAtomCount(); j++) {
madanIndex *= Math.pow(degree[i], AM[i][j]);
}
}
DoubleArrayResult result = new DoubleArrayResult();
result.add(CSI);
result.add(EDC);
result.add(AEDS);
result.add(CEI);
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), result, getDescriptorNames());
}
use of org.openscience.cdk.qsar.result.DoubleArrayResult in project ambit-mirror by ideaconsult.
the class DescriptorMopacShellTest method testCalculate2.
@Test
public void testCalculate2() throws Exception {
DescriptorMopacShell d = new DescriptorMopacShell();
String smiles = "[O-][N+](=O)C1=CC(Cl)=C(Cl)C=C1Cl";
// "[H]C1=C([H])C([H])=C([H])C([H])=C1([H])";
// todo add hydrogens
IAtomContainer ac = parser.parseSmiles(smiles);
DescriptorValue v = (DescriptorValue) d.calculate(ac);
if (v.getException() != null)
throw v.getException();
Assert.assertEquals(Mopac7Reader.parameters.length, v.getNames().length);
Assert.assertEquals(DescriptorMopacShell.EHOMO, v.getNames()[7]);
Assert.assertEquals(DescriptorMopacShell.ELUMO, v.getNames()[8]);
DoubleArrayResult r = (DoubleArrayResult) v.getValue();
// System.out.println(r.get(7));
// System.out.println(r.get(8));
// ehomo
Assert.assertEquals(-9.70887, r.get(7), 1E-2);
// elumo
Assert.assertEquals(-3.54057, r.get(8), 1E-2);
// Assert.assertEquals(78.113,r.get(6),1E-2); //Molecular weight
// Assert.assertEquals(97.85217,r.get(2),1E-2); //FINAL HEAT OF FORMATION
}
Aggregations