Example #1
0
        /// <summary>
        /// Returns the R or S chirality according to the CIP rules, based on the given
        /// chirality information.
        /// </summary>
        /// <param name="container"><see cref="IAtomContainer"/> to which the <paramref name="stereoCenter"/> belongs.</param>
        /// <param name="stereoCenter">Chiral center for which the CIP chirality is to be determined as <see cref="ITetrahedralChirality"/> object.</param>
        /// <returns>A <see cref="CIPChirality"/> value.</returns>
        public static CIPChirality GetCIPChirality(IAtomContainer container, ITetrahedralChirality stereoCenter)
        {
            // the LigancyFourChirality is kind of redundant but we keep for an
            // easy way to get the ILigands array
            var tmp    = new LigancyFourChirality(container, stereoCenter).ligands;
            var stereo = stereoCenter.Stereo;

            int parity = PermParity(tmp);

            if (parity == 0)
            {
                return(CIPChirality.None);
            }
            if (parity < 0)
            {
                stereo = stereo.Invert();
            }

            if (stereo == TetrahedralStereo.Clockwise)
            {
                return(CIPChirality.R);
            }
            if (stereo == TetrahedralStereo.AntiClockwise)
            {
                return(CIPChirality.S);
            }

            return(CIPChirality.None);
        }
Example #2
0
        public void TestTwoVersusDoubleBondedOxygenR()
        {
            var molecule = smiles.ParseSmiles("OC(O)C([H])(C)C=O");
            LigancyFourChirality chirality = CIPTool.DefineLigancyFourChirality(molecule, 3, 4, 5, 1, 6, TetrahedralStereo.Clockwise);

            Assert.AreEqual(CIPTool.CIPChirality.R, CIPTool.GetCIPChirality(chirality));
        }
Example #3
0
        public void Test()
        {
            var molecule = smiles.ParseSmiles("ClC(Br)(I)[H]");
            LigancyFourChirality chirality = CIPTool.DefineLigancyFourChirality(molecule, 1, 4, 0, 2, 3, TetrahedralStereo.Clockwise);

            Assert.AreEqual(CIPTool.CIPChirality.R, CIPTool.GetCIPChirality(chirality));
        }
Example #4
0
        public void Test2methylbutanolR()
        {
            var molecule = smiles.ParseSmiles("OCC([H])(C)CC");
            LigancyFourChirality chirality = CIPTool.DefineLigancyFourChirality(molecule, 2, 3, 1, 4, 5, TetrahedralStereo.Clockwise);

            Assert.AreEqual(CIPTool.CIPChirality.R, CIPTool.GetCIPChirality(chirality));
        }
Example #5
0
        public void TestGetCIPChirality()
        {
            var chirality   = new LigancyFourChirality(molecule.Atoms[1], ligands, TetrahedralStereo.Clockwise);
            var rsChirality = CIPTool.GetCIPChirality(chirality);

            Assert.AreEqual(CIPTool.CIPChirality.S, rsChirality);
        }
Example #6
0
        public void TestProject()
        {
            var chirality = new LigancyFourChirality(molecule.Atoms[1], ligands, TetrahedralStereo.Clockwise);

            chirality.Project(ligands);
            Assert.AreEqual(TetrahedralStereo.Clockwise, chirality.Stereo);
        }
Example #7
0
        public void TestImplicitHydrogen()
        {
            var molecule = smiles.ParseSmiles("CCC(C)CCC");
            LigancyFourChirality chirality = CIPTool.DefineLigancyFourChirality(molecule, 2, CIPTool.Hydrogen, 3, 1, 4,
                                                                                TetrahedralStereo.AntiClockwise);

            Assert.AreEqual(CIPTool.CIPChirality.S, CIPTool.GetCIPChirality(chirality));
        }
Example #8
0
        public void TestTetraHalogenMethane()
        {
            var molecule = smiles.ParseSmiles("FC(Br)(Cl)I");
            LigancyFourChirality chirality = CIPTool.DefineLigancyFourChirality(molecule, 1, 0, 4, 2, 3,
                                                                                TetrahedralStereo.AntiClockwise);

            Assert.AreEqual(CIPTool.CIPChirality.R, CIPTool.GetCIPChirality(chirality));
        }
Example #9
0
        public void TestProjectTwoChanges()
        {
            var chirality  = new LigancyFourChirality(molecule.Atoms[1], ligands, TetrahedralStereo.Clockwise);
            var newLigands = new ILigand[] { ligands[1], ligands[0], ligands[3], ligands[2] };

            chirality = chirality.Project(newLigands);
            Assert.AreEqual(TetrahedralStereo.Clockwise, chirality.Stereo);
        }
Example #10
0
        public void TestGetCIPChiralityAnti()
        {
            var antiLigands = new ILigand[] { ligands[0], ligands[1], ligands[3], ligands[2] };

            var chirality   = new LigancyFourChirality(molecule.Atoms[1], antiLigands, TetrahedralStereo.AntiClockwise);
            var rsChirality = CIPTool.GetCIPChirality(chirality);

            Assert.AreEqual(CIPTool.CIPChirality.S, rsChirality);
        }
Example #11
0
        public void TestConstructor()
        {
            var chirality = new LigancyFourChirality(molecule.Atoms[1], ligands, TetrahedralStereo.Clockwise);

            Assert.IsNotNull(chirality);
            Assert.AreEqual(molecule.Atoms[1], chirality.ChiralAtom);
            for (int i = 0; i < ligands.Length; i++)
            {
                Assert.AreEqual(ligands[i], chirality.Ligands[i]);
            }
            Assert.AreEqual(TetrahedralStereo.Clockwise, chirality.Stereo);
        }
Example #12
0
        /// <summary>
        /// Returns the R or S chirality according to the CIP rules, based on the given
        /// chirality information.
        /// </summary>
        /// <param name="stereoCenter">Chiral center for which the CIP chirality is to be
        ///                     determined as <see cref="LigancyFourChirality"/> object.</param>
        /// <returns>A <see cref="CIPChirality"/> value.</returns>
        public static CIPChirality GetCIPChirality(LigancyFourChirality stereoCenter)
        {
            var ligands     = Order(stereoCenter.Ligands);
            var rsChirality = stereoCenter.Project(ligands);

            bool allAreDifferent = CheckIfAllLigandsAreDifferent(ligands);

            if (!allAreDifferent)
            {
                return(CIPChirality.None);
            }

            if (rsChirality.Stereo == TetrahedralStereo.Clockwise)
            {
                return(CIPChirality.R);
            }

            return(CIPChirality.S);
        }
Example #13
0
        public void TestConstructorILigancyFourChirality()
        {
            var ligandAtoms = new List <IAtom>();

            foreach (var ligand in ligands)
            {
                ligandAtoms.Add(ligand.LigandAtom);
            }
            var cdkChiral = new TetrahedralChirality(molecule.Atoms[1],
                                                     ligandAtoms, TetrahedralStereo.Clockwise);
            var chirality = new LigancyFourChirality(molecule, cdkChiral);

            Assert.IsNotNull(chirality);
            Assert.AreEqual(molecule.Atoms[1], chirality.ChiralAtom);
            for (int i = 0; i < ligands.Length; i++)
            {
                Assert.AreEqual(ligands[i].LigandAtom, chirality.Ligands[i].LigandAtom);
                Assert.AreEqual(ligands[i].CentralAtom, chirality.Ligands[i].CentralAtom);
                Assert.AreEqual(ligands[i].AtomContainer, chirality.Ligands[i].AtomContainer);
            }
            Assert.AreEqual(TetrahedralStereo.Clockwise, chirality.Stereo);
        }