public void TestAromaticAndNonAromatic()
        {
            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();

            string smiles1 = "c1ccccc1";
            string smiles2 = "C1=CC=CC=C1";

            var sp   = CDK.SmilesParser;
            var mol1 = sp.ParseSmiles(smiles1);
            var mol2 = sp.ParseSmiles(smiles2);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2);
            Aromaticity.CDKLegacy.Apply(mol1);
            Aromaticity.CDKLegacy.Apply(mol2);

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

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

            peoe.CalculateCharges(mol1);
            peoe.CalculateCharges(mol2);
            for (int i = 0; i < mol1.Atoms.Count; i++)
            {
                Assert.AreEqual(mol1.Atoms[i].Charge.Value, mol2.Atoms[i].Charge.Value, 0.01, "charge on atom " + i + " does not match");
            }
        }
        public void TestAromaticBondOrders()
        {
            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();

            string smiles1 = "c1ccccc1";
            var    sp      = CDK.SmilesParser;
            var    mol1    = sp.ParseSmiles(smiles1);

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

            List <bool> oldBondOrders = new List <bool>();

            for (int i = 0; i < mol1.Bonds.Count; i++)
            {
                oldBondOrders.Add(mol1.Bonds[i].IsAromatic);
            }

            peoe.CalculateCharges(mol1);

            List <bool> newBondOrders = new List <bool>();

            for (int i = 0; i < mol1.Bonds.Count; i++)
            {
                newBondOrders.Add(mol1.Bonds[i].IsAromatic);
            }

            for (int i = 0; i < oldBondOrders.Count; i++)
            {
                Assert.AreEqual(oldBondOrders[i], newBondOrders[i], "bond " + i + " does not match");
            }
        }
        public void TestAssignrPiMarsilliFactors_IAtomContainerSet()
        {
            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();

            IAtomContainer molecule = builder.NewAtomContainer();

            molecule.Atoms.Add(builder.NewAtom("C"));
            molecule.Atoms.Add(builder.NewAtom("F"));
            molecule.AddBond(molecule.Atoms[0], molecule.Atoms[1], BondOrder.Single);

            AddExplicitHydrogens(molecule);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molecule);
            CDK.LonePairElectronChecker.Saturate(molecule);
            foreach (var atom in molecule.Atoms)
            {
                atom.Charge = 0;
            }

            var set = builder.NewAtomContainerSet();

            set.Add(molecule);
            set.Add(molecule);

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

            Assert.IsNotNull(peoe.AssignrPiMarsilliFactors(set));
        }
 /// <summary>
 /// Constructor for the Electronegativity object.
 /// </summary>
 /// <param name="maxIterations">The maximal number of Iteration</param>
 /// <param name="maxResonStruc">The maximal number of Resonance Structures</param>
 public PiElectronegativity(int maxIterations, int maxResonStruc)
 {
     peoe                   = new GasteigerMarsiliPartialCharges();
     pepe                   = new GasteigerPEPEPartialCharges();
     MaxIterations          = maxIterations;
     MaxResonanceStructures = maxResonStruc;
 }
        public void TestSetStepSize()
        {
            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();
            int StepSize = 22;

            peoe.StepSize = StepSize;
            Assert.AreEqual(StepSize, peoe.StepSize);
        }
        public void TestSetMaxResoStruc_Int()
        {
            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();
            int MX_RESON = 1;

            peoe.MaxResonanceStructures = MX_RESON;
            Assert.AreEqual(MX_RESON, peoe.MaxResonanceStructures);
        }
        public void TestSetMaxGasteigerIters_Double()
        {
            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();
            int MX_ITERATIONS = 10;

            peoe.MaxGasteigerIterations = MX_ITERATIONS;
            Assert.AreEqual(MX_ITERATIONS, peoe.MaxGasteigerIterations);
        }
        public void TestCalculateCharges_IAtomContainer()
        {
            double[] testResult = { 0.0, 0.0, 0.0, 0.0, 0.0 };

            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();

            IAtomContainer molecule = builder.NewAtomContainer();

            molecule.Atoms.Add(builder.NewAtom("C"));
            molecule.Atoms.Add(builder.NewAtom("F"));
            molecule.AddBond(molecule.Atoms[0], molecule.Atoms[1], BondOrder.Single);

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

            peoe.CalculateCharges(molecule);
            for (int i = 0; i < molecule.Atoms.Count; i++)
            {
                //Debug.WriteLine("Charge for atom:"+i+" S:"+mol.GetAtomAt(i).Symbol+" Charge:"+mol.GetAtomAt(i).Charge);
                Assert.AreEqual(testResult[i], molecule.Atoms[i].Charge.Value, 0.01);
            }
        }
        public void TestGetStepSize()
        {
            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();

            Assert.AreEqual(5, peoe.StepSize);
        }
        public void TestGetMaxResoStruc()
        {
            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();

            Assert.AreEqual(50, peoe.MaxResonanceStructures);
        }
        public void TestGetMaxGasteigerIters()
        {
            GasteigerPEPEPartialCharges peoe = new GasteigerPEPEPartialCharges();

            Assert.AreEqual(8, peoe.MaxGasteigerIterations);
        }