Search in sources :

Example 16 with AtomTypeFactory

use of org.openscience.cdk.config.AtomTypeFactory in project cdk by cdk.

the class CDKAtomTypeMatcherTest method testAllElementsRepresented.

/**
 * Test if all elements up to and including Uranium have atom types.
 *
 * @throws Exception
 */
@Test
public void testAllElementsRepresented() throws Exception {
    AtomTypeFactory factory = AtomTypeFactory.getInstance("org/openscience/cdk/dict/data/cdk-atom-types.owl", SilentChemObjectBuilder.getInstance());
    Assert.assertTrue("Could not read the atom types", factory.getSize() != 0);
    String errorMessage = "Elements without atom type(s) defined in the XML:";
    // TODO: 92 ?
    final int testUptoAtomicNumber = 36;
    int elementsMissingTypes = 0;
    for (int i = 1; i < testUptoAtomicNumber; i++) {
        String symbol = PeriodicTable.getSymbol(i);
        IAtomType[] expectedTypes = factory.getAtomTypes(symbol);
        if (expectedTypes.length == 0) {
            errorMessage += " " + symbol;
            elementsMissingTypes++;
        }
    }
    Assert.assertEquals(errorMessage, 0, elementsMissingTypes);
}
Also used : IAtomType(org.openscience.cdk.interfaces.IAtomType) AtomTypeFactory(org.openscience.cdk.config.AtomTypeFactory) Test(org.junit.Test)

Aggregations

AtomTypeFactory (org.openscience.cdk.config.AtomTypeFactory)16 IAtomType (org.openscience.cdk.interfaces.IAtomType)9 CDKException (org.openscience.cdk.exception.CDKException)7 Test (org.junit.Test)6 IAtom (org.openscience.cdk.interfaces.IAtom)6 IOException (java.io.IOException)4 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)4 Point3d (javax.vecmath.Point3d)2 Ignore (org.junit.Ignore)2 IAtomTypeMatcher (org.openscience.cdk.atomtype.IAtomTypeMatcher)2 AbstractAtomTypeTest (org.openscience.cdk.test.atomtype.AbstractAtomTypeTest)2 AtomConfigurator (ambit2.core.processors.structure.AtomConfigurator)1 SmilesParserWrapper (ambit2.core.smiles.SmilesParserWrapper)1 AtomEnvironmentDescriptor (ambit2.descriptors.AtomEnvironmentDescriptor)1 InputStream (java.io.InputStream)1 StringTokenizer (java.util.StringTokenizer)1 Atom (org.openscience.cdk.Atom)1 AtomContainer (org.openscience.cdk.AtomContainer)1 ChemFile (org.openscience.cdk.ChemFile)1 ChemObject (org.openscience.cdk.ChemObject)1