From: <raj...@us...> - 2008-07-11 18:27:08
|
Revision: 11548 http://cdk.svn.sourceforge.net/cdk/?rev=11548&view=rev Author: rajarshi Date: 2008-07-11 11:27:06 -0700 (Fri, 11 Jul 2008) Log Message: ----------- Added a test to ensure that IP's for equivalent atoms are equal Modified Paths: -------------- cdk/trunk/src/test/org/openscience/cdk/tools/IonizationPotentialToolTest.java Modified: cdk/trunk/src/test/org/openscience/cdk/tools/IonizationPotentialToolTest.java =================================================================== --- cdk/trunk/src/test/org/openscience/cdk/tools/IonizationPotentialToolTest.java 2008-07-11 14:42:30 UTC (rev 11547) +++ cdk/trunk/src/test/org/openscience/cdk/tools/IonizationPotentialToolTest.java 2008-07-11 18:27:06 UTC (rev 11548) @@ -22,33 +22,69 @@ import org.junit.Assert; import org.junit.Test; +import org.openscience.cdk.DefaultChemObjectBuilder; import org.openscience.cdk.NewCDKTestCase; +import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector; +import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemObjectBuilder; +import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder; +import org.openscience.cdk.smiles.SmilesParser; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** -* TestSuite that runs all tests. -* -* @cdk.module test-ionpot -*/ -public class IonizationPotentialToolTest extends NewCDKTestCase{ + * TestSuite that runs all tests. + * + * @cdk.module test-ionpot + */ +public class IonizationPotentialToolTest extends NewCDKTestCase { - private final static IChemObjectBuilder builder = NoNotificationChemObjectBuilder.getInstance(); + private final static IChemObjectBuilder builder = NoNotificationChemObjectBuilder.getInstance(); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); - /** - * Constructor of the IonizationPotentialToolTest. - */ - public IonizationPotentialToolTest() { + + /** + * Constructor of the IonizationPotentialToolTest. + */ + public IonizationPotentialToolTest() { super(); } - /** - * A unit test suite for JUnit. - * - * @return The test suite - */ - @Test public void testIonizationPotentialTool() { - - Assert.assertNotNull(new IonizationPotentialTool()); - } - + + /** + * A unit test suite for JUnit. + * + * @return The test suite + */ + @Test + public void testIonizationPotentialTool() { + + Assert.assertNotNull(new IonizationPotentialTool()); + } + + @Test + public void testBenzene() throws Exception { + String smiles = "c1ccccc1"; + SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); + IMolecule molecule = sp.parseSmiles(smiles); + lpcheck.saturate(molecule); + addExplicitHydrogens(molecule); + CDKHueckelAromaticityDetector.detectAromaticity(molecule); + + + List<Double> carbonIPs = new ArrayList<Double>(); + Iterator<IAtom> atoms = molecule.atoms(); + while (atoms.hasNext()) { + IAtom atom = atoms.next(); + if (atom.getSymbol().equals("H")) continue; + carbonIPs.add(IonizationPotentialTool.predictIP(molecule, atom)); + } + + double firstIP = carbonIPs.get(0); + for (double ip : carbonIPs) { + Assert.assertEquals(firstIP, ip, 0.0001); + } + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |