コード例 #1
0
ファイル: MoleculeFactory.cs プロジェクト: nofuture-git/31g
        public static IAtomContainer Methenium()
        {
            var methenium = new AtomContainer();
            var carbon    = methenium.AddAtom("C");

            for (var i = 0; i < 3; i++)
            {
                methenium.AddBond(carbon, methenium.AddAtom("H"), BondOrder.Single);
            }

            //the electron pair is gone
            carbon.FormalCharge = 1;
            methenium.Title     = nameof(methenium);

            return(methenium);
        }
コード例 #2
0
        public void TestRemoveElectronContainer_IAtomContainerSet_IElectronContainer()
        {
            IChemObjectSet <IAtomContainer> ms = new ChemObjectSet <IAtomContainer>();
            var mol = new AtomContainer();

            mol.Atoms.Add(new Atom("O"));
            mol.Atoms.Add(new Atom("O"));
            mol.AddBond(mol.Atoms[0], mol.Atoms[1], BondOrder.Double);
            IBond bond = mol.Bonds[0];

            ms.Add(mol);
            IBond otherBond = new Bond(new Atom(), new Atom());

            MoleculeSetManipulator.RemoveElectronContainer(ms, otherBond);
            Assert.AreEqual(1, MoleculeSetManipulator.GetBondCount(ms));
            MoleculeSetManipulator.RemoveElectronContainer(ms, bond);
            Assert.AreEqual(0, MoleculeSetManipulator.GetBondCount(ms));
        }
コード例 #3
0
ファイル: MoleculeFactory.cs プロジェクト: nofuture-git/31g
        public static IAtomContainer Lye()
        {
            var hydroxideAnion = new AtomContainer();
            var oxy            = hydroxideAnion.AddAtom("O");

            oxy.FormalCharge = -1;

            hydroxideAnion.AddBond(oxy, hydroxideAnion.AddAtom("H"), BondOrder.Single);

            var lye = new Crystal(hydroxideAnion);

            var sodium = lye.AddAtom("Na");

            sodium.FormalCharge = 1;

            lye.Title = nameof(lye);

            return(lye);
        }
コード例 #4
0
        public void TestRemoveAtomAndConnectedElectronContainers_IAtomContainerSet_IAtom()
        {
            IChemObjectSet <IAtomContainer> ms = new ChemObjectSet <IAtomContainer>();
            var mol = new AtomContainer();

            mol.Atoms.Add(new Atom("O"));
            mol.Atoms.Add(new Atom("O"));
            mol.AddBond(mol.Atoms[0], mol.Atoms[1], BondOrder.Double);
            IAtom atom = mol.Atoms[0];

            ms.Add(mol);
            IAtom otherAtom = new Atom("O");

            MoleculeSetManipulator.RemoveAtomAndConnectedElectronContainers(ms, otherAtom);
            Assert.AreEqual(1, MoleculeSetManipulator.GetBondCount(ms));
            Assert.AreEqual(2, MoleculeSetManipulator.GetAtomCount(ms));
            MoleculeSetManipulator.RemoveAtomAndConnectedElectronContainers(ms, atom);
            Assert.AreEqual(0, MoleculeSetManipulator.GetBondCount(ms));
            Assert.AreEqual(1, MoleculeSetManipulator.GetAtomCount(ms));
        }
コード例 #5
0
ファイル: MoleculeFactory.cs プロジェクト: nofuture-git/31g
        public static IAtomContainer Bleach()
        {
            var hypochlorite = new AtomContainer();

            var oxygen = hypochlorite.AddAtom("O");

            var chloride = hypochlorite.AddAtom("Cl");

            chloride.FormalCharge = -1;

            hypochlorite.AddBond(oxygen, chloride, BondOrder.Single);

            var bleach = new Crystal(hypochlorite);

            var sodium = bleach.AddAtom("Na");

            sodium.FormalCharge = 1;

            bleach.Title = nameof(bleach);

            return(bleach);
        }
コード例 #6
0
        public void ClockwiseSortShouldHandleExactlyOppositeAtoms()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 0, 4.50d, -14.84d));
            m.Atoms.Add(Atom("C", 3, 4.51d, -13.30d));
            m.Atoms.Add(Atom("C", 2, 4.93d, -14.13d));
            m.Atoms.Add(Atom("C", 2, 3.68d, -14.81d));
            m.Atoms.Add(Atom("O", 0, 4.05d, -15.54d));
            m.Atoms.Add(Atom("O", 1, 3.23d, -15.50d));
            m.Atoms.Add(Atom("C", 3, 5.32d, -14.86d));
            m.Atoms.Add(Atom("C", 3, 4.45d, -16.27d));
            m.AddBond(m.Atoms[0], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[7], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[3], BondOrder.Single);
            m.StereoElements.Add(new TetrahedralChirality(m.Atoms[0], new IAtom[] { m.Atoms[2], m.Atoms[4], m.Atoms[6], m.Atoms[3], }, TetrahedralStereo.AntiClockwise));
            NonplanarBonds.Assign(m);
            Assert.AreEqual(BondStereo.Up, m.Bonds[2].Stereo);
        }
コード例 #7
0
        public void UseCrossedBondIfNeeded()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 3, 0.000, 0.000));
            m.Atoms.Add(Atom("C", 1, 1.299, -0.750));
            m.Atoms.Add(Atom("C", 1, 2.598, -0.000));
            m.Atoms.Add(Atom("C", 1, 3.897, -0.750));
            m.Atoms.Add(Atom("C", 1, 5.196, -0.000));
            m.Atoms.Add(Atom("C", 1, 6.495, -0.750));
            m.Atoms.Add(Atom("C", 1, 7.794, -0.000));
            m.Atoms.Add(Atom("C", 3, 9.093, -0.750));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Double);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Double);
            m.AddBond(m.Atoms[4], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[5], m.Atoms[6], BondOrder.Double);
            m.AddBond(m.Atoms[6], m.Atoms[7], BondOrder.Single);
            m.StereoElements.Add(new DoubleBondStereochemistry(
                                     m.Bonds[1],
                                     new IBond[] {
                m.Bonds[0],
                m.Bonds[2]
            },
                                     DoubleBondConformation.Opposite));
            m.StereoElements.Add(new DoubleBondStereochemistry(
                                     m.Bonds[5],
                                     new IBond[] {
                m.Bonds[4],
                m.Bonds[6]
            },
                                     DoubleBondConformation.Opposite));
            NonplanarBonds.Assign(m);
            Assert.AreEqual(BondStereo.EOrZ, m.Bonds[3].Stereo);
        }
