Ejemplo n.º 1
0
        public void TestDetectNaphtalene()
        {
            Trace.TraceInformation("Entering testDetectNaphtalene.");
            IAtomContainer mol      = null;
            var            filename = "NCDK.Data.CML.naphtalene.cml";

            mol = ReadCMLMolecule(filename);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);

            var acSet = ConjugatedPiSystemsDetector.Detect(mol);

            Assert.AreEqual(1, acSet.Count);
            IAtomContainer ac = acSet[0];

            Assert.AreEqual(10, ac.Atoms.Count);
            Assert.AreEqual(11, ac.Bonds.Count);

            for (int i = 0; i < ac.Atoms.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac.Atoms[i]));
            }

            for (int i = 0; i < ac.Bonds.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac.Bonds[i]));
            }
        }
Ejemplo n.º 2
0
        public void TestCyanoallene()
        {
            IAtomContainer mol = null;

            mol = CDK.SmilesParser.ParseSmiles("C=C=CC#N");
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            AddImplicitHydrogens(mol);
            CDK.LonePairElectronChecker.Saturate(mol);
            Aromaticity.CDKLegacy.Apply(mol);

            var acSet = ConjugatedPiSystemsDetector.Detect(mol);

            Assert.AreEqual(1, acSet.Count);
            IAtomContainer ac1 = acSet[0];

            Assert.AreEqual(4, ac1.Atoms.Count);
            Assert.AreEqual(3, ac1.Bonds.Count);

            for (int i = 0; i < ac1.Atoms.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac1.Atoms[i]));
            }

            for (int i = 0; i < ac1.Bonds.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac1.Bonds[i]));
            }
        }
Ejemplo n.º 3
0
        public void TestChargeWithProtonImplicit()
        {
            var sp  = CDK.SmilesParser;
            var mol = sp.ParseSmiles("C=C[C+]");

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            CDK.LonePairElectronChecker.Saturate(mol);
            Aromaticity.CDKLegacy.Apply(mol);

            var acSet = ConjugatedPiSystemsDetector.Detect(mol);

            Assert.AreEqual(1, acSet.Count);
            IAtomContainer ac1 = acSet[0];

            Assert.AreEqual(3, ac1.Atoms.Count);
            Assert.AreEqual(2, ac1.Bonds.Count);

            for (int i = 0; i < ac1.Atoms.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac1.Atoms[i]));
            }

            for (int i = 0; i < ac1.Bonds.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac1.Bonds[i]));
            }
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            {
                var mol = new AtomContainer();
                #region Detect
                Atom a0 = new Atom("C"); mol.Atoms.Add(a0);
                Atom a1 = new Atom("C"); mol.Atoms.Add(a1);
                Atom a2 = new Atom("C"); mol.Atoms.Add(a2);
                Atom h1 = new Atom("H"); mol.Atoms.Add(h1);
                Atom h2 = new Atom("H"); mol.Atoms.Add(h2);
                Atom h3 = new Atom("H"); mol.Atoms.Add(h3);
                Atom h4 = new Atom("H"); mol.Atoms.Add(h4);
                Atom h5 = new Atom("H"); mol.Atoms.Add(h5);
                mol.AddBond(a0, a1, BondOrder.Double);
                mol.AddBond(a1, a2, BondOrder.Single);
                mol.AddBond(a0, h1, BondOrder.Single);
                mol.AddBond(a0, h2, BondOrder.Single);
                mol.AddBond(a1, h3, BondOrder.Single);
                mol.AddBond(a2, h4, BondOrder.Single);
                mol.AddBond(a2, h5, BondOrder.Single);
                SingleElectron se = new SingleElectron(a2);
                mol.Add(se);

                var pi_systems = ConjugatedPiSystemsDetector.Detect(mol);
                #endregion
            }
        }
Ejemplo n.º 5
0
        public void TestPiSystemWithCarbokation()
        {
            Trace.TraceInformation("Entering testPiSystemWithCarbokation.");
            IAtomContainer mol      = null;
            var            filename = "NCDK.Data.MDL.piSystemWithCarbokation.mol";
            var            ins      = ResourceLoader.GetAsStream(filename);
            MDLReader      reader   = new MDLReader(ins);
            var            chemFile = reader.Read(builder.NewChemFile());

            mol = chemFile[0][0].MoleculeSet[0];

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            Aromaticity.CDKLegacy.Apply(mol);

            var acSet = ConjugatedPiSystemsDetector.Detect(mol);

            Assert.AreEqual(2, acSet.Count);
            IAtomContainer ac1 = acSet[0];

            Assert.AreEqual(4, ac1.Atoms.Count);
            Assert.AreEqual(3, ac1.Bonds.Count);

            for (int i = 0; i < ac1.Atoms.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac1.Atoms[i]));
            }

            for (int i = 0; i < ac1.Bonds.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac1.Bonds[i]));
            }

            IAtomContainer ac2 = acSet[0];

            Assert.AreEqual(4, ac2.Atoms.Count);
            Assert.AreEqual(3, ac2.Bonds.Count);

            for (int i = 0; i < ac2.Atoms.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac2.Atoms[i]));
            }

            for (int i = 0; i < ac2.Bonds.Count; i++)
            {
                Assert.IsTrue(mol.Contains(ac2.Bonds[i]));
            }
        }
