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;
}
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);
}
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());
}
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());
}
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);
}
Aggregations