コード例 #8
0
ファイル: MoleculeFactory.cs プロジェクト: nofuture-git/31g
        public static IAtomContainer Antifreeze()
        {
            var antifreeze = new AtomContainer();

            var oxy0 = antifreeze.AddAtom("O");

            antifreeze.AddBond(antifreeze.AddAtom("H"), oxy0, BondOrder.Single);

            var carbon0 = antifreeze.AddAtom("C");

            antifreeze.AddBond(oxy0, carbon0, BondOrder.Single);

            for (var i = 0; i < 2; i++)
            {
                antifreeze.AddBond(carbon0, antifreeze.AddAtom("H"), BondOrder.Single);
            }

            var carbon1 = antifreeze.AddAtom("C");

            antifreeze.AddBond(carbon0, carbon1, BondOrder.Single);

            for (var i = 0; i < 2; i++)
            {
                antifreeze.AddBond(carbon1, antifreeze.AddAtom("H"), BondOrder.Single);
            }

            var oxy1 = antifreeze.AddAtom("O");

            antifreeze.AddBond(carbon1, oxy1, BondOrder.Single);

            antifreeze.AddBond(oxy1, antifreeze.AddAtom("H"), BondOrder.Single);

            antifreeze.SetProperty(NCDK.CDKPropertyName.Title, nameof(antifreeze));

            return(antifreeze);
        }
コード例 #9
0
        public void DontMarkRingBondsInBezeneAsUnspecified()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 1, -1.299, 0.750));
            m.Atoms.Add(Atom("C", 1, 0.000, 1.500));
            m.Atoms.Add(Atom("C", 1, 1.299, 0.750));
            m.Atoms.Add(Atom("C", 1, 1.299, -0.750));
            m.Atoms.Add(Atom("C", 1, 0.000, -1.500));
            m.Atoms.Add(Atom("C", 1, -1.299, -0.750));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Double);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Double);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[5], BondOrder.Double);
            m.AddBond(m.Atoms[0], m.Atoms[5], BondOrder.Single);
            NonplanarBonds.Assign(m);
            foreach (var bond in m.Bonds)
            {
                Assert.AreEqual(BondStereo.None, bond.Stereo);
            }
        }
コード例 #10
0
        public void NonPlanarBondsForClockwsieExtendedTetrahedral()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 3, -1.56d, 0.78d));
            m.Atoms.Add(Atom("C", 0, -1.13d, 1.49d));
            m.Atoms.Add(Atom("C", 0, -0.31d, 1.47d));
            m.Atoms.Add(Atom("C", 0, 0.52d, 1.46d));
            m.Atoms.Add(Atom("C", 3, 0.94d, 2.17d));
            m.Atoms.Add(Atom("H", 0, 0.92d, 0.74d));
            m.Atoms.Add(Atom("H", 0, -1.53d, 2.21d));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Double, BondStereo.None);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Double, BondStereo.None);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[5], BondOrder.Single);
            m.StereoElements.Add(new ExtendedTetrahedral(m.Atoms[2], new IAtom[] { m.Atoms[0], m.Atoms[6], m.Atoms[4], m.Atoms[5] }, TetrahedralStereo.Clockwise));
            NonplanarBonds.Assign(m);
            Assert.AreEqual(BondStereo.Up, m.GetBond(m.Atoms[1], m.Atoms[0]).Stereo);
            Assert.AreEqual(BondStereo.Down, m.GetBond(m.Atoms[1], m.Atoms[6]).Stereo);
        }
コード例 #11
0
        public void Anticlockwise_1()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 0, -1.47d, 3.62d));
            m.Atoms.Add(Atom("C", 2, -1.13d, 2.16d));
            m.Atoms.Add(Atom("C", 2, 0.30d, 1.72d));
            m.Atoms.Add(Atom("C", 3, 0.64d, 0.26d));
            m.Atoms.Add(Atom("C", 3, -2.90d, 4.06d));
            m.Atoms.Add(Atom("N", 2, 0.03d, 3.70d));
            m.Atoms.Add(Atom("O", 1, -1.28d, 5.11d));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[6], BondOrder.Single);
            m.StereoElements.Add(new TetrahedralChirality(m.Atoms[0], new IAtom[] { m.Atoms[1], m.Atoms[4], m.Atoms[5], m.Atoms[6] }, TetrahedralStereo.AntiClockwise));
            NonplanarBonds.Assign(m);
            Assert.AreEqual(BondStereo.None, m.Bonds[0].Stereo);
            Assert.AreEqual(BondStereo.None, m.Bonds[3].Stereo);
            Assert.AreEqual(BondStereo.Down, m.Bonds[4].Stereo);
            Assert.AreEqual(BondStereo.Up, m.Bonds[5].Stereo);
        }
