Search in sources :

Example 1 with AtomEnvironmentMatrixDescriptor

use of ambit2.descriptors.AtomEnvironmentMatrixDescriptor in project ambit-mirror by ideaconsult.

the class AtomEnvironmentGeneratorTest method testAtomTypeMatrix.

@Test
public void testAtomTypeMatrix() throws Exception {
    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);
        HashIntDescriptorResult sparseMatrix = gen.doCalculation(mol);
        System.out.println("Sparse Matrix");
        System.out.println(sparseMatrix);
        System.out.println("End Sparse Matrix");
    }
    reader.close();
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) AtomEnvironmentMatrixDescriptor(ambit2.descriptors.AtomEnvironmentMatrixDescriptor) IteratingSDFReader(org.openscience.cdk.io.iterator.IteratingSDFReader) RawIteratingSDFReader(ambit2.core.io.RawIteratingSDFReader) HashIntDescriptorResult(ambit2.core.data.HashIntDescriptorResult) Test(org.junit.Test)

Example 2 with AtomEnvironmentMatrixDescriptor

use of ambit2.descriptors.AtomEnvironmentMatrixDescriptor 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();
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) FileWriter(java.io.FileWriter) AtomEnvironmentMatrixDescriptor(ambit2.descriptors.AtomEnvironmentMatrixDescriptor) IntegerArrayResult(org.openscience.cdk.qsar.result.IntegerArrayResult) IteratingSDFReader(org.openscience.cdk.io.iterator.IteratingSDFReader) RawIteratingSDFReader(ambit2.core.io.RawIteratingSDFReader) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue) File(java.io.File)

Aggregations

RawIteratingSDFReader (ambit2.core.io.RawIteratingSDFReader)2 AtomEnvironmentMatrixDescriptor (ambit2.descriptors.AtomEnvironmentMatrixDescriptor)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)2 IteratingSDFReader (org.openscience.cdk.io.iterator.IteratingSDFReader)2 HashIntDescriptorResult (ambit2.core.data.HashIntDescriptorResult)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 Test (org.junit.Test)1 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)1 IntegerArrayResult (org.openscience.cdk.qsar.result.IntegerArrayResult)1