Search in sources :

Example 1 with DoubleArrayResult

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);
    }
}
Also used : DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) CDKException(org.openscience.cdk.exception.CDKException) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue)

Example 2 with DoubleArrayResult

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());
}
Also used : DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue)

Example 3 with DoubleArrayResult

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;
}
Also used : IDescriptorResult(org.openscience.cdk.qsar.result.IDescriptorResult) BooleanResult(org.openscience.cdk.qsar.result.BooleanResult) IntegerArrayResult(org.openscience.cdk.qsar.result.IntegerArrayResult) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) ArrayResult(ambit2.core.data.ArrayResult) IntegerArrayResult(org.openscience.cdk.qsar.result.IntegerArrayResult) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) DoubleResult(org.openscience.cdk.qsar.result.DoubleResult) AbstractDescriptorResultType(ambit2.core.data.AbstractDescriptorResultType) VerboseDescriptorResult(ambit2.descriptors.VerboseDescriptorResult) IntegerResult(org.openscience.cdk.qsar.result.IntegerResult)

Example 4 with DoubleArrayResult

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());
}
Also used : CDKException(org.openscience.cdk.exception.CDKException) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) DoubleResult(org.openscience.cdk.qsar.result.DoubleResult) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue)

Example 5 with DoubleArrayResult

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
}
Also used : DescriptorMopacShell(ambit2.mopac.DescriptorMopacShell) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) DoubleArrayResult(org.openscience.cdk.qsar.result.DoubleArrayResult) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) Test(org.junit.Test)

Aggregations

DoubleArrayResult (org.openscience.cdk.qsar.result.DoubleArrayResult)116 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)84 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)67 Test (org.junit.Test)61 IAtom (org.openscience.cdk.interfaces.IAtom)37 CDKException (org.openscience.cdk.exception.CDKException)29 IBond (org.openscience.cdk.interfaces.IBond)24 AtomContainer (org.openscience.cdk.AtomContainer)23 List (java.util.List)19 SmilesParser (org.openscience.cdk.smiles.SmilesParser)19 InputStream (java.io.InputStream)17 Point2d (javax.vecmath.Point2d)16 ChemFile (org.openscience.cdk.ChemFile)15 ISimpleChemObjectReader (org.openscience.cdk.io.ISimpleChemObjectReader)15 IDescriptorResult (org.openscience.cdk.qsar.result.IDescriptorResult)12 MDLV2000Reader (org.openscience.cdk.io.MDLV2000Reader)11 DoubleResult (org.openscience.cdk.qsar.result.DoubleResult)11 ArrayList (java.util.ArrayList)10 ChemObject (org.openscience.cdk.ChemObject)9 GasteigerMarsiliPartialCharges (org.openscience.cdk.charges.GasteigerMarsiliPartialCharges)8