コード例 #12
0
ファイル: MoleculeFactory.cs プロジェクト: nofuture-git/31g
        public static IAtomContainer CitricAcid()
        {
            var citricAcid = new AtomContainer();

            var carbons = Enumerable.Range(0, 6).Select(i => citricAcid.AddAtom("C")).ToList();
            var oxygens = Enumerable.Range(0, 7).Select(i => citricAcid.AddAtom("O")).ToList();

            citricAcid.AddBond(oxygens[0], citricAcid.AddAtom("H"), BondOrder.Single);

            citricAcid.AddBond(oxygens[0], carbons[0], BondOrder.Single);

            citricAcid.AddBond(oxygens[1], carbons[0], BondOrder.Double);

            citricAcid.AddBond(carbons[0], carbons[1], BondOrder.Single);

            citricAcid.AddBond(carbons[1], citricAcid.AddAtom("H"), BondOrder.Single);
            citricAcid.AddBond(carbons[1], citricAcid.AddAtom("H"), BondOrder.Single);

            citricAcid.AddBond(carbons[1], carbons[2], BondOrder.Single);

            citricAcid.AddBond(oxygens[2], citricAcid.AddAtom("H"), BondOrder.Single);

            citricAcid.AddBond(carbons[2], oxygens[2], BondOrder.Single);

            citricAcid.AddBond(carbons[2], carbons[3], BondOrder.Single);

            citricAcid.AddBond(oxygens[3], citricAcid.AddAtom("H"), BondOrder.Single);

            citricAcid.AddBond(carbons[3], oxygens[3], BondOrder.Single);

            citricAcid.AddBond(carbons[3], oxygens[4], BondOrder.Double);

            citricAcid.AddBond(carbons[2], carbons[4], BondOrder.Single);

            citricAcid.AddBond(carbons[4], citricAcid.AddAtom("H"), BondOrder.Single);
            citricAcid.AddBond(carbons[4], citricAcid.AddAtom("H"), BondOrder.Single);

            citricAcid.AddBond(carbons[4], carbons[5], BondOrder.Single);

            citricAcid.AddBond(oxygens[5], citricAcid.AddAtom("H"), BondOrder.Single);

            citricAcid.AddBond(carbons[5], oxygens[5], BondOrder.Single);

            citricAcid.AddBond(carbons[5], oxygens[6], BondOrder.Double);

            citricAcid.Title = nameof(citricAcid);

            return(citricAcid);
        }
コード例 #13
0
        public void SetUp()
        {
            pinene_1 = new AtomContainer();
            pinene_1.Atoms.Add(new Atom("C"));                                        // 1
            pinene_1.Atoms.Add(new Atom("C"));                                        // 2
            pinene_1.Atoms.Add(new Atom("C"));                                        // 3
            pinene_1.Atoms.Add(new Atom("C"));                                        // 4
            pinene_1.Atoms.Add(new Atom("C"));                                        // 5
            pinene_1.Atoms.Add(new Atom("C"));                                        // 6
            pinene_1.Atoms.Add(new Atom("C"));                                        // 7
            pinene_1.Atoms.Add(new Atom("C"));                                        // 8
            pinene_1.Atoms.Add(new Atom("C"));                                        // 9
            pinene_1.Atoms.Add(new Atom("C"));                                        // 10

            pinene_1.AddBond(pinene_1.Atoms[0], pinene_1.Atoms[1], BondOrder.Double); // 1
            pinene_1.AddBond(pinene_1.Atoms[1], pinene_1.Atoms[2], BondOrder.Single); // 2
            pinene_1.AddBond(pinene_1.Atoms[2], pinene_1.Atoms[3], BondOrder.Single); // 3
            pinene_1.AddBond(pinene_1.Atoms[3], pinene_1.Atoms[4], BondOrder.Single); // 4
            pinene_1.AddBond(pinene_1.Atoms[4], pinene_1.Atoms[5], BondOrder.Single); // 5
            pinene_1.AddBond(pinene_1.Atoms[5], pinene_1.Atoms[0], BondOrder.Single); // 6
            pinene_1.AddBond(pinene_1.Atoms[0], pinene_1.Atoms[6], BondOrder.Single); // 7
            pinene_1.AddBond(pinene_1.Atoms[3], pinene_1.Atoms[7], BondOrder.Single); // 8
            pinene_1.AddBond(pinene_1.Atoms[5], pinene_1.Atoms[7], BondOrder.Single); // 9
            pinene_1.AddBond(pinene_1.Atoms[7], pinene_1.Atoms[8], BondOrder.Single); // 10
            pinene_1.AddBond(pinene_1.Atoms[7], pinene_1.Atoms[9], BondOrder.Single); // 11

            pinene_2 = new AtomContainer();
            pinene_2.Atoms.Add(new Atom("C"));                                        // 1
            pinene_2.Atoms.Add(new Atom("C"));                                        // 2
            pinene_2.Atoms.Add(new Atom("C"));                                        // 3
            pinene_2.Atoms.Add(new Atom("C"));                                        // 4
            pinene_2.Atoms.Add(new Atom("C"));                                        // 5
            pinene_2.Atoms.Add(new Atom("C"));                                        // 6
            pinene_2.Atoms.Add(new Atom("C"));                                        // 7
            pinene_2.Atoms.Add(new Atom("C"));                                        // 8
            pinene_2.Atoms.Add(new Atom("C"));                                        // 9
            pinene_2.Atoms.Add(new Atom("C"));                                        // 10

            pinene_2.AddBond(pinene_2.Atoms[0], pinene_2.Atoms[4], BondOrder.Single); // 1
            pinene_2.AddBond(pinene_2.Atoms[0], pinene_2.Atoms[5], BondOrder.Single); // 2
            pinene_2.AddBond(pinene_2.Atoms[0], pinene_2.Atoms[8], BondOrder.Single); // 3
            pinene_2.AddBond(pinene_2.Atoms[1], pinene_2.Atoms[2], BondOrder.Single); // 4
            pinene_2.AddBond(pinene_2.Atoms[1], pinene_2.Atoms[9], BondOrder.Single); // 5
            pinene_2.AddBond(pinene_2.Atoms[2], pinene_2.Atoms[3], BondOrder.Single); // 6
            pinene_2.AddBond(pinene_2.Atoms[2], pinene_2.Atoms[0], BondOrder.Single); // 7
            pinene_2.AddBond(pinene_2.Atoms[3], pinene_2.Atoms[8], BondOrder.Single); // 8
            pinene_2.AddBond(pinene_2.Atoms[8], pinene_2.Atoms[7], BondOrder.Single); // 9
            pinene_2.AddBond(pinene_2.Atoms[7], pinene_2.Atoms[9], BondOrder.Double); // 10
            pinene_2.AddBond(pinene_2.Atoms[7], pinene_2.Atoms[6], BondOrder.Single); // 11

            pinene_non = new AtomContainer();
            pinene_non.Atoms.Add(new Atom("C"));                                            // 1
            pinene_non.Atoms.Add(new Atom("C"));                                            // 2
            pinene_non.Atoms.Add(new Atom("C"));                                            // 3
            pinene_non.Atoms.Add(new Atom("C"));                                            // 4
            pinene_non.Atoms.Add(new Atom("C"));                                            // 5
            pinene_non.Atoms.Add(new Atom("C"));                                            // 6
            pinene_non.Atoms.Add(new Atom("C"));                                            // 7
            pinene_non.Atoms.Add(new Atom("C"));                                            // 8
            pinene_non.Atoms.Add(new Atom("C"));                                            // 9
            pinene_non.Atoms.Add(new Atom("C"));                                            // 10

            pinene_non.AddBond(pinene_non.Atoms[0], pinene_non.Atoms[5], BondOrder.Single); // 1
            pinene_non.AddBond(pinene_non.Atoms[0], pinene_non.Atoms[7], BondOrder.Single); // 2
            pinene_non.AddBond(pinene_non.Atoms[0], pinene_non.Atoms[8], BondOrder.Single); // 3
            pinene_non.AddBond(pinene_non.Atoms[1], pinene_non.Atoms[9], BondOrder.Single); // 4
            pinene_non.AddBond(pinene_non.Atoms[1], pinene_non.Atoms[4], BondOrder.Single); // 5
            pinene_non.AddBond(pinene_non.Atoms[2], pinene_non.Atoms[3], BondOrder.Single); // 6
            pinene_non.AddBond(pinene_non.Atoms[2], pinene_non.Atoms[4], BondOrder.Single); // 7
            pinene_non.AddBond(pinene_non.Atoms[2], pinene_non.Atoms[6], BondOrder.Single); // 8
            pinene_non.AddBond(pinene_non.Atoms[2], pinene_non.Atoms[7], BondOrder.Single); // 9
            pinene_non.AddBond(pinene_non.Atoms[4], pinene_non.Atoms[5], BondOrder.Double); // 10
            pinene_non.AddBond(pinene_non.Atoms[7], pinene_non.Atoms[9], BondOrder.Single); // 11
        }
