// minimum details


        /// <summary>  Partitions a RingSet into RingSets of connected rings. Rings which share
        /// an Atom, a Bond or three or more atoms with at least on other ring in
        /// the RingSet are considered connected.
        ///
        /// </summary>
        /// <param name="ringSet"> The RingSet to be partitioned
        /// </param>
        /// <returns>          A Vector of connected RingSets
        /// </returns>
        public static System.Collections.ArrayList partitionRings(IRingSet ringSet)
        {
            System.Collections.ArrayList ringSets = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
            if (ringSet.AtomContainerCount == 0)
            {
                return(ringSets);
            }
            IRingSet tempRingSet = null;
            IRing    ring        = (IRing)ringSet.getAtomContainer(0);

            if (ring == null)
            {
                return(ringSets);
            }
            IRingSet rs = ring.Builder.newRingSet();

            for (int f = 0; f < ringSet.AtomContainerCount; f++)
            {
                rs.addAtomContainer(ringSet.getAtomContainer(f));
            }
            do
            {
                ring = (IRing)rs.getAtomContainer(0);
                IRingSet newRs = ring.Builder.newRingSet();
                newRs.addAtomContainer(ring);
                tempRingSet = walkRingSystem(rs, ring, newRs);
                if (debug)
                {
                    System.Console.Out.WriteLine("found ringset with ringcount: " + tempRingSet.AtomContainerCount);
                }
                ringSets.Add(walkRingSystem(rs, ring, newRs));
            }while (rs.AtomContainerCount > 0);

            return(ringSets);
        }
Exemple #2
0
        private static IRingSet toRingSet(IAtomContainer ac, System.Collections.ICollection cycles)
        {
            IRingSet ringSet = ac.Builder.newRingSet();

            System.Collections.IEnumerator cycleIterator = cycles.GetEnumerator();

            while (cycleIterator.MoveNext())
            {
                SimpleCycle cycle = (SimpleCycle)cycleIterator.Current;

                IRing ring = ac.Builder.newRing();

                System.Collections.IList vertices = cycle.vertexList();

                IAtom[] atoms = new IAtom[vertices.Count];
                atoms[0] = (IAtom)vertices[0];
                for (int i = 1; i < vertices.Count; i++)
                {
                    atoms[i] = (IAtom)vertices[i];
                    ring.addElectronContainer(ac.getBond(atoms[i - 1], atoms[i]));
                }
                ring.addElectronContainer(ac.getBond(atoms[vertices.Count - 1], atoms[0]));
                ring.Atoms = atoms;

                ringSet.addAtomContainer(ring);
            }

            return(ringSet);
        }
        /// <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);
                }
            }
        }
 /// <summary> Sorts the rings in the set by size. The largest ring comes
 /// first.
 /// </summary>
 public static void sort(IRingSet ringSet)
 {
     System.Collections.IList ringList = new System.Collections.ArrayList();
     IAtomContainer[]         rings    = ringSet.AtomContainers;
     for (int i = 0; i < rings.Length; i++)
     {
         ringList.Add(rings[i]);
     }
     SupportClass.CollectionsSupport.Sort(ringList, new RingSizeComparator(RingSizeComparator.LARGE_FIRST));
     ringSet.removeAllAtomContainers();
     System.Collections.IEnumerator iter = ringList.GetEnumerator();
     //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
     while (iter.MoveNext())
     {
         //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
         ringSet.addAtomContainer((IRing)iter.Current);
     }
 }
 /// <summary> Sorts the rings in the set by size. The largest ring comes
 /// first.
 /// </summary>
 public static void sort(IRingSet ringSet)
 {
     System.Collections.IList ringList = new System.Collections.ArrayList();
     IAtomContainer[] rings = ringSet.AtomContainers;
     for (int i = 0; i < rings.Length; i++)
     {
         ringList.Add(rings[i]);
     }
     SupportClass.CollectionsSupport.Sort(ringList, new RingSizeComparator(RingSizeComparator.LARGE_FIRST));
     ringSet.removeAllAtomContainers();
     System.Collections.IEnumerator iter = ringList.GetEnumerator();
     //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
     while (iter.MoveNext())
     {
         //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
         ringSet.addAtomContainer((IRing)iter.Current);
     }
 }
        /// <summary>  Perform a walk in the given RingSet, starting at a given Ring and
        /// recursivly searching for other Rings connected to this ring. By doing
        /// this it finds all rings in the RingSet connected to the start ring,
        /// putting them in newRs, and removing them from rs.
        ///
        /// </summary>
        /// <param name="rs">    The RingSet to be searched
        /// </param>
        /// <param name="ring">  The ring to start with
        /// </param>
        /// <param name="newRs"> The RingSet containing all Rings connected to ring
        /// </param>
        /// <returns>        newRs The RingSet containing all Rings connected to ring
        /// </returns>
        private static IRingSet walkRingSystem(IRingSet rs, IRing ring, IRingSet newRs)
        {
            IRing tempRing;

            System.Collections.IList tempRings = rs.getConnectedRings(ring);
            if (debug)
            {
                System.Console.Out.WriteLine("walkRingSystem -> tempRings.size(): " + tempRings.Count);
            }
            rs.removeAtomContainer(ring);
            System.Collections.IEnumerator iter = tempRings.GetEnumerator();
            //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
            while (iter.MoveNext())
            {
                //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
                tempRing = (IRing)iter.Current;
                if (!newRs.contains(tempRing))
                {
                    newRs.addAtomContainer(tempRing);
                    newRs.add(walkRingSystem(rs, tempRing, newRs));
                }
            }
            return(newRs);
        }
 /// <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);
         }
     }
 }
 /// <summary>  Perform a walk in the given RingSet, starting at a given Ring and
 /// recursivly searching for other Rings connected to this ring. By doing
 /// this it finds all rings in the RingSet connected to the start ring,
 /// putting them in newRs, and removing them from rs.
 /// 
 /// </summary>
 /// <param name="rs">    The RingSet to be searched
 /// </param>
 /// <param name="ring">  The ring to start with
 /// </param>
 /// <param name="newRs"> The RingSet containing all Rings connected to ring
 /// </param>
 /// <returns>        newRs The RingSet containing all Rings connected to ring
 /// </returns>
 private static IRingSet walkRingSystem(IRingSet rs, IRing ring, IRingSet newRs)
 {
     IRing tempRing;
     System.Collections.IList tempRings = rs.getConnectedRings(ring);
     if (debug)
     {
         System.Console.Out.WriteLine("walkRingSystem -> tempRings.size(): " + tempRings.Count);
     }
     rs.removeAtomContainer(ring);
     System.Collections.IEnumerator iter = tempRings.GetEnumerator();
     //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'"
     while (iter.MoveNext())
     {
         //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'"
         tempRing = (IRing)iter.Current;
         if (!newRs.contains(tempRing))
         {
             newRs.addAtomContainer(tempRing);
             newRs.add(walkRingSystem(rs, tempRing, newRs));
         }
     }
     return newRs;
 }