Exemple #1
0
        public virtual IAtomContainer getSpanningTree()
        {
            IAtomContainer ac = molecule.Builder.newAtomContainer();

            for (int a = 0; a < V; a++)
            {
                ac.addAtom(molecule.getAtomAt(a));
            }
            for (int b = 0; b < E; b++)
            {
                if (bondsInTree[b])
                {
                    ac.addBond(molecule.getBondAt(b));
                }
            }
            return(ac);
        }
        /// <summary> Kruskal algorithm</summary>
        /// <param name="atomContainer">
        /// </param>
        public virtual void buildSpanningTree(IAtomContainer atomContainer)
        {
            disconnected = false;
            molecule = atomContainer;

            V = atomContainer.AtomCount;
            E = atomContainer.getBondCount();

            sptSize = 0; edrSize = 0;
            fastFindInit(V);
            for (int i = 0; i < V; i++)
            {
                (atomContainer.getAtomAt(i)).setProperty("ST_ATOMNO", System.Convert.ToString(i + 1));
            }
            IBond bond;
            int v1, v2;
            bondsInTree = new bool[E];

            for (int b = 0; b < E; b++)
            {
                bondsInTree[b] = false;
                bond = atomContainer.getBondAt(b);
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                v1 = System.Int32.Parse((bond.getAtomAt(0)).getProperty("ST_ATOMNO").ToString());
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                v2 = System.Int32.Parse((bond.getAtomAt(1)).getProperty("ST_ATOMNO").ToString());
                //this below is a little bit  slower
                //v1 = atomContainer.getAtomNumber(bond.getAtomAt(0))+1; 
                //v2 = atomContainer.getAtomNumber(bond.getAtomAt(1))+1;
                if (fastfind(v1, v2, true))
                {
                    bondsInTree[b] = true;
                    sptSize++;
                    //System.out.println("ST : includes bond between atoms "+v1+","+v2);
                }
                if (sptSize >= (V - 1))
                    break;
            }
            // if atomcontainer is connected then the number of bonds in the spanning tree = (No atoms-1)
            //i.e.  edgesRings = new Bond[E-V+1];
            //but to hold all bonds if atomContainer was disconnected then  edgesRings = new Bond[E-sptSize]; 
            if (sptSize != (V - 1))
                disconnected = true;
            for (int b = 0; b < E; b++)
                if (!bondsInTree[b])
                {
                    //			edgesRings[edrSize] = atomContainer.getBondAt(b);
                    edrSize++;
                }
            cb = new int[edrSize][];
            for (int i2 = 0; i2 < edrSize; i2++)
            {
                cb[i2] = new int[E];
            }
            for (int i = 0; i < edrSize; i++)
                for (int a = 0; a < E; a++)
                    cb[i][a] = 0;
        }