コード例 #14
0
        public void BetaDGlucoseWithExplicitHydrogens_Haworth()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 0, 4.16d, 1.66d));
            m.Atoms.Add(Atom("C", 0, 3.75d, 0.94d));
            m.Atoms.Add(Atom("C", 0, 4.16d, 0.23d));
            m.Atoms.Add(Atom("C", 0, 5.05d, 0.23d));
            m.Atoms.Add(Atom("C", 0, 5.46d, 0.94d));
            m.Atoms.Add(Atom("O", 0, 5.05d, 1.66d));
            m.Atoms.Add(Atom("O", 1, 5.46d, 1.48d));
            m.Atoms.Add(Atom("C", 2, 4.16d, 2.20d));
            m.Atoms.Add(Atom("O", 1, 3.45d, 2.61d));
            m.Atoms.Add(Atom("O", 1, 3.74d, 0.50d));
            m.Atoms.Add(Atom("O", 1, 4.16d, 0.77d));
            m.Atoms.Add(Atom("O", 1, 5.04d, -0.21d));
            m.Atoms.Add(Atom("H", 0, 4.15d, -0.21d));
            m.Atoms.Add(Atom("H", 0, 5.05d, 0.77d));
            m.Atoms.Add(Atom("H", 0, 5.45d, 0.50d));
            m.Atoms.Add(Atom("H", 0, 3.75d, 1.48d));
            m.Atoms.Add(Atom("H", 0, 4.17d, 1.15d));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[7], BondOrder.Single);
            m.AddBond(m.Atoms[7], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[9], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[10], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[11], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[12], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[13], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[14], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[15], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[16], BondOrder.Single);

            EdgeToBondMap bondMap = EdgeToBondMap.WithSpaceFor(m);

            int[][] graph = GraphUtil.ToAdjList(m, bondMap);

            Stereocenters stereocenters = new Stereocenters(m, graph, bondMap);

            stereocenters.CheckSymmetry();
            CyclicCarbohydrateRecognition recon = new CyclicCarbohydrateRecognition(m, graph, bondMap,
                                                                                    stereocenters);

            var elements = recon.Recognise(new[] { Projection.Haworth }).ToReadOnlyList();

            AssertTetrahedralCenter(elements[0],
                                    m.Atoms[1],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[15], m.Atoms[0], m.Atoms[9], m.Atoms[2]);
            AssertTetrahedralCenter(elements[1],
                                    m.Atoms[2],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[10], m.Atoms[1], m.Atoms[12], m.Atoms[3]);
            AssertTetrahedralCenter(elements[2],
                                    m.Atoms[3],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[13], m.Atoms[2], m.Atoms[11], m.Atoms[4]);
            AssertTetrahedralCenter(elements[3],
                                    m.Atoms[4],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[6], m.Atoms[3], m.Atoms[14], m.Atoms[5]);
            AssertTetrahedralCenter(elements[4],
                                    m.Atoms[0],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[7], m.Atoms[5], m.Atoms[16], m.Atoms[1]);
        }
