Search in sources :

Example 1 with IElement

use of org.openscience.cdk.interfaces.IElement in project ambit-mirror by ideaconsult.

the class MoleculeTools method analyzeSubstance.

/*
	 * protected static byte[] toByteArray(BitSet bits) { byte[] bytes = new
	 * byte[bits.length()/8+1]; for (int i=0; i<bits.length(); i++) { if
	 * (bits.get(i)) { bytes[bytes.length-i/8-1] |= 1<<(i%8); } } return bytes;
	 * }
	 */
public static boolean analyzeSubstance(IAtomContainer molecule) throws IOException {
    if ((molecule == null) || (molecule.getAtomCount() == 0))
        return false;
    int noH = 0;
    // MFAnalyser mfa = new MFAnalyser(molecule);
    IMolecularFormula formula = MolecularFormulaManipulator.getMolecularFormula(molecule);
    IElement h = Isotopes.getInstance().getElement("H");
    if (MolecularFormulaManipulator.getElementCount(formula, h) == 0) {
        noH = 1;
        // cdk/data/config
        if (adder == null)
            adder = CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance());
        try {
            adder.addImplicitHydrogens(molecule);
            int atomCount = molecule.getAtomCount();
            formula = MolecularFormulaManipulator.getMolecularFormula(molecule);
        } catch (CDKException x) {
            logger.log(Level.SEVERE, x.getMessage(), x);
            formula = null;
        }
    }
    if (formula != null) {
        molecule.setProperty(AmbitCONSTANTS.FORMULA, MolecularFormulaManipulator.getString(formula));
        double mass = MolecularFormulaManipulator.getTotalMassNumber(formula);
        molecule.setProperty(AmbitCONSTANTS.MOLWEIGHT, new Double(mass));
        try {
            molecule.setProperty(AmbitCONSTANTS.STRUCTURETYPE, sp.process(molecule));
        } catch (Exception x) {
        }
        ;
        molecule.setProperty(AmbitCONSTANTS.SUBSTANCETYPE, getSubstanceType(MolecularFormulaManipulator.getString(formula)));
    }
    return true;
}
Also used : IElement(org.openscience.cdk.interfaces.IElement) CDKException(org.openscience.cdk.exception.CDKException) IMolecularFormula(org.openscience.cdk.interfaces.IMolecularFormula) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) CDKException(org.openscience.cdk.exception.CDKException) IOException(java.io.IOException)

Example 2 with IElement

use of org.openscience.cdk.interfaces.IElement in project cdk by cdk.

the class PDBAtomTest method testPDBAtom_IElement.

@Test
public void testPDBAtom_IElement() {
    IElement element = new Element();
    IAtom a = new PDBAtom(element);
    Assert.assertNotNull(a);
}
Also used : IElement(org.openscience.cdk.interfaces.IElement) IPDBAtom(org.openscience.cdk.interfaces.IPDBAtom) IElement(org.openscience.cdk.interfaces.IElement) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test) AbstractPDBAtomTest(org.openscience.cdk.test.interfaces.AbstractPDBAtomTest)

Example 3 with IElement

use of org.openscience.cdk.interfaces.IElement in project cdk by cdk.

the class PseudoAtomTest method testPseudoAtom_IElement.

@Test
public void testPseudoAtom_IElement() {
    IElement element = newChemObject().getBuilder().newInstance(IElement.class);
    IPseudoAtom a = new PseudoAtom(element);
    Assert.assertEquals("R", a.getSymbol());
    Assert.assertNull(a.getPoint3d());
    Assert.assertNull(a.getPoint2d());
    Assert.assertNull(a.getFractionalPoint3d());
}
Also used : IPseudoAtom(org.openscience.cdk.interfaces.IPseudoAtom) IElement(org.openscience.cdk.interfaces.IElement) IPseudoAtom(org.openscience.cdk.interfaces.IPseudoAtom) AbstractPseudoAtomTest(org.openscience.cdk.test.interfaces.AbstractPseudoAtomTest) Test(org.junit.Test)

Example 4 with IElement

use of org.openscience.cdk.interfaces.IElement in project cdk by cdk.

the class IsotopeTest method testIsotope_IElement.

@Test
public void testIsotope_IElement() {
    IElement element = new Element("C");
    IIsotope i = new Isotope(element);
    Assert.assertEquals("C", i.getSymbol());
}
Also used : IIsotope(org.openscience.cdk.interfaces.IIsotope) IElement(org.openscience.cdk.interfaces.IElement) IIsotope(org.openscience.cdk.interfaces.IIsotope) IElement(org.openscience.cdk.interfaces.IElement) AbstractIsotopeTest(org.openscience.cdk.test.interfaces.AbstractIsotopeTest) Test(org.junit.Test)

Example 5 with IElement

use of org.openscience.cdk.interfaces.IElement in project cdk by cdk.

the class AtomTest method testAtom_IElement.

@Test
public void testAtom_IElement() {
    IElement element = newChemObject().getBuilder().newInstance(IElement.class);
    IAtom a = new Atom(element);
    Assert.assertNotNull(a);
}
Also used : IElement(org.openscience.cdk.interfaces.IElement) IAtom(org.openscience.cdk.interfaces.IAtom) IAtom(org.openscience.cdk.interfaces.IAtom) AbstractAtomTest(org.openscience.cdk.test.interfaces.AbstractAtomTest) Test(org.junit.Test)

Aggregations

IElement (org.openscience.cdk.interfaces.IElement)71 Test (org.junit.Test)59 AbstractElementTest (org.openscience.cdk.test.interfaces.AbstractElementTest)15 IAtom (org.openscience.cdk.interfaces.IAtom)13 IIsotope (org.openscience.cdk.interfaces.IIsotope)10 IMolecularFormula (org.openscience.cdk.interfaces.IMolecularFormula)9 IChemObject (org.openscience.cdk.interfaces.IChemObject)8 CDKException (org.openscience.cdk.exception.CDKException)4 MolecularFormula (org.openscience.cdk.formula.MolecularFormula)4 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)4 IPseudoAtom (org.openscience.cdk.interfaces.IPseudoAtom)4 ChemObject (org.openscience.cdk.ChemObject)3 IsotopeFactory (org.openscience.cdk.config.IsotopeFactory)3 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)3 IAtomType (org.openscience.cdk.interfaces.IAtomType)3 AbstractAtomTest (org.openscience.cdk.test.interfaces.AbstractAtomTest)3 AbstractAtomTypeTest (org.openscience.cdk.test.interfaces.AbstractAtomTypeTest)3 AbstractIsotopeTest (org.openscience.cdk.test.interfaces.AbstractIsotopeTest)3 AbstractPDBAtomTest (org.openscience.cdk.test.interfaces.AbstractPDBAtomTest)3 AbstractPseudoAtomTest (org.openscience.cdk.test.interfaces.AbstractPseudoAtomTest)3