예제 #1
0
        /// <summary>
        /// Is the {@code atom} a suppressible hydrogen and can be represented as
        /// implicit. A hydrogen is suppressible if it is not an ion, not the major
        /// isotope (i.e. it is a deuterium or tritium atom) and is not molecular
        /// hydrogen.
        /// </summary>
        /// <param name="container"> the structure </param>
        /// <param name="atom">      an atom in the structure </param>
        /// <returns> the atom is a hydrogen and it can be suppressed (implicit) </returns>
        private static bool suppressibleHydrogen(IAtomContainer container, IAtom atom)
        {
            // is the atom a hydrogen
            if (!"H".Equals(atom.getSymbol()))
            {
                return(false);
            }
            // is the hydrogen an ion?
            if (GetFormalCharge(atom) != 0)
            {
                return(false);
            }
            // is the hydrogen deuterium / tritium?
            if (GetMassNumber(atom) != 1)
            {
                return(false);
            }
            // molecule hydrogen with implicit H?
            if (atom.getImplicitHydrogenCount() != null && atom.getImplicitHydrogenCount().intValue() != 0)
            {
                return(false);
            }
            // molecule hydrogen
            List <IAtom> neighbors = container.getConnectedAtomsList(atom) as List <IAtom>;

            if (neighbors.Count == 1 && neighbors[0].getSymbol().Equals("H"))
            {
                return(false);
            }
            // what about bridging hydrogens?
            // hydrogens with atom-atom mapping?
            return(true);
        }
예제 #2
0
        /// <summary>
        /// Get integer ImplicitHydrogenCount for an atom
        /// </summary>
        /// <param name="atom"></param>
        /// <returns></returns>

        public static int GetImplicitHydrogenCount(IAtom atom)
        {
            if (atom.getImplicitHydrogenCount() == null)
            {
                return(0);
            }
            else
            {
                return(atom.getImplicitHydrogenCount().intValue());
            }
        }
예제 #3
0
        /// <summary>
        /// Increment the implicit hydrogen count of the provided atom. If the atom
        /// was a non-pseudo atom and had an unset hydrogen count an exception is
        /// thrown.
        /// </summary>
        /// <param name="atom"> an atom to increment the hydrogen count of </param>
        private static void incrementImplHydrogenCount(IAtom atom)
        {
            int?hCount = atom.getImplicitHydrogenCount().intValue();

            if (hCount == null)
            {
                if (!(atom is IPseudoAtom))
                {
                    throw new System.ArgumentException("a non-pseudo atom had an unset hydrogen count");
                }
                hCount = 0;
            }

            atom.setImplicitHydrogenCount(new java.lang.Integer((int)hCount + 1));
        }