/// <summary> /// Get the topological weight factor for each atomContainer. /// </summary> /// <param name="atomContainer">The IAtomContainer to study.</param> /// <param name="ac">The IAtomContainer to study.</param> /// <returns>The value</returns> private static double GetTopologicalFactors(IAtomContainer atomContainer, IAtomContainer ac) { /* factor for separation of charge */ int totalNCharge1 = AtomContainerManipulator.GetTotalNegativeFormalCharge(atomContainer); int totalPCharge1 = AtomContainerManipulator.GetTotalPositiveFormalCharge(atomContainer); double fQ = 1.0; if (totalNCharge1 != 0.0) { fQ = 0.5; for (int i = 0; i < atomContainer.Bonds.Count; i++) { IBond bond = atomContainer.Bonds[i]; if (bond.Atoms[0].FormalCharge != 0.0 && bond.Atoms[1].FormalCharge != 0.0) { fQ = 0.25; break; } } } /* factor, if the number of covalents bonds is decreased */ double fB = 1.0; int numBond1 = 0; int numBond2 = 0; for (int i = 0; i < atomContainer.Bonds.Count; i++) { if (atomContainer.Bonds[i].Order == BondOrder.Double) { numBond1 += 1; } if (ac.Bonds[i].Order == BondOrder.Double) { numBond2 += 1; } } if (numBond1 < /* > */ numBond2) { fB = 0.8; } double fPlus = 1.0; if (totalNCharge1 == 0.0 && totalPCharge1 == 0.0) { fPlus = 0.1; } /* aromatic */ double fA = 1.0; try { if (Aromaticity.CDKLegacy.Apply(ac)) { if (!Aromaticity.CDKLegacy.Apply(atomContainer)) { fA = 0.3; } } } catch (CDKException e) { Console.Out.WriteLine(e.StackTrace); } Debug.WriteLine("return " + fQ * fB * fPlus * fA + "= sp:" + fQ + ", dc:" + fB + ", fPlus:" + fPlus + ", fA:" + fA); return(fQ * fB * fPlus * fA); }