From 3043c177b6de26fadd72e60216387ec7284946aa Mon Sep 17 00:00:00 2001 From: Rajarshi Guha Date: Sun, 16 May 2010 11:41:35 -0400 Subject: [PATCH] Renamed the ligancy classes to use the term tetrahedral since they implicitly encode for tetrahedral chirality Signed-off-by: Egon Willighagen --- .../cdk/interfaces/ILigancyFourChirality.java | 65 --------------- .../openscience/cdk/smiles/SmilesParser.java | 8 +- .../cdk/stereo/LigancyFourChirality.java | 83 ------------------- .../cdk/smiles/SmilesParserTest.java | 52 ++++++------ .../cdk/stereo/LigancyFourChiralityTest.java | 14 ++-- 5 files changed, 37 insertions(+), 185 deletions(-) delete mode 100644 src/main/org/openscience/cdk/interfaces/ILigancyFourChirality.java delete mode 100644 src/main/org/openscience/cdk/stereo/LigancyFourChirality.java diff --git a/src/main/org/openscience/cdk/interfaces/ILigancyFourChirality.java b/src/main/org/openscience/cdk/interfaces/ILigancyFourChirality.java deleted file mode 100644 index 71338abc4f0..00000000000 --- a/src/main/org/openscience/cdk/interfaces/ILigancyFourChirality.java +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2010 Egon Willighagen - * - * Contact: cdk-devel@lists.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * All we ask is that proper credit is given for our work, which includes - * - but is not limited to - adding the above copyright notice to the beginning - * of your source code files, and to any copyright notice that you may distribute - * with programs based on this work. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ -package org.openscience.cdk.interfaces; - -/** - * Stereochemistry specification for quadrivalent atoms. The data model defines the central, chiral {@link IAtom}, - * and its four ligand {@link IAtom}s, directly bonded to the chiral atom via an {@link IBond}. The ordering of the - * four ligands is important, and defines together with the {@link Stereo} to spatial geometry around the chiral atom. - * The first ligand points towards to observer, and the three other ligands point away from the observer; the - * {@link Stereo} then defines the order of the second, third, and fourth ligand to be clockwise or anti-clockwise. - * - * @cdk.module interfaces - */ -public interface ILigancyFourChirality extends IStereoElement { - - /** - * Enumeration that defines the two possible chiralities for this stereochemistry type. - */ - public enum Stereo { - CLOCKWISE, - ANTI_CLOCKWISE - } - - /** - * Returns an array of ligand atoms around the chiral atom. - * - * @return an array of four {@link IAtom}s. - */ - public IAtom[] getLigands(); - - /** - * Atom that is the chirality center. - * - * @return the chiral {@link IAtom}. - */ - public IAtom getChiralAtom(); - - /** - * Defines the stereochemistry around the chiral atom. The value depends on the order of ligand atoms. - * - * @return the {@link Stereo} for this stereo element. - */ - public Stereo getStereo(); - -} diff --git a/src/main/org/openscience/cdk/smiles/SmilesParser.java b/src/main/org/openscience/cdk/smiles/SmilesParser.java index 60da400ff00..f579f55c2fb 100644 --- a/src/main/org/openscience/cdk/smiles/SmilesParser.java +++ b/src/main/org/openscience/cdk/smiles/SmilesParser.java @@ -44,15 +44,15 @@ import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; -import org.openscience.cdk.interfaces.ILigancyFourChirality; +import org.openscience.cdk.interfaces.ITetrahedralChirality; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IAtomType.Hybridization; import org.openscience.cdk.interfaces.IBond.Order; -import org.openscience.cdk.interfaces.ILigancyFourChirality.Stereo; -import org.openscience.cdk.stereo.LigancyFourChirality; +import org.openscience.cdk.interfaces.ITetrahedralChirality.Stereo; +import org.openscience.cdk.stereo.TetrahedralChirality; import org.openscience.cdk.tools.CDKHydrogenAdder; import org.openscience.cdk.tools.ILoggingTool; import org.openscience.cdk.tools.LoggingToolFactory; @@ -233,7 +233,7 @@ public IMolecule parseSmiles(String smiles) throws InvalidSmilesException { TemporaryChiralityStorage chirality = chiralityInfo.get(atom); logger.debug("Chiral atom found: ", atom); IAtom[] atoms = chirality.atoms; - ILigancyFourChirality l4Chiral = new LigancyFourChirality( + ITetrahedralChirality l4Chiral = new TetrahedralChirality( atom, new IAtom[]{ atoms[0], atoms[1], atoms[2], atoms[3] diff --git a/src/main/org/openscience/cdk/stereo/LigancyFourChirality.java b/src/main/org/openscience/cdk/stereo/LigancyFourChirality.java deleted file mode 100644 index 1ce9d443745..00000000000 --- a/src/main/org/openscience/cdk/stereo/LigancyFourChirality.java +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (C) 2010 Egon Willighagen - * - * Contact: cdk-devel@lists.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * All we ask is that proper credit is given for our work, which includes - * - but is not limited to - adding the above copyright notice to the beginning - * of your source code files, and to any copyright notice that you may distribute - * with programs based on this work. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ -package org.openscience.cdk.stereo; - -import org.openscience.cdk.DefaultChemObjectBuilder; -import org.openscience.cdk.interfaces.IAtom; -import org.openscience.cdk.interfaces.IChemObjectBuilder; -import org.openscience.cdk.interfaces.ILigancyFourChirality; - -/** - * Stereochemistry specification for quadrivalent atoms. See {@link ILigancyFourChirality} for - * further details. - * - * @cdk.module data - * - * @see ILigancyFourChirality - */ -public class LigancyFourChirality implements ILigancyFourChirality { - - private IAtom chiralAtom; - private IAtom[] ligandAtoms; - private Stereo stereo; - - public LigancyFourChirality(IAtom chiralAtom, IAtom[] ligandAtoms, Stereo chirality) { - this.chiralAtom = chiralAtom; - this.ligandAtoms = ligandAtoms; - this.stereo = chirality; - } - - /** - * Returns an array of ligand atoms around the chiral atom. - * - * @return an array of four {@link IAtom}s. - */ - public IAtom[] getLigands() { - IAtom[] arrayCopy = new IAtom[4]; - System.arraycopy(ligandAtoms, 0, arrayCopy, 0, 4); - return arrayCopy; - } - - /** - * Atom that is the chirality center. - * - * @return the chiral {@link IAtom}. - */ - public IAtom getChiralAtom() { - return chiralAtom; - } - - /** - * Defines the stereochemistry around the chiral atom. The value depends on the order of ligand atoms. - * - * @return the {@link Stereo} for this stereo element. - */ - public Stereo getStereo() { - return stereo; - } - - public IChemObjectBuilder getBuilder() { - return DefaultChemObjectBuilder.getInstance(); - } - -} diff --git a/src/test/org/openscience/cdk/smiles/SmilesParserTest.java b/src/test/org/openscience/cdk/smiles/SmilesParserTest.java index f5a9ef23231..299d1d7e9b9 100644 --- a/src/test/org/openscience/cdk/smiles/SmilesParserTest.java +++ b/src/test/org/openscience/cdk/smiles/SmilesParserTest.java @@ -39,13 +39,13 @@ import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; -import org.openscience.cdk.interfaces.ILigancyFourChirality; +import org.openscience.cdk.interfaces.ITetrahedralChirality; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IStereoElement; -import org.openscience.cdk.interfaces.ILigancyFourChirality.Stereo; +import org.openscience.cdk.interfaces.ITetrahedralChirality.Stereo; import org.openscience.cdk.isomorphism.IsomorphismTester; import org.openscience.cdk.isomorphism.UniversalIsomorphismTester; import org.openscience.cdk.layout.StructureDiagramGenerator; @@ -1872,8 +1872,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -1896,8 +1896,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -1915,8 +1915,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -1934,8 +1934,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -1965,8 +1965,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -1985,8 +1985,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -1999,8 +1999,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -2019,8 +2019,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -2038,8 +2038,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -2057,8 +2057,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -2076,8 +2076,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); IAtom[] ligands = l4Chiral.getLigands(); for (IAtom atom : ligands) Assert.assertNotNull(atom); @@ -2096,8 +2096,8 @@ public void testAromaticity() throws InvalidSmilesException{ Assert.assertTrue(stereoElements.hasNext()); IStereoElement stereoElement = stereoElements.next(); Assert.assertNotNull(stereoElement); - Assert.assertTrue(stereoElement instanceof ILigancyFourChirality); - ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement; + Assert.assertTrue(stereoElement instanceof ITetrahedralChirality); + ITetrahedralChirality l4Chiral = (ITetrahedralChirality)stereoElement; Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol()); if (l4Chiral.getStereo() == Stereo.CLOCKWISE) { IAtom[] ligands = l4Chiral.getLigands(); diff --git a/src/test/org/openscience/cdk/stereo/LigancyFourChiralityTest.java b/src/test/org/openscience/cdk/stereo/LigancyFourChiralityTest.java index e5b04b59331..04b7666de48 100644 --- a/src/test/org/openscience/cdk/stereo/LigancyFourChiralityTest.java +++ b/src/test/org/openscience/cdk/stereo/LigancyFourChiralityTest.java @@ -32,7 +32,7 @@ import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IBond.Order; -import org.openscience.cdk.interfaces.ILigancyFourChirality.Stereo; +import org.openscience.cdk.interfaces.ITetrahedralChirality.Stereo; /** * @cdk.module test-data @@ -64,7 +64,7 @@ public static void setup() throws Exception { @Test public void testLigancyFourChirality_IAtom_arrayIAtom_ILigancyFourChirality_STEREO() { - LigancyFourChirality chirality = new LigancyFourChirality( + TetrahedralChirality chirality = new TetrahedralChirality( molecule.getAtom(1), ligands, Stereo.CLOCKWISE ); Assert.assertNotNull(chirality); @@ -72,7 +72,7 @@ public void testLigancyFourChirality_IAtom_arrayIAtom_ILigancyFourChirality_STER @Test public void testGetBuilder() { - LigancyFourChirality chirality = new LigancyFourChirality( + TetrahedralChirality chirality = new TetrahedralChirality( molecule.getAtom(1), ligands, Stereo.CLOCKWISE ); Assert.assertEquals( @@ -83,7 +83,7 @@ public void testGetBuilder() { @Test public void testGetChiralAtom() { - LigancyFourChirality chirality = new LigancyFourChirality( + TetrahedralChirality chirality = new TetrahedralChirality( molecule.getAtom(1), ligands, Stereo.CLOCKWISE ); Assert.assertNotNull(chirality); @@ -92,7 +92,7 @@ public void testGetChiralAtom() { @Test public void testGetStereo() { - LigancyFourChirality chirality = new LigancyFourChirality( + TetrahedralChirality chirality = new TetrahedralChirality( molecule.getAtom(1), ligands, Stereo.CLOCKWISE ); Assert.assertNotNull(chirality); @@ -100,12 +100,12 @@ public void testGetStereo() { for (int i=0; i