/// <summary> We define the heaviest ring as the one with the highest number of double bonds. /// Needed for example for the placement of in-ring double bonds. /// /// </summary> /// <param name="bond"> A bond which must be contained by the heaviest ring /// </param> /// <returns> The ring with the higest number of double bonds connected to a given bond /// </returns> public static IRing getHeaviestRing(IRingSet ringSet, IBond bond) { System.Collections.IList rings = ringSet.getRings(bond); IRing ring = null; int maxOrderSum = 0; for (int i = 0; i < rings.Count; i++) { if (maxOrderSum < ((IRing)rings[i]).OrderSum) { ring = (IRing)rings[i]; maxOrderSum = ring.OrderSum; } } return(ring); }
private bool preprocessMolecule(IAtomContainer original) { //prepare atom weights var atomWeightCanBeCalculated = prepareAtomWeights(original); // If the SDF contains an "R" or something, we don't know its mass, so this whole endevour is fruitless // (since we won't be able to match the fragment masses to the peaks). if (!atomWeightCanBeCalculated) { return false; } //mark all the bonds and atoms with numbers --> identify them later on originalMolecule = markAllBonds(original); //do ring detection with the original molecule var allRingsFinder = new AllRingsFinder(); // Steve: Set a really large timeout, because we don't want to crash just because it took a long time. // The size limit of 7 below should stop it looping forever. allRingsFinder.setTimeout(int.MaxValue); // TODO: Steve: The 7 is a max ring size - I added this to prevent it getting in to infinite loops (7 comes from MetFrag // where it is used in some other random class). Don't know if we need to change this?? allRings = allRingsFinder.findAllRings(originalMolecule, Integer.valueOf(7)); aromaticBonds = new List<IBond>(); CDKHueckelAromaticityDetector.detectAromaticity(originalMolecule); foreach (var bond in originalMolecule.bonds().ToWindowsEnumerable<IBond>()) { //lets see if it is a ring and aromatic var rings = allRings.getRings(bond); //don't split up aromatic rings...see constructor for option for (var i = 0; i < rings.getAtomContainerCount(); i++) { var aromatic = AromaticityCalculator.isAromatic((IRing)rings.getAtomContainer(i), originalMolecule); if (aromatic) { aromaticBonds.Add(bond); break; } } } return true; }
/// <summary> We define the heaviest ring as the one with the highest number of double bonds. /// Needed for example for the placement of in-ring double bonds. /// /// </summary> /// <param name="bond"> A bond which must be contained by the heaviest ring /// </param> /// <returns> The ring with the higest number of double bonds connected to a given bond /// </returns> public static IRing getHeaviestRing(IRingSet ringSet, IBond bond) { System.Collections.IList rings = ringSet.getRings(bond); IRing ring = null; int maxOrderSum = 0; for (int i = 0; i < rings.Count; i++) { if (maxOrderSum < ((IRing)rings[i]).OrderSum) { ring = (IRing)rings[i]; maxOrderSum = ring.OrderSum; } } return ring; }