/// <summary> Checks the pathes if a ring has been found /// /// </summary> /// <param name="pathes"> The pathes to check for rings /// </param> /// <param name="ringSet"> The ringset to add the detected rings to /// </param> /// <param name="ac"> The AtomContainer with the original structure /// </param> private void detectRings(System.Collections.ArrayList pathes, IRingSet ringSet, IAtomContainer ac) { Path path = null; IRing ring = null; IBond bond = null; for (int f = 0; f < pathes.Count; f++) { path = (Path)pathes[f]; if (path.Count > 3 && path[path.Count - 1] == path[0]) { if (debug) { System.Console.Out.WriteLine("Removing path " + path.toString(originalAc) + " which is a ring."); } path.RemoveAt(0); ring = ac.Builder.newRing(); for (int g = 0; g < path.Count; g++) { ring.addAtom((IAtom)path[g]); } IBond[] bonds = ac.Bonds; for (int g = 0; g < bonds.Length; g++) { bond = bonds[g]; if (ring.contains(bond.getAtomAt(0)) && ring.contains(bond.getAtomAt(1))) { ring.addBond(bond); } } ringSet.addAtomContainer(ring); } } }
private IRing combineRings(IRingSet ringset, int i, int j) { int c = 0; for (int b = 0; b < cb[i].Length; b++) { c = cb[i][b] + cb[j][b]; if (c > 1) { break; //at least one common bond } } if (c < 2) { return(null); } IRing ring = molecule.Builder.newRing(); IRing ring1 = (IRing)ringset.getAtomContainer(i); IRing ring2 = (IRing)ringset.getAtomContainer(j); for (int b = 0; b < cb[i].Length; b++) { c = cb[i][b] + cb[j][b]; if ((c == 1) && (cb[i][b] == 1)) { ring.addBond(molecule.getBondAt(b)); } else if ((c == 1) && (cb[j][b] == 1)) { ring.addBond(molecule.getBondAt(b)); } } for (int a = 0; a < ring1.AtomCount; a++) { ring.addAtom(ring1.getAtomAt(a)); } for (int a = 0; a < ring2.AtomCount; a++) { ring.addAtom(ring2.getAtomAt(a)); } return(ring); }
private IRing getRing(IAtomContainer spt, IBond bond) { IRing ring = spt.Builder.newRing(); PathTools.resetFlags(spt); ring.addAtom(bond.getAtomAt(0)); PathTools.depthFirstTargetSearch(spt, bond.getAtomAt(0), bond.getAtomAt(1), ring); ring.addBond(bond); return(ring); }