Exemple #3
0
        /// <summary>  Checks some simple heuristics for whether the subgraph query can
        /// realistically be a subgraph of the supergraph. If, for example, the
        /// number of nitrogen atoms in the query is larger than that of the supergraph
        /// it cannot be part of it.
        ///
        /// </summary>
        /// <param name="ac1"> the supergraph to be checked
        /// </param>
        /// <param name="ac2"> the subgraph to be tested for
        /// </param>
        /// <returns>    true if the subgraph ac2 has a chance to be a subgraph of ac1
        ///
        /// </returns>

        private static bool testSubgraphHeuristics(IAtomContainer ac1, IAtomContainer ac2)
        {
            int ac1SingleBondCount   = 0;
            int ac1DoubleBondCount   = 0;
            int ac1TripleBondCount   = 0;
            int ac1AromaticBondCount = 0;
            int ac2SingleBondCount   = 0;
            int ac2DoubleBondCount   = 0;
            int ac2TripleBondCount   = 0;
            int ac2AromaticBondCount = 0;
            int ac1SCount            = 0;
            int ac1OCount            = 0;
            int ac1NCount            = 0;
            int ac1FCount            = 0;
            int ac1ClCount           = 0;
            int ac1BrCount           = 0;
            int ac1ICount            = 0;
            int ac1CCount            = 0;

            int ac2SCount  = 0;
            int ac2OCount  = 0;
            int ac2NCount  = 0;
            int ac2FCount  = 0;
            int ac2ClCount = 0;
            int ac2BrCount = 0;
            int ac2ICount  = 0;
            int ac2CCount  = 0;

            IBond bond;
            IAtom atom;

            for (int i = 0; i < ac1.getBondCount(); i++)
            {
                bond = ac1.getBondAt(i);
                if (bond.getFlag(CDKConstants.ISAROMATIC))
                {
                    ac1AromaticBondCount++;
                }
                else if (bond.Order == 1)
                {
                    ac1SingleBondCount++;
                }
                else if (bond.Order == 2)
                {
                    ac1DoubleBondCount++;
                }
                else if (bond.Order == 3)
                {
                    ac1TripleBondCount++;
                }
            }
            for (int i = 0; i < ac2.getBondCount(); i++)
            {
                bond = ac2.getBondAt(i);
                if (bond is IQueryBond)
                {
                    continue;
                }
                if (bond.getFlag(CDKConstants.ISAROMATIC))
                {
                    ac2AromaticBondCount++;
                }
                else if (bond.Order == 1)
                {
                    ac2SingleBondCount++;
                }
                else if (bond.Order == 2)
                {
                    ac2DoubleBondCount++;
                }
                else if (bond.Order == 3)
                {
                    ac2TripleBondCount++;
                }
            }

            if (ac2SingleBondCount > ac1SingleBondCount)
            {
                return(false);
            }
            if (ac2AromaticBondCount > ac1AromaticBondCount)
            {
                return(false);
            }
            if (ac2DoubleBondCount > ac1DoubleBondCount)
            {
                return(false);
            }
            if (ac2TripleBondCount > ac1TripleBondCount)
            {
                return(false);
            }

            for (int i = 0; i < ac1.AtomCount; i++)
            {
                atom = ac1.getAtomAt(i);
                if (atom.Symbol.Equals("S"))
                {
                    ac1SCount++;
                }
                else if (atom.Symbol.Equals("N"))
                {
                    ac1NCount++;
                }
                else if (atom.Symbol.Equals("O"))
                {
                    ac1OCount++;
                }
                else if (atom.Symbol.Equals("F"))
                {
                    ac1FCount++;
                }
                else if (atom.Symbol.Equals("Cl"))
                {
                    ac1ClCount++;
                }
                else if (atom.Symbol.Equals("Br"))
                {
                    ac1BrCount++;
                }
                else if (atom.Symbol.Equals("I"))
                {
                    ac1ICount++;
                }
                else if (atom.Symbol.Equals("C"))
                {
                    ac1CCount++;
                }
            }
            for (int i = 0; i < ac2.AtomCount; i++)
            {
                atom = ac2.getAtomAt(i);
                if (atom is IQueryAtom)
                {
                    continue;
                }
                if (atom.Symbol.Equals("S"))
                {
                    ac2SCount++;
                }
                else if (atom.Symbol.Equals("N"))
                {
                    ac2NCount++;
                }
                else if (atom.Symbol.Equals("O"))
                {
                    ac2OCount++;
                }
                else if (atom.Symbol.Equals("F"))
                {
                    ac2FCount++;
                }
                else if (atom.Symbol.Equals("Cl"))
                {
                    ac2ClCount++;
                }
                else if (atom.Symbol.Equals("Br"))
                {
                    ac2BrCount++;
                }
                else if (atom.Symbol.Equals("I"))
                {
                    ac2ICount++;
                }
                else if (atom.Symbol.Equals("C"))
                {
                    ac2CCount++;
                }
            }

            if (ac1SCount < ac2SCount)
            {
                return(false);
            }
            if (ac1NCount < ac2NCount)
            {
                return(false);
            }
            if (ac1OCount < ac2OCount)
            {
                return(false);
            }
            if (ac1FCount < ac2FCount)
            {
                return(false);
            }
            if (ac1ClCount < ac2ClCount)
            {
                return(false);
            }
            if (ac1BrCount < ac2BrCount)
            {
                return(false);
            }
            if (ac1ICount < ac2ICount)
            {
                return(false);
            }
            if (ac1CCount < ac2CCount)
            {
                return(false);
            }


            return(true);
        }
