Search in sources :

Example 1 with IteratingSMILESReader

use of org.openscience.cdk.io.iterator.IteratingSMILESReader in project cdk by cdk.

the class RecursiveTest method testBasicAmineOnDrugs_cdkAromaticModel.

@Category(SlowTest.class)
@Test
public void testBasicAmineOnDrugs_cdkAromaticModel() throws Exception {
    String filename = "drugs.smi";
    InputStream ins = this.getClass().getResourceAsStream(filename);
    IteratingSMILESReader reader = new IteratingSMILESReader(ins, DefaultChemObjectBuilder.getInstance());
    SMARTSQueryTool sqt = new SMARTSQueryTool("[NX3;H2,H1;!$(NC=O)]", DefaultChemObjectBuilder.getInstance());
    sqt.setAromaticity(new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet()));
    int nmatch = 0;
    int nmol = 0;
    READ: while (reader.hasNext()) {
        IAtomContainer container = reader.next();
        AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(container);
        // model
        for (IAtom atom : container.atoms()) {
            if (atom.getAtomTypeName() == null) {
                continue READ;
            }
        }
        if (sqt.matches(container)) {
            nmatch++;
        }
        nmol++;
    }
    reader.close();
    Assert.assertEquals(141, nmol);
    Assert.assertEquals(4, nmatch);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Aromaticity(org.openscience.cdk.aromaticity.Aromaticity) IteratingSMILESReader(org.openscience.cdk.io.iterator.IteratingSMILESReader) InputStream(java.io.InputStream) SMARTSQueryTool(org.openscience.cdk.smiles.smarts.SMARTSQueryTool) IAtom(org.openscience.cdk.interfaces.IAtom) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) SlowTest(org.openscience.cdk.test.SlowTest)

Aggregations

InputStream (java.io.InputStream)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1 Aromaticity (org.openscience.cdk.aromaticity.Aromaticity)1 IAtom (org.openscience.cdk.interfaces.IAtom)1 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)1 IteratingSMILESReader (org.openscience.cdk.io.iterator.IteratingSMILESReader)1 SMARTSQueryTool (org.openscience.cdk.smiles.smarts.SMARTSQueryTool)1 SlowTest (org.openscience.cdk.test.SlowTest)1