コード例 #15
0
        public void TestBug777529()
        {
            var m = new AtomContainer();

            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("C"));
            m.Atoms.Add(new Atom("O"));
            m.Atoms.Add(new Atom("O"));
            m.Atoms.Add(new Atom("F"));
            m.Atoms[0].ImplicitHydrogenCount = 1;
            m.Atoms[2].ImplicitHydrogenCount = 1;
            m.Atoms[3].ImplicitHydrogenCount = 1;
            m.Atoms[6].ImplicitHydrogenCount = 1;
            m.Atoms[7].ImplicitHydrogenCount = 1;
            m.Atoms[8].ImplicitHydrogenCount = 1;
            m.Atoms[9].ImplicitHydrogenCount = 1;
            //m.GetAtomAt(10).SetHydrogenCount(1);
            //m.GetAtomAt(12).SetHydrogenCount(1);
            m.Atoms[14].ImplicitHydrogenCount = 1;
            m.Atoms[15].ImplicitHydrogenCount = 1;
            m.Atoms[17].ImplicitHydrogenCount = 1;
            m.Atoms[18].ImplicitHydrogenCount = 1;
            m.Atoms[19].ImplicitHydrogenCount = 3;
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[5], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[6], m.Atoms[7], BondOrder.Single);
            m.AddBond(m.Atoms[7], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[9], BondOrder.Single);
            m.AddBond(m.Atoms[5], m.Atoms[10], BondOrder.Single);
            m.AddBond(m.Atoms[9], m.Atoms[10], BondOrder.Single);
            m.AddBond(m.Atoms[10], m.Atoms[11], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[12], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[12], BondOrder.Single);
            m.AddBond(m.Atoms[11], m.Atoms[12], BondOrder.Single);
            m.AddBond(m.Atoms[11], m.Atoms[13], BondOrder.Single);
            m.AddBond(m.Atoms[13], m.Atoms[14], BondOrder.Single);
            m.AddBond(m.Atoms[14], m.Atoms[15], BondOrder.Single);
            m.AddBond(m.Atoms[15], m.Atoms[16], BondOrder.Single);
            m.AddBond(m.Atoms[16], m.Atoms[17], BondOrder.Single);
            m.AddBond(m.Atoms[13], m.Atoms[18], BondOrder.Single);
            m.AddBond(m.Atoms[17], m.Atoms[18], BondOrder.Single);
            m.AddBond(m.Atoms[20], m.Atoms[16], BondOrder.Single);
            m.AddBond(m.Atoms[11], m.Atoms[21], BondOrder.Single);
            m.AddBond(m.Atoms[22], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[20], m.Atoms[19], BondOrder.Single);
            m.Atoms[0].IsAromatic  = true;
            m.Atoms[1].IsAromatic  = true;
            m.Atoms[2].IsAromatic  = true;
            m.Atoms[3].IsAromatic  = true;
            m.Atoms[4].IsAromatic  = true;
            m.Atoms[12].IsAromatic = true;
            m.Atoms[5].IsAromatic  = true;
            m.Atoms[6].IsAromatic  = true;
            m.Atoms[7].IsAromatic  = true;
            m.Atoms[8].IsAromatic  = true;
            m.Atoms[9].IsAromatic  = true;
            m.Atoms[10].IsAromatic = true;
            m.Bonds[0].IsAromatic  = true;
            m.Bonds[1].IsAromatic  = true;
            m.Bonds[2].IsAromatic  = true;
            m.Bonds[3].IsAromatic  = true;
            m.Bonds[5].IsAromatic  = true;
            m.Bonds[6].IsAromatic  = true;
            m.Bonds[7].IsAromatic  = true;
            m.Bonds[8].IsAromatic  = true;
            m.Bonds[9].IsAromatic  = true;
            m.Bonds[10].IsAromatic = true;
            m.Bonds[12].IsAromatic = true;
            m.Bonds[13].IsAromatic = true;
            satcheck.Saturate(m);
            Assert.IsTrue(m.Bonds[4].Order == BondOrder.Single);
            Assert.IsTrue(m.Bonds[9].Order == BondOrder.Double ^ m.Bonds[5].Order == BondOrder.Double);
            Assert.IsTrue(m.Bonds[13].Order == BondOrder.Double
                          ^ m.Bonds[3].Order == BondOrder.Double);
        }
コード例 #16
0
        public void HorizontalBondsMustBeTerminal()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 0, 12.71d, -16.51d));
            m.Atoms.Add(Atom("C", 1, 12.30d, -17.22d));
            m.Atoms.Add(Atom("C", 1, 11.47d, -17.22d));
            m.Atoms.Add(Atom("C", 1, 11.06d, -16.51d));
            m.Atoms.Add(Atom("C", 1, 11.47d, -15.79d));
            m.Atoms.Add(Atom("C", 1, 12.30d, -15.79d));
            m.Atoms.Add(Atom("O", 1, 13.54d, -17.33d));
            m.Atoms.Add(Atom("C", 0, 13.54d, -16.51d));
            m.Atoms.Add(Atom("C", 0, 14.36d, -16.51d));
            m.Atoms.Add(Atom("O", 1, 14.77d, -17.22d));
            m.Atoms.Add(Atom("O", 0, 14.77d, -15.79d));
            m.Atoms.Add(Atom("C", 3, 13.54d, -15.68d));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[5], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[4], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[7], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[7], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[9], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[10], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[0], m.Atoms[7], BondOrder.Single);
            m.AddBond(m.Atoms[11], m.Atoms[7], BondOrder.Single);

            EdgeToBondMap bondMap = EdgeToBondMap.WithSpaceFor(m);

            int[][]            graph      = GraphUtil.ToAdjList(m, bondMap);
            FischerRecognition recogniser = new FischerRecognition(m,
                                                                   graph,
                                                                   bondMap,
                                                                   Stereocenters.Of(m));

            Assert.IsTrue(recogniser.Recognise(new[] { Projection.Fischer }).Count() == 0);
        }
コード例 #17
0
        public void Oxpene()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 1, 1.39d, 3.65d));
            m.Atoms.Add(Atom("C", 2, 2.22d, 3.65d));
            m.Atoms.Add(Atom("C", 1, 2.93d, 4.07d));
            m.Atoms.Add(Atom("C", 1, 0.68d, 4.07d));
            m.Atoms.Add(Atom("C", 1, 1.01d, 4.63d));
            m.Atoms.Add(Atom("C", 1, 2.52d, 4.64d));
            m.Atoms.Add(Atom("O", 0, 1.76d, 4.89d));
            m.Atoms.Add(Atom("O", 1, 0.68d, 3.24d));
            m.Atoms.Add(Atom("C", 2, 1.01d, 5.45d));
            m.Atoms.Add(Atom("O", 1, 0.18d, 5.45d));
            m.Atoms.Add(Atom("C", 3, 2.52d, 5.46d));
            m.Atoms.Add(Atom("O", 0, 2.93d, 3.24d));
            m.Atoms.Add(Atom("C", 2, 1.39d, 4.48d));
            m.Atoms.Add(Atom("C", 3, 2.22d, 4.48d));
            m.Atoms.Add(Atom("C", 2, 3.76d, 3.24d));
            m.Atoms.Add(Atom("C", 2, 4.34d, 2.66d));
            m.Atoms.Add(Atom("O", 0, 5.16d, 2.66d));
            m.Atoms.Add(Atom("C", 3, 5.58d, 3.37d));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[5], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[7], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[9], BondOrder.Single);
            m.AddBond(m.Atoms[5], m.Atoms[10], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[11], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[12], BondOrder.Single);
            m.AddBond(m.Atoms[12], m.Atoms[13], BondOrder.Single);
            m.AddBond(m.Atoms[11], m.Atoms[14], BondOrder.Single);
            m.AddBond(m.Atoms[14], m.Atoms[15], BondOrder.Single);
            m.AddBond(m.Atoms[15], m.Atoms[16], BondOrder.Single);
            m.AddBond(m.Atoms[16], m.Atoms[17], BondOrder.Single);
            EdgeToBondMap bondMap = EdgeToBondMap.WithSpaceFor(m);

            int[][] graph = GraphUtil.ToAdjList(m, bondMap);

            Stereocenters stereocenters = new Stereocenters(m, graph, bondMap);

            stereocenters.CheckSymmetry();
            CyclicCarbohydrateRecognition recon = new CyclicCarbohydrateRecognition(m, graph, bondMap,
                                                                                    stereocenters);

            var elements = recon.Recognise(new[] { Projection.Haworth }).ToReadOnlyList();

            AssertTetrahedralCenter(elements[0],
                                    m.Atoms[2],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[2], m.Atoms[1], m.Atoms[11], m.Atoms[5]);
            AssertTetrahedralCenter(elements[1],
                                    m.Atoms[5],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[10], m.Atoms[2], m.Atoms[5], m.Atoms[6]);
            AssertTetrahedralCenter(elements[2],
                                    m.Atoms[4],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[8], m.Atoms[6], m.Atoms[4], m.Atoms[3]);
            AssertTetrahedralCenter(elements[3],
                                    m.Atoms[3],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[3], m.Atoms[4], m.Atoms[7], m.Atoms[0]);
            AssertTetrahedralCenter(elements[4],
                                    m.Atoms[0],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[12], m.Atoms[3], m.Atoms[0], m.Atoms[1]);
        }
コード例 #18
0
        public void Atp_Haworth()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("O", 0, 2.56d, -6.46d));
            m.Atoms.Add(Atom("C", 1, 1.90d, -6.83d));
            m.Atoms.Add(Atom("C", 1, 2.15d, -7.46d));
            m.Atoms.Add(Atom("C", 1, 2.98d, -7.46d));
            m.Atoms.Add(Atom("C", 1, 3.23d, -6.83d));
            m.Atoms.Add(Atom("C", 2, 1.90d, -6.00d));
            m.Atoms.Add(Atom("O", 0, 1.18d, -5.59d));
            m.Atoms.Add(Atom("O", 1, 2.15d, -8.29d));
            m.Atoms.Add(Atom("O", 1, 2.98d, -8.29d));
            m.Atoms.Add(Atom("P", 0, 0.36d, -5.59d));
            m.Atoms.Add(Atom("O", 0, -0.47d, -5.59d));
            m.Atoms.Add(Atom("O", 0, 0.36d, -4.76d));
            m.Atoms.Add(Atom("O", 1, 0.36d, -6.41d));
            m.Atoms.Add(Atom("P", 0, -1.29d, -5.59d));
            m.Atoms.Add(Atom("O", 0, -2.12d, -5.59d));
            m.Atoms.Add(Atom("O", 0, -1.29d, -4.76d));
            m.Atoms.Add(Atom("O", 1, -1.29d, -6.41d));
            m.Atoms.Add(Atom("P", 0, -2.94d, -5.59d));
            m.Atoms.Add(Atom("O", 1, -3.77d, -5.59d));
            m.Atoms.Add(Atom("O", 0, -2.94d, -4.76d));
            m.Atoms.Add(Atom("O", 1, -2.94d, -6.41d));
            m.Atoms.Add(Atom("C", 0, 4.73d, -4.51d));
            m.Atoms.Add(Atom("C", 0, 4.02d, -4.92d));
            m.Atoms.Add(Atom("C", 0, 4.02d, -5.75d));
            m.Atoms.Add(Atom("N", 0, 4.73d, -6.16d));
            m.Atoms.Add(Atom("N", 0, 5.44d, -5.75d));
            m.Atoms.Add(Atom("C", 1, 5.44d, -4.92d));
            m.Atoms.Add(Atom("C", 1, 2.75d, -5.33d));
            m.Atoms.Add(Atom("N", 0, 3.23d, -4.67d));
            m.Atoms.Add(Atom("N", 2, 4.73d, -3.68d));
            m.Atoms.Add(Atom("N", 0, 3.23d, -6.00d));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[5], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[7], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[6], m.Atoms[9], BondOrder.Single);
            m.AddBond(m.Atoms[9], m.Atoms[10], BondOrder.Single);
            m.AddBond(m.Atoms[9], m.Atoms[11], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[9], m.Atoms[12], BondOrder.Single);
            m.AddBond(m.Atoms[13], m.Atoms[14], BondOrder.Single);
            m.AddBond(m.Atoms[13], m.Atoms[15], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[13], m.Atoms[16], BondOrder.Single);
            m.AddBond(m.Atoms[10], m.Atoms[13], BondOrder.Single);
            m.AddBond(m.Atoms[17], m.Atoms[18], BondOrder.Single);
            m.AddBond(m.Atoms[17], m.Atoms[19], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[17], m.Atoms[20], BondOrder.Single);
            m.AddBond(m.Atoms[14], m.Atoms[17], BondOrder.Single);
            m.AddBond(m.Atoms[21], m.Atoms[22], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[22], m.Atoms[23], BondOrder.Single);
            m.AddBond(m.Atoms[23], m.Atoms[24], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[24], m.Atoms[25], BondOrder.Single);
            m.AddBond(m.Atoms[25], m.Atoms[26], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[21], m.Atoms[26], BondOrder.Single);
            m.AddBond(m.Atoms[27], m.Atoms[28], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[22], m.Atoms[28], BondOrder.Single);
            m.AddBond(m.Atoms[21], m.Atoms[29], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[30], BondOrder.Single);
            m.AddBond(m.Atoms[30], m.Atoms[27], BondOrder.Single);
            m.AddBond(m.Atoms[23], m.Atoms[30], BondOrder.Single);

            EdgeToBondMap bondMap = EdgeToBondMap.WithSpaceFor(m);

            int[][] graph = GraphUtil.ToAdjList(m, bondMap);

            Stereocenters stereocenters = new Stereocenters(m, graph, bondMap);

            stereocenters.CheckSymmetry();
            CyclicCarbohydrateRecognition recon = new CyclicCarbohydrateRecognition(m, graph, bondMap,
                                                                                    stereocenters);

            var elements = recon.Recognise(new[] { Projection.Haworth }).ToReadOnlyList();

            AssertTetrahedralCenter(elements[0],
                                    m.Atoms[1],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[5], m.Atoms[0], m.Atoms[1], m.Atoms[2]);
            AssertTetrahedralCenter(elements[1],
                                    m.Atoms[2],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[2], m.Atoms[1], m.Atoms[7], m.Atoms[3]);
            AssertTetrahedralCenter(elements[2],
                                    m.Atoms[3],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[3], m.Atoms[2], m.Atoms[8], m.Atoms[4]);
            AssertTetrahedralCenter(elements[3],
                                    m.Atoms[4],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[30], m.Atoms[3], m.Atoms[4], m.Atoms[0]);
        }