Exemple #4
0
        /// <summary> Kruskal algorithm</summary>
        /// <param name="atomContainer">
        /// </param>
        public virtual void buildSpanningTree(IAtomContainer atomContainer)
        {
            disconnected = false;
            molecule     = atomContainer;

            V = atomContainer.AtomCount;
            E = atomContainer.getBondCount();

            sptSize = 0; edrSize = 0;
            fastFindInit(V);
            for (int i = 0; i < V; i++)
            {
                (atomContainer.getAtomAt(i)).setProperty("ST_ATOMNO", System.Convert.ToString(i + 1));
            }
            IBond bond;
            int   v1, v2;

            bondsInTree = new bool[E];

            for (int b = 0; b < E; b++)
            {
                bondsInTree[b] = false;
                bond           = atomContainer.getBondAt(b);
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                v1 = System.Int32.Parse((bond.getAtomAt(0)).getProperty("ST_ATOMNO").ToString());
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                v2 = System.Int32.Parse((bond.getAtomAt(1)).getProperty("ST_ATOMNO").ToString());
                //this below is a little bit  slower
                //v1 = atomContainer.getAtomNumber(bond.getAtomAt(0))+1;
                //v2 = atomContainer.getAtomNumber(bond.getAtomAt(1))+1;
                if (fastfind(v1, v2, true))
                {
                    bondsInTree[b] = true;
                    sptSize++;
                    //System.out.println("ST : includes bond between atoms "+v1+","+v2);
                }
                if (sptSize >= (V - 1))
                {
                    break;
                }
            }
            // if atomcontainer is connected then the number of bonds in the spanning tree = (No atoms-1)
            //i.e.  edgesRings = new Bond[E-V+1];
            //but to hold all bonds if atomContainer was disconnected then  edgesRings = new Bond[E-sptSize];
            if (sptSize != (V - 1))
            {
                disconnected = true;
            }
            for (int b = 0; b < E; b++)
            {
                if (!bondsInTree[b])
                {
                    //			edgesRings[edrSize] = atomContainer.getBondAt(b);
                    edrSize++;
                }
            }
            cb = new int[edrSize][];
            for (int i2 = 0; i2 < edrSize; i2++)
            {
                cb[i2] = new int[E];
            }
            for (int i = 0; i < edrSize; i++)
            {
                for (int a = 0; a < E; a++)
                {
                    cb[i][a] = 0;
                }
            }
        }
        /// <summary>  Checks some simple heuristics for whether the subgraph query can
        /// realistically be a subgraph of the supergraph. If, for example, the
        /// number of nitrogen atoms in the query is larger than that of the supergraph
        /// it cannot be part of it.
        /// 
        /// </summary>
        /// <param name="ac1"> the supergraph to be checked
        /// </param>
        /// <param name="ac2"> the subgraph to be tested for
        /// </param>
        /// <returns>    true if the subgraph ac2 has a chance to be a subgraph of ac1
        /// 
        /// </returns>

        private static bool testSubgraphHeuristics(IAtomContainer ac1, IAtomContainer ac2)
        {
            int ac1SingleBondCount = 0;
            int ac1DoubleBondCount = 0;
            int ac1TripleBondCount = 0;
            int ac1AromaticBondCount = 0;
            int ac2SingleBondCount = 0;
            int ac2DoubleBondCount = 0;
            int ac2TripleBondCount = 0;
            int ac2AromaticBondCount = 0;
            int ac1SCount = 0;
            int ac1OCount = 0;
            int ac1NCount = 0;
            int ac1FCount = 0;
            int ac1ClCount = 0;
            int ac1BrCount = 0;
            int ac1ICount = 0;
            int ac1CCount = 0;

            int ac2SCount = 0;
            int ac2OCount = 0;
            int ac2NCount = 0;
            int ac2FCount = 0;
            int ac2ClCount = 0;
            int ac2BrCount = 0;
            int ac2ICount = 0;
            int ac2CCount = 0;

            IBond bond;
            IAtom atom;
            for (int i = 0; i < ac1.getBondCount(); i++)
            {
                bond = ac1.getBondAt(i);
                if (bond.getFlag(CDKConstants.ISAROMATIC))
                    ac1AromaticBondCount++;
                else if (bond.Order == 1)
                    ac1SingleBondCount++;
                else if (bond.Order == 2)
                    ac1DoubleBondCount++;
                else if (bond.Order == 3)
                    ac1TripleBondCount++;
            }
            for (int i = 0; i < ac2.getBondCount(); i++)
            {
                bond = ac2.getBondAt(i);
                if (bond is IQueryBond)
                    continue;
                if (bond.getFlag(CDKConstants.ISAROMATIC))
                    ac2AromaticBondCount++;
                else if (bond.Order == 1)
                    ac2SingleBondCount++;
                else if (bond.Order == 2)
                    ac2DoubleBondCount++;
                else if (bond.Order == 3)
                    ac2TripleBondCount++;
            }

            if (ac2SingleBondCount > ac1SingleBondCount)
                return false;
            if (ac2AromaticBondCount > ac1AromaticBondCount)
                return false;
            if (ac2DoubleBondCount > ac1DoubleBondCount)
                return false;
            if (ac2TripleBondCount > ac1TripleBondCount)
                return false;

            for (int i = 0; i < ac1.AtomCount; i++)
            {
                atom = ac1.getAtomAt(i);
                if (atom.Symbol.Equals("S"))
                    ac1SCount++;
                else if (atom.Symbol.Equals("N"))
                    ac1NCount++;
                else if (atom.Symbol.Equals("O"))
                    ac1OCount++;
                else if (atom.Symbol.Equals("F"))
                    ac1FCount++;
                else if (atom.Symbol.Equals("Cl"))
                    ac1ClCount++;
                else if (atom.Symbol.Equals("Br"))
                    ac1BrCount++;
                else if (atom.Symbol.Equals("I"))
                    ac1ICount++;
                else if (atom.Symbol.Equals("C"))
                    ac1CCount++;
            }
            for (int i = 0; i < ac2.AtomCount; i++)
            {
                atom = ac2.getAtomAt(i);
                if (atom is IQueryAtom)
                    continue;
                if (atom.Symbol.Equals("S"))
                    ac2SCount++;
                else if (atom.Symbol.Equals("N"))
                    ac2NCount++;
                else if (atom.Symbol.Equals("O"))
                    ac2OCount++;
                else if (atom.Symbol.Equals("F"))
                    ac2FCount++;
                else if (atom.Symbol.Equals("Cl"))
                    ac2ClCount++;
                else if (atom.Symbol.Equals("Br"))
                    ac2BrCount++;
                else if (atom.Symbol.Equals("I"))
                    ac2ICount++;
                else if (atom.Symbol.Equals("C"))
                    ac2CCount++;
            }

            if (ac1SCount < ac2SCount)
                return false;
            if (ac1NCount < ac2NCount)
                return false;
            if (ac1OCount < ac2OCount)
                return false;
            if (ac1FCount < ac2FCount)
                return false;
            if (ac1ClCount < ac2ClCount)
                return false;
            if (ac1BrCount < ac2BrCount)
                return false;
            if (ac1ICount < ac2ICount)
                return false;
            if (ac1CCount < ac2CCount)
                return false;


            return true;
        }
