コード例 #1
0
        public void GasteigerChargeTest()
        {
            var mol        = new MolReader(FileNames.BenzeneFilePath).GetMol();
            var chargedMol = mol.AssignGasteigerCharges();

            Assert.IsTrue(chargedMol.Atoms().Count() > 0);
            foreach (var atom in chargedMol.Atoms())
            {
                if (atom.IsCarbon())
                {
                    Assert.AreEqual(-0.0618, Math.Round(atom.GetPartialCharge(), 4));
                }
                else
                {
                    Assert.AreEqual(0.0618, Math.Round(atom.GetPartialCharge(), 4));
                }
            }

            mol        = new MolReader(FileNames.PropaneFilePath).GetMol();
            chargedMol = mol.AssignGasteigerCharges();
            Assert.IsTrue(chargedMol.Atoms().Count() > 0);
            foreach (var atom in chargedMol.Atoms())
            {
                if (atom.IsCarbon() && (atom.GetIdx() == 1 || atom.GetIdx() == 3))
                {
                    Assert.AreEqual(-0.0655, Math.Round(atom.GetPartialCharge(), 4));
                }
                else if (atom.IsCarbon() && atom.GetIdx() == 2)
                {
                    Assert.AreEqual(-0.0588, Math.Round(atom.GetPartialCharge(), 4));
                }
                else if (atom.IsHydrogen() && atom.Neighbors().First().IsCarbon() && (atom.Neighbors().First().GetIdx() == 1 || atom.Neighbors().First().GetIdx() == 3))
                {
                    Assert.AreEqual(0.0230, Math.Round(atom.GetPartialCharge(), 4));
                }
                else if (atom.IsHydrogen() && atom.Neighbors().First().IsCarbon() && atom.Neighbors().First().GetIdx() == 2)
                {
                    Assert.AreEqual(0.0260, Math.Round(atom.GetPartialCharge(), 4));
                }
            }
        }
コード例 #2
0
        public void FormalChargeTest()
        {
            var mol = new MolReader(FileNames.AceticAcidFilePath).GetMol();

            this._descriptor = new MolDescriptor(mol);
            Assert.AreEqual(0, this._descriptor.TotalCharge);

            var newMol = mol.AssignGasteigerCharges();

            Assert.AreEqual(0, Math.Round(newMol.Atoms().Sum(a => a.GetPartialCharge()), 4));

            mol = new MolReader(FileNames.AcetateFilePath).GetMol();
            this._descriptor = new MolDescriptor(mol);
            Assert.AreEqual(-1, this._descriptor.TotalCharge);

            newMol           = mol.AssignGasteigerCharges();
            this._descriptor = new MolDescriptor(newMol);
            Assert.AreEqual(-1, Math.Round(newMol.Atoms().Sum(a => a.GetPartialCharge()), 4));

            mol = new MolReader(FileNames.CyclosporineFilePath).GetMol();
            this._descriptor = new MolDescriptor(mol);
            Assert.AreEqual(0d, Math.Round(this._descriptor.TotalCharge, 4));
        }