From: Nikolay K. <ni...@un...> - 2014-03-13 13:17:29
|
Hi, I obtain Null pointer exception when I try to generate the smiles code for a molecule with hydrogen atoms converted from implicit to explicit. Am I missing something in the explicit hydrogens manipulation? The exception is in thrown by the Beem package. I use CDK 1.5.6 Here is the java code: public void testSmilesParser(String smiles) throws Exception { System.out.println("Testing smiles: " + smiles); SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles(smiles); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); CDKHydrogenAdder adder = CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance()); adder.addImplicitHydrogens(mol); HydrogenAdderProcessor.convertImplicitToExplicitHydrogens(mol); SmilesGenerator smiGen = new SmilesGenerator(); String smiles2 = smiGen.create(mol); System.out.println(smiles + " --> " + smiles2); } testSmilesParser("CC"); And here is the output. Testing smiles: CC Exception in thread "main" java.lang.NullPointerException: One or more atoms had an undefined number of implicit hydrogens at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:208) at org.openscience.cdk.smiles.CDKToBeam.toBeamAtom(CDKToBeam.java:200) at org.openscience.cdk.smiles.CDKToBeam.toBeamGraph(CDKToBeam.java:148) at org.openscience.cdk.smiles.SmilesGenerator.create(SmilesGenerator.java:376) at org.openscience.cdk.smiles.SmilesGenerator.create(SmilesGenerator.java:332) at ambit2.smarts.test.TestUtilities.testSmilesParser(TestUtilities.java:1534) at ambit2.smarts.test.TestUtilities.main(TestUtilities.java:2127) Analogously in the molecule is read from a MOL file the same exception is thrown. If the input smiles is defined with explicit hydrogen there is no problem. testSmilesParser("[H]C([H])([H])C([H])([H])[H]"); outputs: Testing smiles: [H]C([H])([H])C([H])([H])[H] [H]C([H])([H])C([H])([H])[H] --> [H]C([H])([H])C([H])([H])[H] With best regards Nick ---------------------------------------------------------- Dr. Nikolay Kochev University of Plovdiv Department of Analytical Chemistry and Computer Chemistry ---------------------------------------------------------- |