示例#1
0
        /// <summary>
        /// Count bonds connecting two heavy atoms
        /// </summary>
        /// <param name="mol"></param>
        /// <returns></returns>

        public static int GetHeavyBondCount(IAtomContainer mol)
        {
            int hbCnt = 0;

            for (int bi = 0; bi < mol.getBondCount(); bi++)
            {
                IBond b = mol.getBond(bi);
                if (b.getAtomCount() != 2)
                {
                    continue;
                }

                IAtom a = b.getAtom(0);                    // first atom
                if (a.getAtomicNumber().intValue() == 1 || // do not count hydrogens
                    a.getSymbol().Equals("H"))
                {
                    a = b.getAtom(1);                      // second atom
                }
                if (a.getAtomicNumber().intValue() == 1 || // do not count hydrogens
                    a.getSymbol().Equals("H"))
                {
                    continue;
                }

                hbCnt++;
            }

            return(hbCnt);
        }
示例#2
0
        /// <summary>
        /// GetHeavyAtomCount
        /// </summary>
        /// <param name="mol"></param>
        /// <returns></returns>

        public static int GetHeavyAtomCount(IAtomContainer mol)
        {
            int haCnt = 0;

            for (int ai = 0; ai < mol.getAtomCount(); ai++)
            {
                IAtom atom = mol.getAtom(ai);
                if (atom.getAtomicNumber().intValue() == 1 ||                  // do not count hydrogens
                    atom.getSymbol().Equals("H"))
                {
                    continue;
                }
                else
                {
                    haCnt++;
                }
            }

            return(haCnt);
        }