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 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); } }