当前位置: 首页>>代码示例>>C#>>正文


C# IAtomContainer.getBondAt方法代码示例

本文整理汇总了C#中IAtomContainer.getBondAt方法的典型用法代码示例。如果您正苦于以下问题:C# IAtomContainer.getBondAt方法的具体用法?C# IAtomContainer.getBondAt怎么用?C# IAtomContainer.getBondAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAtomContainer的用法示例。


在下文中一共展示了IAtomContainer.getBondAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: testSubgraphHeuristics

        /// <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++;
            }
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:UniversalIsomorphismTester.cs

示例2: buildSpanningTree

        /// <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;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:61,代码来源:SpanningTree.cs

示例3: removeHydrogens

        /// <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);
                }
            }
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:AtomContainerManipulator.cs


注:本文中的IAtomContainer.getBondAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。