コード例 #19
0
        public void BetaDGlucose_Chair_Rotated()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 1, -0.77d, 10.34d));
            m.Atoms.Add(Atom("C", 1, 0.03d, 10.13d));
            m.Atoms.Add(Atom("O", 0, 0.83d, 10.34d));
            m.Atoms.Add(Atom("C", 1, 1.24d, 9.63d));
            m.Atoms.Add(Atom("C", 1, 0.44d, 9.84d));
            m.Atoms.Add(Atom("C", 1, -0.35d, 9.63d));
            m.Atoms.Add(Atom("O", 1, 0.86d, 9.13d));
            m.Atoms.Add(Atom("O", 1, 2.04d, 9.84d));
            m.Atoms.Add(Atom("C", 2, -0.68d, 10.54d));
            m.Atoms.Add(Atom("O", 1, -0.68d, 11.37d));
            m.Atoms.Add(Atom("O", 1, -1.48d, 9.93d));
            m.Atoms.Add(Atom("O", 1, -1.15d, 9.84d));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[5], m.Atoms[0], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[7], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[9], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[10], BondOrder.Single);
            m.AddBond(m.Atoms[5], m.Atoms[11], BondOrder.Single);

            Vector2 center = GeometryUtil.Get2DCenter(m);

            GeometryUtil.Rotate(m, center, Vectors.DegreeToRadian(-80));

            for (int i = 0; i < 30; i++)
            {
                GeometryUtil.Rotate(m, center, Vectors.DegreeToRadian(5));

                EdgeToBondMap bondMap       = EdgeToBondMap.WithSpaceFor(m);
                int[][]       graph         = GraphUtil.ToAdjList(m, bondMap);
                Stereocenters stereocenters = new Stereocenters(m, graph, bondMap);
                stereocenters.CheckSymmetry();
                CyclicCarbohydrateRecognition recon = new CyclicCarbohydrateRecognition(m, graph, bondMap,
                                                                                        stereocenters);

                var elements = recon.Recognise(new[] { Projection.Chair }).ToReadOnlyList();
                m.SetStereoElements(elements);

                AssertTetrahedralCenter(elements[0],
                                        m.Atoms[1],
                                        TetrahedralStereo.Clockwise,
                                        m.Atoms[8], m.Atoms[0], m.Atoms[1], m.Atoms[2]);
                AssertTetrahedralCenter(elements[1],
                                        m.Atoms[3],
                                        TetrahedralStereo.Clockwise,
                                        m.Atoms[7], m.Atoms[2], m.Atoms[3], m.Atoms[4]);
                AssertTetrahedralCenter(elements[2],
                                        m.Atoms[4],
                                        TetrahedralStereo.Clockwise,
                                        m.Atoms[4], m.Atoms[3], m.Atoms[6], m.Atoms[5]);
                AssertTetrahedralCenter(elements[3],
                                        m.Atoms[5],
                                        TetrahedralStereo.Clockwise,
                                        m.Atoms[11], m.Atoms[4], m.Atoms[5], m.Atoms[0]);
                AssertTetrahedralCenter(elements[4],
                                        m.Atoms[0],
                                        TetrahedralStereo.Clockwise,
                                        m.Atoms[0], m.Atoms[5], m.Atoms[10], m.Atoms[1]);
            }
        }
コード例 #20
0
        public void Hexopyranose()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("O", 1, 0.00d, 2.48d));
            m.Atoms.Add(Atom("C", 2, 0.71d, 2.06d));
            m.Atoms.Add(Atom("C", 1, 0.71d, 1.24d));
            m.Atoms.Add(Atom("O", 0, 1.43d, 0.82d));
            m.Atoms.Add(Atom("C", 1, 1.43d, -0.00d));
            m.Atoms.Add(Atom("O", 1, 2.14d, -0.41d));
            m.Atoms.Add(Atom("C", 1, 0.71d, -0.41d));
            m.Atoms.Add(Atom("O", 1, 0.71d, -1.24d));
            m.Atoms.Add(Atom("C", 1, -0.00d, 0.00d));
            m.Atoms.Add(Atom("O", 1, -0.71d, -0.41d));
            m.Atoms.Add(Atom("C", 1, 0.00d, 0.83d));
            m.Atoms.Add(Atom("O", 1, -0.71d, 1.24d));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[6], m.Atoms[7], BondOrder.Single);
            m.AddBond(m.Atoms[6], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[9], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[10], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[10], BondOrder.Single);
            m.AddBond(m.Atoms[10], m.Atoms[11], BondOrder.Single);
            EdgeToBondMap bondMap = EdgeToBondMap.WithSpaceFor(m);

            int[][] graph = GraphUtil.ToAdjList(m, bondMap);

            Stereocenters stereocenters = new Stereocenters(m, graph, bondMap);

            stereocenters.CheckSymmetry();
            CyclicCarbohydrateRecognition recon = new CyclicCarbohydrateRecognition(m, graph, bondMap,
                                                                                    stereocenters);

            Assert.IsTrue(recon.Recognise(new[] { Projection.Haworth }).Count() == 0);
        }
