From: <sh...@us...> - 2007-01-31 13:42:31
|
Revision: 7788 http://svn.sourceforge.net/cdk/?rev=7788&view=rev Author: shk3 Date: 2007-01-31 05:42:28 -0800 (Wed, 31 Jan 2007) Log Message: ----------- more tests for BondTools Modified Paths: -------------- trunk/cdk/src/org/openscience/cdk/test/geometry/BondToolsTest.java trunk/cdk/src/org/openscience/cdk/test/smiles/SmilesGeneratorTest.java Added Paths: ----------- trunk/cdk/src/data/mdl/squareplanar.mol trunk/cdk/src/data/mdl/tetrahedral_1_lazy.mol trunk/cdk/src/data/mdl/tetrahedral_with_four_wedges.mol trunk/cdk/src/data/mdl/trigonal_bipyramidal.mol Added: trunk/cdk/src/data/mdl/squareplanar.mol =================================================================== --- trunk/cdk/src/data/mdl/squareplanar.mol (rev 0) +++ trunk/cdk/src/data/mdl/squareplanar.mol 2007-01-31 13:42:28 UTC (rev 7788) @@ -0,0 +1,15 @@ + + CDK 1/31/07,13:54 + + 5 4 0 0 0 0 0 0 0 0999 V2000 + 259.0000 1023.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 295.0000 1023.0000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 + 241.0000 991.8231 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 223.0000 1023.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 277.0000 1054.0000 0.0000 Cl 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 1 0 0 0 + 1 3 1 1 0 0 0 + 1 4 1 6 0 0 0 + 1 5 1 6 0 0 0 +M END + Added: trunk/cdk/src/data/mdl/tetrahedral_1_lazy.mol =================================================================== --- trunk/cdk/src/data/mdl/tetrahedral_1_lazy.mol (rev 0) +++ trunk/cdk/src/data/mdl/tetrahedral_1_lazy.mol 2007-01-31 13:42:28 UTC (rev 7788) @@ -0,0 +1,14 @@ + + CDK 1/31/07,13:9 + + 5 4 0 0 0 0 0 0 0 0999 V2000 + 259.0000 1023.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 295.0000 1023.0000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 + 241.0000 1054.1769 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 241.0000 991.8231 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 223.0000 1023.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 0 0 0 + 1 3 1 0 0 0 0 + 1 4 1 1 0 0 0 + 1 5 1 0 0 0 0 +M END Added: trunk/cdk/src/data/mdl/tetrahedral_with_four_wedges.mol =================================================================== --- trunk/cdk/src/data/mdl/tetrahedral_with_four_wedges.mol (rev 0) +++ trunk/cdk/src/data/mdl/tetrahedral_with_four_wedges.mol 2007-01-31 13:42:28 UTC (rev 7788) @@ -0,0 +1,14 @@ + + CDK 1/31/07,14:22 + + 5 4 0 0 0 0 0 0 0 0999 V2000 + 440.0000 621.6769 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 476.0000 621.6769 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 + 422.0000 652.8538 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 422.0000 590.5000 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 404.0000 621.6769 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 6 0 0 0 + 1 3 1 1 0 0 0 + 1 4 1 1 0 0 0 + 1 5 1 6 0 0 0 +M END Added: trunk/cdk/src/data/mdl/trigonal_bipyramidal.mol =================================================================== --- trunk/cdk/src/data/mdl/trigonal_bipyramidal.mol (rev 0) +++ trunk/cdk/src/data/mdl/trigonal_bipyramidal.mol 2007-01-31 13:42:28 UTC (rev 7788) @@ -0,0 +1,16 @@ + + CDK 1/31/07,13:48 + + 6 5 0 0 0 0 0 0 0 0999 V2000 + 259.0000 1023.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 295.0000 1023.0000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 + 241.0000 1054.1769 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 241.0000 991.8231 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 223.0000 1023.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 277.0000 1054.0000 0.0000 Cl 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 0 0 0 + 1 3 1 0 0 0 0 + 1 4 1 1 0 0 0 + 1 5 1 6 0 0 0 + 1 6 1 0 0 0 0 +M END Modified: trunk/cdk/src/org/openscience/cdk/test/geometry/BondToolsTest.java =================================================================== --- trunk/cdk/src/org/openscience/cdk/test/geometry/BondToolsTest.java 2007-01-31 12:55:34 UTC (rev 7787) +++ trunk/cdk/src/org/openscience/cdk/test/geometry/BondToolsTest.java 2007-01-31 13:42:28 UTC (rev 7788) @@ -22,6 +22,8 @@ import java.io.InputStream; +import javax.vecmath.Point3d; + import junit.framework.Test; import junit.framework.TestSuite; @@ -109,6 +111,127 @@ fail(exc.getMessage()); } } + + + public void testCloseEnoughToBond_IAtom_IAtom_double(){ + try{ + String filename = "data/mdl/testdoublebondconfig.mol"; + InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); + MDLV2000Reader reader = new MDLV2000Reader(ins); + ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + IMolecule mol=chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0); + mol.getAtom(0).setPoint3d(new Point3d(mol.getAtom(0).getPoint2d().x,mol.getAtom(0).getPoint2d().y,0)); + mol.getAtom(1).setPoint3d(new Point3d(mol.getAtom(1).getPoint2d().x,mol.getAtom(1).getPoint2d().y,0)); + mol.getAtom(8).setPoint3d(new Point3d(mol.getAtom(8).getPoint2d().x,mol.getAtom(8).getPoint2d().y,0)); + assertTrue(BondTools.closeEnoughToBond(mol.getAtom(0),mol.getAtom(1),1)); + assertFalse(BondTools.closeEnoughToBond(mol.getAtom(0),mol.getAtom(8),1)); + } catch (Exception exc) { + exc.printStackTrace(); + fail(exc.getMessage()); + } + } + + public void testGiveAngleBothMethods_Point2d_Point2d_Point2d_boolean(){ + try{ + String filename = "data/mdl/testdoublebondconfig.mol"; + InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); + MDLV2000Reader reader = new MDLV2000Reader(ins); + ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + IMolecule mol=chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0); + assertEquals(2.0943946986086157,BondTools.giveAngleBothMethods(mol.getAtom(0).getPoint2d(),mol.getAtom(2).getPoint2d(),mol.getAtom(3).getPoint2d(),true),0.2); + assertEquals(2.0943946986086157,BondTools.giveAngleBothMethods(mol.getAtom(0).getPoint2d(),mol.getAtom(2).getPoint2d(),mol.getAtom(3).getPoint2d(),false),0.2); + } catch (Exception exc) { + exc.printStackTrace(); + fail(exc.getMessage()); + } + } + + public void testIsTetrahedral_IAtomContainer_IAtom_boolean(){ + try{ + String filename = "data/mdl/tetrahedral_1.mol"; + InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); + MDLV2000Reader reader = new MDLV2000Reader(ins); + ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + IMolecule mol=chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0); + assertEquals(BondTools.isTetrahedral(mol,mol.getAtom(0),true),1); + assertEquals(BondTools.isTetrahedral(mol,mol.getAtom(1),true),0); + filename = "data/mdl/tetrahedral_1_lazy.mol"; + ins = this.getClass().getClassLoader().getResourceAsStream(filename); + reader = new MDLV2000Reader(ins); + chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + mol=chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0); + assertEquals(BondTools.isTetrahedral(mol,mol.getAtom(0),true),0); + assertEquals(BondTools.isTetrahedral(mol,mol.getAtom(0),false),3); + } catch (Exception exc) { + exc.printStackTrace(); + fail(exc.getMessage()); + } + } + + public void testIsTrigonalBipyramidalOrOctahedral_IAtomContainer_IAtom(){ + try{ + String filename = "data/mdl/trigonal_bipyramidal.mol"; + InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); + MDLV2000Reader reader = new MDLV2000Reader(ins); + ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + IMolecule mol=chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0); + assertEquals(BondTools.isTrigonalBipyramidalOrOctahedral(mol,mol.getAtom(0)),1); + assertEquals(BondTools.isTrigonalBipyramidalOrOctahedral(mol,mol.getAtom(1)),0); + } catch (Exception exc) { + exc.printStackTrace(); + fail(exc.getMessage()); + } + } + + public void testIsStereo_IAtomContainer_IAtom(){ + try{ + String filename = "data/mdl/trigonal_bipyramidal.mol"; + InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); + MDLV2000Reader reader = new MDLV2000Reader(ins); + ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + IMolecule mol=chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0); + assertTrue(BondTools.isStereo(mol,mol.getAtom(0))); + assertFalse(BondTools.isStereo(mol,mol.getAtom(1))); + } catch (Exception exc) { + exc.printStackTrace(); + fail(exc.getMessage()); + } + } + + public void testIsSquarePlanar_IAtomContainer_IAtom(){ + try{ + String filename = "data/mdl/squareplanar.mol"; + InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); + MDLV2000Reader reader = new MDLV2000Reader(ins); + ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + IMolecule mol=chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0); + assertTrue(BondTools.isSquarePlanar(mol,mol.getAtom(0))); + assertFalse(BondTools.isSquarePlanar(mol,mol.getAtom(1))); + } catch (Exception exc) { + exc.printStackTrace(); + fail(exc.getMessage()); + } + } + + public void testStereosAreOpposite_IAtomContainer_IAtom(){ + try{ + String filename = "data/mdl/squareplanar.mol"; + InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); + MDLV2000Reader reader = new MDLV2000Reader(ins); + ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + IMolecule mol=chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0); + assertFalse(BondTools.stereosAreOpposite(mol,mol.getAtom(0))); + filename = "data/mdl/tetrahedral_with_four_wedges.mol"; + ins = this.getClass().getClassLoader().getResourceAsStream(filename); + reader = new MDLV2000Reader(ins); + chemFile = (ChemFile)reader.read((ChemObject)new ChemFile()); + mol=chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0); + assertTrue(BondTools.stereosAreOpposite(mol,mol.getAtom(0))); + } catch (Exception exc) { + exc.printStackTrace(); + fail(exc.getMessage()); + } + } } Modified: trunk/cdk/src/org/openscience/cdk/test/smiles/SmilesGeneratorTest.java =================================================================== --- trunk/cdk/src/org/openscience/cdk/test/smiles/SmilesGeneratorTest.java 2007-01-31 12:55:34 UTC (rev 7787) +++ trunk/cdk/src/org/openscience/cdk/test/smiles/SmilesGeneratorTest.java 2007-01-31 13:42:28 UTC (rev 7788) @@ -180,10 +180,10 @@ String smiles1 = sg.createSMILES(mol1, true, new boolean[mol1.getBondCount()]); assertNotNull(smiles1); assertEquals("[H]OC(=O)[C@](F)(N([H])[H])C([H])([H])[H]", smiles1); + + //by setting additional stereo descriptors, we should get another smiles mol1.getBond(1).setStereo(CDKConstants.STEREO_BOND_DOWN); mol1.getBond(2).setStereo(CDKConstants.STEREO_BOND_UP); - - // what is tested below? smiles1 = sg.createSMILES(mol1, true, new boolean[mol1.getBondCount()]); assertNotNull(smiles1); assertEquals("[H]OC(=O)[C@](F)(C([H])([H])[H])N([H])[H]", smiles1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |