private void UpdateElectronCount(BondOrder order) { if (order == BondOrder.Unset) { return; } this.ElectronCount = order.Numeric() * 2; }
/// <summary> /// Get the single bond equivalent (SBE) of a list of bonds, given an iterator to the list. /// </summary> /// <param name="bonds">An iterator to the list of bonds</param> /// <returns>The SBE sum</returns> public static int GetSingleBondEquivalentSum(IEnumerable <IBond> bonds) { int sum = 0; foreach (var bond in bonds) { BondOrder order = bond.Order; if (!order.IsUnset()) { sum += order.Numeric(); } } return(sum); }
private void SetTargetSingleAtomMap(bool removeHydrogen) { int counter = 0; BondEnergies be = BondEnergies.Instance; foreach (var targetAtom in target.Atoms) { if ((removeHydrogen && !targetAtom.AtomicNumber.Equals(AtomicNumbers.H)) || (!removeHydrogen)) { foreach (var sourceAtoms in source.Atoms) { var mapAtoms = new Dictionary <IAtom, IAtom>(); if (string.Equals(targetAtom.Symbol, sourceAtoms.Symbol, StringComparison.OrdinalIgnoreCase)) { mapAtoms[sourceAtoms] = targetAtom; var bonds = source.GetConnectedBonds(sourceAtoms); double totalOrder = 0; foreach (var bond in bonds) { BondOrder order = bond.Order; totalOrder += order.Numeric() + BondEnergies.GetEnergies(bond); } if (sourceAtoms.FormalCharge != targetAtom.FormalCharge) { totalOrder += 0.5; } connectedBondOrder[counter] = totalOrder; mappings.Insert(counter++, mapAtoms); } } } else { Console.Error.WriteLine("Skipping Hydrogen mapping or This is not a single mapping case!"); } } }
private void SetSourceSingleAtomMap(IQueryAtomContainer source, bool removeHydrogen) { int counter = 0; BondEnergies be = BondEnergies.Instance; foreach (var sourceAtom in source.Atoms) { var smartAtom = (IQueryAtom)sourceAtom; if ((removeHydrogen && !smartAtom.AtomicNumber.Equals(AtomicNumbers.H)) || (!removeHydrogen)) { foreach (var targetAtom in target.Atoms) { var mapAtoms = new Dictionary <IAtom, IAtom>(); if (smartAtom.Matches(targetAtom)) { mapAtoms[sourceAtom] = targetAtom; var bonds = target.GetConnectedBonds(targetAtom); double totalOrder = 0; foreach (var bond in bonds) { BondOrder order = bond.Order; totalOrder += order.Numeric() + BondEnergies.GetEnergies(bond); } if (targetAtom.FormalCharge != sourceAtom.FormalCharge) { totalOrder += 0.5; } connectedBondOrder[counter] = totalOrder; mappings.Insert(counter++, mapAtoms); } } } else { Console.Error.WriteLine("Skipping Hydrogen mapping or This is not a single mapping case!"); } } }
/// <summary> /// Returns the number of times the side chain should end up as the CIP-expanded ligand list. The CIP /// rules prescribe that a double bonded oxygen should be represented twice in the list. /// </summary> /// <param name="order"><see cref="BondOrder"/> of the bond</param> /// <returns>int reflecting the duplication number</returns> private static int GetDuplication(BondOrder order) { return(order.Numeric()); }
public static double[] GetAtomWeights(IAtomContainer atomContainer) { IAtom atom, headAtom, endAtom; int headAtomPosition, endAtomPosition; //int k = 0; double[] weightArray = new double[atomContainer.Atoms.Count]; double[][] adjaMatrix = ConnectionMatrix.GetMatrix(atomContainer); int[][] apspMatrix = PathTools.ComputeFloydAPSP(adjaMatrix); int[] atomLayers = GetAtomLayers(apspMatrix); int[] valenceSum; int[] interLayerBondSum; Debug.WriteLine("adjacency matrix: "); DisplayMatrix(adjaMatrix); Debug.WriteLine("all-pairs-shortest-path matrix: "); DisplayMatrix(apspMatrix); Debug.WriteLine("atom layers: "); DisplayArray(atomLayers); for (int i = 0; i < atomContainer.Atoms.Count; i++) { atom = atomContainer.Atoms[i]; valenceSum = new int[atomLayers[i]]; for (int v = 0; v < valenceSum.Length; v++) { valenceSum[v] = 0; } interLayerBondSum = new int[atomLayers[i] - 1]; for (int v = 0; v < interLayerBondSum.Length; v++) { interLayerBondSum[v] = 0; } //weightArray[k] = atom.GetValenceElectronsCount() - atom.GetHydrogenCount(); // method unfinished if (AtomicNumbers.O.Equals(atom.AtomicNumber)) { weightArray[i] = 6 - atom.ImplicitHydrogenCount.Value; } else { weightArray[i] = 4 - atom.ImplicitHydrogenCount.Value; } for (int j = 0; j < apspMatrix.Length; j++) { if (string.Equals("O", atomContainer.Atoms[j].Symbol, StringComparison.Ordinal)) { valenceSum[apspMatrix[j][i]] += 6 - atomContainer.Atoms[j].ImplicitHydrogenCount.Value; } else { valenceSum[apspMatrix[j][i]] += 4 - atomContainer.Atoms[j].ImplicitHydrogenCount.Value; } } var bonds = atomContainer.Bonds; foreach (var bond in bonds) { headAtom = bond.Begin; endAtom = bond.End; headAtomPosition = atomContainer.Atoms.IndexOf(headAtom); endAtomPosition = atomContainer.Atoms.IndexOf(endAtom); if (Math.Abs(apspMatrix[i][headAtomPosition] - apspMatrix[i][endAtomPosition]) == 1) { int min = Math.Min(apspMatrix[i][headAtomPosition], apspMatrix[i][endAtomPosition]); BondOrder order = bond.Order; interLayerBondSum[min] += order.IsUnset() ? 0 : order.Numeric(); } } for (int j = 0; j < interLayerBondSum.Length; j++) { weightArray[i] += interLayerBondSum[j] * valenceSum[j + 1] * Math.Pow(10, -(j + 1)); } Debug.WriteLine("valence sum: "); DisplayArray(valenceSum); Debug.WriteLine("inter-layer bond sum: "); DisplayArray(interLayerBondSum); } Debug.WriteLine("weight array: "); DisplayArray(weightArray); return(weightArray); }
public static double DestroyBondOrder(BondOrder bondOrder) { return(bondOrder.Numeric()); }