コード例 #21
0
        public void Mannitol()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 2, -0.53d, 6.25d));
            m.Atoms.Add(Atom("C", 1, -0.53d, 5.42d));
            m.Atoms.Add(Atom("O", 1, 0.18d, 6.66d));
            m.Atoms.Add(Atom("O", 1, -1.36d, 5.42d));
            m.Atoms.Add(Atom("C", 1, -0.53d, 4.60d));
            m.Atoms.Add(Atom("O", 1, -1.36d, 4.60d));
            m.Atoms.Add(Atom("C", 1, -0.53d, 3.77d));
            m.Atoms.Add(Atom("O", 1, 0.29d, 3.77d));
            m.Atoms.Add(Atom("C", 1, -0.53d, 2.95d));
            m.Atoms.Add(Atom("O", 1, 0.29d, 2.95d));
            m.Atoms.Add(Atom("C", 2, -0.53d, 2.12d));
            m.Atoms.Add(Atom("O", 1, 0.05d, 1.54d));
            m.AddBond(m.Atoms[0], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[1], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[5], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[6], m.Atoms[7], BondOrder.Single);
            m.AddBond(m.Atoms[6], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[9], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[10], BondOrder.Single);
            m.AddBond(m.Atoms[10], m.Atoms[11], BondOrder.Single);

            EdgeToBondMap bondMap = EdgeToBondMap.WithSpaceFor(m);

            int[][]            graph      = GraphUtil.ToAdjList(m, bondMap);
            FischerRecognition recogniser = new FischerRecognition(m,
                                                                   graph,
                                                                   bondMap,
                                                                   Stereocenters.Of(m));
            var elements = recogniser.Recognise(new[] { Projection.Fischer }).ToReadOnlyList();

            Assert.AreEqual(4, elements.Count);
            AssertTetrahedralCenter(elements[0],
                                    m.Atoms[1],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[0], m.Atoms[1], m.Atoms[4], m.Atoms[3]);
            AssertTetrahedralCenter(elements[1],
                                    m.Atoms[4],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[1], m.Atoms[4], m.Atoms[6], m.Atoms[5]);
            AssertTetrahedralCenter(elements[2],
                                    m.Atoms[6],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[4], m.Atoms[7], m.Atoms[8], m.Atoms[6]);
            AssertTetrahedralCenter(elements[3],
                                    m.Atoms[8],
                                    TetrahedralStereo.AntiClockwise,
                                    m.Atoms[6], m.Atoms[9], m.Atoms[10], m.Atoms[8]);

            m.SetStereoElements(elements);
        }
コード例 #22
0
        public void IgnoreCyclicStereocenters()
        {
            var m = new AtomContainer();

            m.Atoms.Add(Atom("C", 0, 6.87d, -5.59d));
            m.Atoms.Add(Atom("C", 0, 6.87d, -6.61d));
            m.Atoms.Add(Atom("C", 0, 7.82d, -5.62d));
            m.Atoms.Add(Atom("C", 0, 6.87d, -4.59d));
            m.Atoms.Add(Atom("O", 0, 8.18d, -6.34d));
            m.Atoms.Add(Atom("C", 0, 7.62d, -6.91d));
            m.Atoms.Add(Atom("C", 0, 5.90d, -5.59d));
            m.Atoms.Add(Atom("C", 0, 8.39d, -5.06d));
            m.Atoms.Add(Atom("C", 0, 5.60d, -4.80d));
            m.Atoms.Add(Atom("C", 2, 6.16d, -4.24d));
            m.Atoms.Add(Atom("O", 0, 8.22d, -4.29d));
            m.Atoms.Add(Atom("C", 2, 6.10d, -6.90d));
            m.Atoms.Add(Atom("C", 2, 5.54d, -6.29d));
            m.Atoms.Add(Atom("C", 2, 7.46d, -4.07d));
            m.Atoms.Add(Atom("O", 0, 7.79d, -7.72d));
            m.Atoms.Add(Atom("O", 0, 9.18d, -5.29d));
            m.Atoms.Add(Atom("O", 1, 6.87d, -7.44d));
            m.Atoms.Add(Atom("C", 3, 6.76d, -3.77d));
            m.Atoms.Add(Atom("C", 3, 4.82d, -5.07d));
            m.Atoms.Add(Atom("C", 3, 5.19d, -4.08d));
            m.Atoms.Add(Atom("H", 0, 8.64d, -5.76d));
            m.Atoms.Add(Atom("H", 0, 5.08d, -5.69d));
            m.AddBond(m.Atoms[1], m.Atoms[0], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[3], m.Atoms[0], BondOrder.Single);
            m.AddBond(m.Atoms[4], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[5], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[0], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[7], m.Atoms[2], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[9], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[10], m.Atoms[7], BondOrder.Single);
            m.AddBond(m.Atoms[11], m.Atoms[1], BondOrder.Single);
            m.AddBond(m.Atoms[12], m.Atoms[6], BondOrder.Single);
            m.AddBond(m.Atoms[13], m.Atoms[3], BondOrder.Single);
            m.AddBond(m.Atoms[14], m.Atoms[5], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[15], m.Atoms[7], BondOrder.Double, BondStereo.EZByCoordinates);
            m.AddBond(m.Atoms[1], m.Atoms[16], BondOrder.Single, BondStereo.Up);
            m.AddBond(m.Atoms[3], m.Atoms[17], BondOrder.Single, BondStereo.Up);
            m.AddBond(m.Atoms[18], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[19], m.Atoms[8], BondOrder.Single);
            m.AddBond(m.Atoms[2], m.Atoms[20], BondOrder.Single, BondStereo.Down);
            m.AddBond(m.Atoms[6], m.Atoms[21], BondOrder.Single, BondStereo.Down);
            m.AddBond(m.Atoms[5], m.Atoms[4], BondOrder.Single);
            m.AddBond(m.Atoms[11], m.Atoms[12], BondOrder.Single);
            m.AddBond(m.Atoms[10], m.Atoms[13], BondOrder.Single);
            m.AddBond(m.Atoms[8], m.Atoms[9], BondOrder.Single);

            EdgeToBondMap bondMap = EdgeToBondMap.WithSpaceFor(m);

            int[][]            graph      = GraphUtil.ToAdjList(m, bondMap);
            FischerRecognition recogniser = new FischerRecognition(m,
                                                                   graph,
                                                                   bondMap,
                                                                   Stereocenters.Of(m));

            Assert.IsTrue(recogniser.Recognise(new[] { Projection.Fischer }).Count() == 0);
        }