コード例 #1
0
        public void RadicalCanon()
        {
            var builder = CDK.Builder;

            IAtomContainer mola = builder.NewAtomContainer();

            mola.Atoms.Add(builder.NewAtom("CH3"));
            mola.Atoms.Add(builder.NewAtom("CH2"));
            mola.Atoms.Add(builder.NewAtom("CH2"));
            mola.Atoms.Add(builder.NewAtom("CH2"));
            mola.Atoms.Add(builder.NewAtom("CH2"));
            mola.Atoms.Add(builder.NewAtom("CH1"));
            mola.Atoms.Add(builder.NewAtom("CH3"));
            mola.AddBond(mola.Atoms[1], mola.Atoms[2], BondOrder.Single);
            mola.AddBond(mola.Atoms[2], mola.Atoms[3], BondOrder.Single);
            mola.AddBond(mola.Atoms[3], mola.Atoms[4], BondOrder.Single);
            mola.AddBond(mola.Atoms[4], mola.Atoms[5], BondOrder.Single);
            mola.AddBond(mola.Atoms[5], mola.Atoms[6], BondOrder.Single);
            mola.AddBond(mola.Atoms[0], mola.Atoms[5], BondOrder.Single);
            mola.AddSingleElectronTo(mola.Atoms[1]);

            SmilesParser    smipar = new SmilesParser(builder);
            var             molb   = smipar.ParseSmiles("CC(CCC[CH2])C |^1:5|");
            SmilesGenerator smigen = new SmilesGenerator(SmiFlavors.Canonical | SmiFlavors.CxRadical);

            Assert.AreEqual(smigen.Create(molb), smigen.Create(mola));
        }
コード例 #2
0
        public void TestCompareIonized()
        {
            var molA = CDK.Builder.NewAtomContainer();

            molA.Atoms.Add(CDK.Builder.NewAtom("C"));
            molA.Atoms.Add(CDK.Builder.NewAtom("C"));
            molA.AddBond(molA.Atoms[0], molA.Atoms[1], BondOrder.Single);
            molA.Atoms.Add(CDK.Builder.NewAtom("C"));
            molA.AddBond(molA.Atoms[1], molA.Atoms[2], BondOrder.Single);
            molA.Atoms.Add(CDK.Builder.NewAtom("Cl"));
            molA.AddBond(molA.Atoms[2], molA.Atoms[3], BondOrder.Single);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molA);
            AddExplicitHydrogens(molA);
            CDK.LonePairElectronChecker.Saturate(molA);

            PiElectronegativityDescriptor descriptor;

            descriptor = CreateDescriptor(molA);
            var resultA = descriptor.Calculate(molA.Atoms[3]).Value;

            IAtomContainer molB = CDK.Builder.NewAtomContainer();

            molB.Atoms.Add(CDK.Builder.NewAtom("C"));
            molB.Atoms.Add(CDK.Builder.NewAtom("C"));
            molB.AddBond(molB.Atoms[0], molB.Atoms[1], BondOrder.Single);
            molB.Atoms.Add(CDK.Builder.NewAtom("C"));
            molB.AddBond(molB.Atoms[1], molB.Atoms[2], BondOrder.Single);
            molB.Atoms.Add(CDK.Builder.NewAtom("Cl"));
            molB.Atoms[3].FormalCharge = 1;
            molB.AddSingleElectronTo(molB.Atoms[3]);
            molB.AddLonePairTo(molB.Atoms[3]);
            molB.AddLonePairTo(molB.Atoms[3]);
            molB.AddBond(molB.Atoms[2], molB.Atoms[3], BondOrder.Single);

            AddExplicitHydrogens(molB);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molB);
            CDK.LonePairElectronChecker.Saturate(molB);

            Assert.AreEqual(1, molB.Atoms[3].FormalCharge.Value, 0.00001);
            Assert.AreEqual(1, molB.SingleElectrons.Count, 0.00001);
            Assert.AreEqual(2, molB.LonePairs.Count, 0.00001);

            descriptor = CreateDescriptor(molB);
            var resultB = descriptor.Calculate(molB.Atoms[3]).Value;

            Assert.AreEqual(resultA, resultB, 0.00001);
        }