Ejemplo n.º 6
0
        public void Test1_fluorobutadienene()
        {
            IAtomContainer mol = CDK.SmilesParser.ParseSmiles("FC=CC=C");

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            AddImplicitHydrogens(mol);
            CDK.LonePairElectronChecker.Saturate(mol);
            Aromaticity.CDKLegacy.Apply(mol);

            var acSet = ConjugatedPiSystemsDetector.Detect(mol);

            Assert.AreEqual(1, acSet.Count);
            IAtomContainer ac1 = acSet[0];

            Assert.AreEqual(5, ac1.Atoms.Count);
            Assert.AreEqual(4, ac1.Bonds.Count);
        }
Ejemplo n.º 7
0
        public void Test3Aminomethane_cation()
        {
            var builder = CDK.Builder;
            var mol     = builder.NewAtomContainer();

            mol.Atoms.Add(builder.NewAtom("N"));
            mol.Atoms.Add(builder.NewAtom("C"));
            mol.AddBond(mol.Atoms[0], mol.Atoms[1], BondOrder.Single);
            mol.Atoms.Add(builder.NewAtom("C"));
            mol.AddBond(mol.Atoms[0], mol.Atoms[2], BondOrder.Single);
            mol.Atoms.Add(builder.NewAtom("C"));
            mol.AddBond(mol.Atoms[0], mol.Atoms[3], BondOrder.Single);
            mol.Atoms[3].FormalCharge = +1;
            mol.Atoms.Add(builder.NewAtom("N"));
            mol.AddBond(mol.Atoms[3], mol.Atoms[4], BondOrder.Single);
            mol.Atoms.Add(builder.NewAtom("C"));
            mol.AddBond(mol.Atoms[4], mol.Atoms[5], BondOrder.Single);
            mol.Atoms.Add(builder.NewAtom("C"));
            mol.AddBond(mol.Atoms[4], mol.Atoms[6], BondOrder.Single);
            mol.Atoms.Add(builder.NewAtom("N"));
            mol.AddBond(mol.Atoms[3], mol.Atoms[7], BondOrder.Single);
            mol.Atoms.Add(builder.NewAtom("C"));
            mol.AddBond(mol.Atoms[7], mol.Atoms[8], BondOrder.Single);
            mol.Atoms.Add(builder.NewAtom("C"));
            mol.AddBond(mol.Atoms[7], mol.Atoms[8], BondOrder.Single);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            AddImplicitHydrogens(mol);
            CDK.LonePairElectronChecker.Saturate(mol);
            Aromaticity.CDKLegacy.Apply(mol);

            var acSet = ConjugatedPiSystemsDetector.Detect(mol);

            Assert.AreEqual(1, acSet.Count);
            IAtomContainer ac1 = acSet[0];

            Assert.AreEqual(4, ac1.Atoms.Count);
            Assert.AreEqual(3, ac1.Bonds.Count);
        }
Ejemplo n.º 8
0
        public void TestNN_dimethylaniline_cation()
        {
            IAtomContainer mol      = null;
            var            filename = "NCDK.Data.MDL.NN_dimethylaniline.mol";
            var            ins      = ResourceLoader.GetAsStream(filename);
            var            reader   = new MDLV2000Reader(ins);
            var            chemFile = reader.Read(builder.NewChemFile());

            mol = chemFile[0][0].MoleculeSet[0];

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            AddImplicitHydrogens(mol);
            CDK.LonePairElectronChecker.Saturate(mol);
            Aromaticity.CDKLegacy.Apply(mol);

            var acSet = ConjugatedPiSystemsDetector.Detect(mol);

            Assert.AreEqual(1, acSet.Count);
            IAtomContainer ac1 = acSet[0];

            Assert.AreEqual(6, ac1.Atoms.Count);
            Assert.AreEqual(5, ac1.Bonds.Count);
        }