Exemple #6
0
        /// <summary> Produces an AtomContainer without explicit Hs but with H count from one with Hs.
        /// The new molecule is a deep copy.
        ///
        /// </summary>
        /// <param name="atomContainer">The AtomContainer from which to remove the hydrogens
        /// </param>
        /// <returns>              The molecule without Hs.
        /// </returns>
        /// <cdk.keyword>          hydrogen, removal </cdk.keyword>
        public static IAtomContainer removeHydrogens(IAtomContainer atomContainer)
        {
            //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
            System.Collections.IDictionary map    = new System.Collections.Hashtable(); // maps original atoms to clones.
            System.Collections.IList       remove = new System.Collections.ArrayList(); // lists removed Hs.

            // Clone atoms except those to be removed.
            IMolecule mol   = atomContainer.Builder.newMolecule();
            int       count = atomContainer.AtomCount;

            for (int i = 0; i < count; i++)
            {
                // Clone/remove this atom?
                IAtom atom = atomContainer.getAtomAt(i);
                if (!atom.Symbol.Equals("H"))
                {
                    IAtom clonedAtom = null;
                    try
                    {
                        clonedAtom = (IAtom)atom.Clone();
                    }
                    //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
                    catch (System.Exception e)
                    {
                        // TODO Auto-generated catch block
                        SupportClass.WriteStackTrace(e, Console.Error);
                    }
                    clonedAtom.setHydrogenCount(0);
                    mol.addAtom(clonedAtom);
                    map[atom] = clonedAtom;
                }
                else
                {
                    remove.Add(atom); // maintain list of removed H.
                }
            }

            // Clone bonds except those involving removed atoms.
            count = atomContainer.getBondCount();
            for (int i = 0; i < count; i++)
            {
                // Check bond.
                //UPGRADE_NOTE: Final was removed from the declaration of 'bond '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                IBond   bond        = atomContainer.getBondAt(i);
                IAtom[] atoms       = bond.getAtoms();
                bool    removedBond = false;
                //UPGRADE_NOTE: Final was removed from the declaration of 'length '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                int length = atoms.Length;
                for (int k = 0; k < length; k++)
                {
                    if (remove.Contains(atoms[k]))
                    {
                        removedBond = true;
                        break;
                    }
                }

                // Clone/remove this bond?
                if (!removedBond)
                // if (!remove.contains(atoms[0]) && !remove.contains(atoms[1]))
                {
                    IBond clone = null;
                    try
                    {
                        clone = (IBond)atomContainer.getBondAt(i).Clone();
                    }
                    //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
                    catch (System.Exception e)
                    {
                        // TODO Auto-generated catch block
                        SupportClass.WriteStackTrace(e, Console.Error);
                    }
                    clone.setAtoms(new IAtom[] { (IAtom)map[atoms[0]], (IAtom)map[atoms[1]] });
                    mol.addBond(clone);
                }
            }

            // Recompute hydrogen counts of neighbours of removed Hydrogens.
            //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'"
            for (System.Collections.IEnumerator i = remove.GetEnumerator(); i.MoveNext();)
            {
                // Process neighbours.
                //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'"
                //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'"
                for (System.Collections.IEnumerator n = atomContainer.getConnectedAtomsVector((IAtom)i.Current).GetEnumerator(); n.MoveNext();)
                {
                    //UPGRADE_NOTE: Final was removed from the declaration of 'neighb '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                    //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'"
                    IAtom neighb = (IAtom)map[n.Current];
                    neighb.setHydrogenCount(neighb.getHydrogenCount() + 1);
                }
            }
            mol.Properties = atomContainer.Properties;
            mol.Flags      = atomContainer.Flags;

            return(mol);
        }
        /// <summary> Produces an AtomContainer without explicit Hs but with H count from one with Hs.
        /// The new molecule is a deep copy.
        /// 
        /// </summary>
        /// <param name="atomContainer">The AtomContainer from which to remove the hydrogens
        /// </param>
        /// <returns>              The molecule without Hs.
        /// </returns>
        /// <cdk.keyword>          hydrogen, removal </cdk.keyword>
        public static IAtomContainer removeHydrogens(IAtomContainer atomContainer)
        {
            //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
            System.Collections.IDictionary map = new System.Collections.Hashtable(); // maps original atoms to clones.
            System.Collections.IList remove = new System.Collections.ArrayList(); // lists removed Hs.

            // Clone atoms except those to be removed.
            IMolecule mol = atomContainer.Builder.newMolecule();
            int count = atomContainer.AtomCount;
            for (int i = 0; i < count; i++)
            {
                // Clone/remove this atom?
                IAtom atom = atomContainer.getAtomAt(i);
                if (!atom.Symbol.Equals("H"))
                {
                    IAtom clonedAtom = null;
                    try
                    {
                        clonedAtom = (IAtom)atom.Clone();
                    }
                    //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
                    catch (System.Exception e)
                    {
                        // TODO Auto-generated catch block
                        SupportClass.WriteStackTrace(e, Console.Error);
                    }
                    clonedAtom.setHydrogenCount(0);
                    mol.addAtom(clonedAtom);
                    map[atom] = clonedAtom;
                }
                else
                {
                    remove.Add(atom); // maintain list of removed H.
                }
            }

            // Clone bonds except those involving removed atoms.
            count = atomContainer.getBondCount();
            for (int i = 0; i < count; i++)
            {
                // Check bond.
                //UPGRADE_NOTE: Final was removed from the declaration of 'bond '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                IBond bond = atomContainer.getBondAt(i);
                IAtom[] atoms = bond.getAtoms();
                bool removedBond = false;
                //UPGRADE_NOTE: Final was removed from the declaration of 'length '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                int length = atoms.Length;
                for (int k = 0; k < length; k++)
                {
                    if (remove.Contains(atoms[k]))
                    {
                        removedBond = true;
                        break;
                    }
                }

                // Clone/remove this bond?
                if (!removedBond)
                // if (!remove.contains(atoms[0]) && !remove.contains(atoms[1]))
                {
                    IBond clone = null;
                    try
                    {
                        clone = (IBond)atomContainer.getBondAt(i).Clone();
                    }
                    //UPGRADE_NOTE: Exception 'java.lang.CloneNotSupportedException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
                    catch (System.Exception e)
                    {
                        // TODO Auto-generated catch block
                        SupportClass.WriteStackTrace(e, Console.Error);
                    }
                    clone.setAtoms(new IAtom[] { (IAtom)map[atoms[0]], (IAtom)map[atoms[1]] });
                    mol.addBond(clone);
                }
            }

            // Recompute hydrogen counts of neighbours of removed Hydrogens.
            //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'"
            for (System.Collections.IEnumerator i = remove.GetEnumerator(); i.MoveNext(); )
            {
                // Process neighbours.
                //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'"
                //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'"
                for (System.Collections.IEnumerator n = atomContainer.getConnectedAtomsVector((IAtom)i.Current).GetEnumerator(); n.MoveNext(); )
                {
                    //UPGRADE_NOTE: Final was removed from the declaration of 'neighb '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                    //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'"
                    IAtom neighb = (IAtom)map[n.Current];
                    neighb.setHydrogenCount(neighb.getHydrogenCount() + 1);
                }
            }
            mol.Properties = atomContainer.Properties;
            mol.Flags = atomContainer.Flags;

            return (mol);
        }