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


C# IAtomContainer.getBondCount方法代码示例

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


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

示例1: getMorganNumbers

 /// <summary>  Makes an array containing the morgan numbers of the atoms of atomContainer.
 /// 
 /// </summary>
 /// <param name="atomContainer"> The atomContainer to analyse.
 /// </param>
 /// <returns>                The morgan numbers value.
 /// </returns>
 public static int[] getMorganNumbers(IAtomContainer atomContainer)
 {
     int[] morganMatrix;
     int[] tempMorganMatrix;
     int N = atomContainer.AtomCount;
     morganMatrix = new int[N];
     tempMorganMatrix = new int[N];
     IAtom[] atoms = null;
     for (int f = 0; f < N; f++)
     {
         morganMatrix[f] = atomContainer.getBondCount(f);
         tempMorganMatrix[f] = atomContainer.getBondCount(f);
     }
     for (int e = 0; e < N; e++)
     {
         for (int f = 0; f < N; f++)
         {
             morganMatrix[f] = 0;
             atoms = atomContainer.getConnectedAtoms(atomContainer.getAtomAt(f));
             for (int g = 0; g < atoms.Length; g++)
             {
                 morganMatrix[f] += tempMorganMatrix[atomContainer.getAtomNumber(atoms[g])];
             }
         }
         Array.Copy(morganMatrix, 0, tempMorganMatrix, 0, N);
     }
     return tempMorganMatrix;
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:35,代码来源:MorganNumbersTools.cs

示例2: getMoleculeGraph

        /// <summary>
        /// Creates a molecule graph for use with jgrapht.
        /// Bond orders are not respected.
        /// </summary>
        /// <param name="molecule">the specified molecule</param>
        /// <returns>a graph representing the molecule</returns>
	    static public SimpleGraph getMoleculeGraph(IAtomContainer molecule) {
		    SimpleGraph graph = new SimpleGraph();
		    for (int i=0; i<molecule.AtomCount; i++	) {
			    IAtom atom = molecule.Atoms[i];
			    graph.addVertex(atom);
		    }
    		
		    for (int i=0; i<molecule.getBondCount(); i++	) {
			    IBond bond = molecule.Bonds[i];
    			
			    /*
			    int order = (int) bond.getOrder();
			    for (int j=0; j<order; j++) {
				    graph.addEdge(bond.getAtoms()[0], bond.getAtoms()[1]);
			    }
			    */
			    graph.addEdge(bond.getAtoms()[0], bond.getAtoms()[1]);
		    }
		    return graph;
	    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:26,代码来源:MoleculeGraphs.cs

示例3: selectAtom

        /// <summary>  Selects an optimal atom for removal
        /// See {@cdk.cite HAN96} for details
        /// 
        /// </summary>
        /// <param name="ac"> The AtomContainer to search
        /// </param>
        /// <returns>     The selected Atom
        /// </returns>
        private IAtom selectAtom(IAtomContainer ac)
        {
            int minDegree = 999;
            // :-)
            int degree = minDegree;
            IAtom minAtom = null;
            IAtom atom = null;
            for (int f = 0; f < ac.AtomCount; f++)
            {
                atom = ac.getAtomAt(f);
                degree = ac.getBondCount(atom);

                if (degree < minDegree)
                {
                    minAtom = atom;
                    minDegree = degree;
                }
            }

            return minAtom;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:29,代码来源:AllRingsFinder.cs

示例4: removeAliphatic

 /// <summary>  Removes all external aliphatic chains by chopping them off from the
 /// ends
 /// 
 /// </summary>
 /// <param name="ac">               The AtomContainer to work with
 /// </param>
 /// <exception cref="CDKException"> An exception thrown if something goes wrong or if the timeout limit is reached
 /// </exception>
 private void removeAliphatic(IAtomContainer ac)
 {
     bool removedSomething;
     IAtom atom = null;
     do
     {
         removedSomething = false;
         //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' 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_javautilEnumerationhasMoreElements'"
         for (System.Collections.IEnumerator e = ac.atoms(); e.MoveNext(); )
         {
             //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' 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_javautilEnumerationnextElement'"
             atom = (IAtom)e.Current;
             if (ac.getBondCount(atom) == 1)
             {
                 ac.removeAtomAndConnectedElectronContainers(atom);
                 removedSomething = true;
             }
         }
     }
     while (removedSomething);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:29,代码来源:AllRingsFinder.cs

示例5: doSearch

 /// <summary>  Description of the Method
 /// 
 /// </summary>
 /// <param name="ac">               The AtomContainer to be searched
 /// </param>
 /// <param name="pathes">           A vectoring storing all the pathes
 /// </param>
 /// <param name="ringSet">          A ringset to be extended while we search
 /// </param>
 /// <exception cref="CDKException"> An exception thrown if something goes wrong or if the timeout limit is reached
 /// </exception>
 private void doSearch(IAtomContainer ac, System.Collections.ArrayList pathes, IRingSet ringSet)
 {
     IAtom atom = null;
     /*
     *  First we convert the molecular graph into a a path graph by
     *  creating a set of two membered pathes from all the bonds in the molecule
     */
     initPathGraph(ac, pathes);
     if (debug)
     {
         System.Console.Out.WriteLine("BondCount: " + ac.getBondCount() + ", PathCount: " + pathes.Count);
     }
     do
     {
         atom = selectAtom(ac);
         if (atom != null)
         {
             remove(atom, ac, pathes, ringSet);
         }
     }
     while (pathes.Count > 0 && atom != null);
     if (debug)
     {
         System.Console.Out.WriteLine("pathes.size(): " + pathes.Count);
     }
     if (debug)
     {
         System.Console.Out.WriteLine("ringSet.size(): " + ringSet.AtomContainerCount);
     }
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:41,代码来源:AllRingsFinder.cs

示例6: 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

示例7: parseChain


//.........这里部分代码省略.........
                                        System.Object placeholder = onew[onew.Length - 1];
                                        for (int k = onew.Length - 2; k > -1; k--)
                                        {
                                            onew[k + 1] = onew[k];
                                        }
                                        onew[0] = placeholder;
                                        l++;
                                        if (l > onew.Length)
                                        {
                                            break;
                                        }
                                    }
                                }
                                //This cares about ring openings. Here the ring closure (represendted by a figure) must be the first atom. In onew the closure is null.
                                if (getRingOpenings(atom, null).Count > 0)
                                {
                                    int l = 0;
                                    while (onew[0] != null)
                                    {
                                        System.Object placeholder = onew[0];
                                        for (int k = 1; k < onew.Length; k++)
                                        {
                                            onew[k - 1] = onew[k];
                                        }
                                        onew[onew.Length - 1] = placeholder;
                                        l++;
                                        if (l > onew.Length)
                                        {
                                            break;
                                        }
                                    }
                                }
                                //The last in onew is a vector: This means we need to exchange the rest of the original smiles with the rest of this vector.
                                if (onew[numberOfAtoms - 1] is System.Collections.ArrayList)
                                {
                                    for (int i = 0; i < numberOfAtoms; i++)
                                    {
                                        if (onew[i] is IAtom)
                                        {
                                            System.Collections.ArrayList vtemp = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
                                            vtemp.Add(onew[i]);
                                            for (int k = positionInVector + 1 + numberOfAtoms; k < v.Count; k++)
                                            {
                                                vtemp.Add(v[k]);
                                            }
                                            onew[i] = vtemp;
                                            for (int k = v.Count - 1; k > positionInVector + 1 + numberOfAtoms - 1; k--)
                                            {
                                                v.RemoveAt(k);
                                            }
                                            for (int k = 1; k < ((System.Collections.ArrayList)onew[numberOfAtoms - 1]).Count; k++)
                                            {
                                                v.Add(((System.Collections.ArrayList)onew[numberOfAtoms - 1])[k]);
                                            }
                                            onew[numberOfAtoms - 1] = ((System.Collections.ArrayList)onew[numberOfAtoms - 1])[0];
                                            break;
                                        }
                                    }
                                }
                                //Put the onew objects in the original Vector
                                int k2 = 0;
                                for (int m = 0; m < onew.Length; m++)
                                {
                                    if (onew[m] != null)
                                    {
                                        v[positionInVector + 1 + k2] = onew[m];
                                        k2++;
                                    }
                                }
                            }
                        }
                    }
                    parent = atom;
                }
                else
                {
                    //Have Vector
                    //System.out.println("in parseChain after else");
                    bool brackets = true;
                    System.Collections.ArrayList result = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
                    addAtoms((System.Collections.ArrayList)o, result);
                    if (isRingOpening(parent, result) && container.getBondCount(parent) < 4)
                    {
                        brackets = false;
                    }
                    if (brackets)
                    {
                        buffer.Append('(');
                    }
                    parseChain((System.Collections.ArrayList)o, buffer, container, parent, chiral, doubleBondConfiguration, atomsInOrderOfSmiles);
                    if (brackets)
                    {
                        buffer.Append(')');
                    }
                }

                positionInVector++;
                //System.out.println("in parseChain after positionVector++");
            }
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:SmilesGenerator.cs

示例8: identicalAtoms

		/**
		 * Very quick and easy isomorphism check.
		 * 
		 * @param molecule1 the molecule1
		 * @param fragsToCompare the frags to compare
		 * 
		 * @return true, if successful
		 */

		private bool identicalAtoms(IAtomContainer molecule1, List<IAtomContainer> fragsToCompare)
		{
			var molFormula = MolecularFormulaTools.GetMolecularFormula(molecule1);
			var molFormulaString = MolecularFormulaTools.GetString(molFormula);

			for (var i = 0; i < fragsToCompare.Count; i++)
			{
				//no match
				if (molecule1.getBondCount() != fragsToCompare[i].getBondCount() && molecule1.getAtomCount() != fragsToCompare[i].getAtomCount())
				{
					continue;
				}

				//Molecular Formula redundancy check
				var molFormulaFrag = MolecularFormulaTools.GetMolecularFormula(fragsToCompare[i]);
				var molFormulaFragString = MolecularFormulaTools.GetString(molFormulaFrag);
				if (molFormulaString.Equals(molFormulaFragString))
				{
					return true;
				}
			}

			//no match found
			return false;
		}
开发者ID:NonlinearDynamics,项目名称:MetFrag.NET,代码行数:34,代码来源:Fragmenter.cs

示例9: saturateRingSystems

		public virtual void  saturateRingSystems(IAtomContainer atomContainer)
		{
			IRingSet rs = new SSSRFinder(atomContainer.Builder.newMolecule(atomContainer)).findSSSR();
			System.Collections.ArrayList ringSets = RingPartitioner.partitionRings(rs);
			IAtomContainer ac = null;
			IAtom atom = null;
			int[] temp;
			for (int f = 0; f < ringSets.Count; f++)
			{
				rs = (IRingSet) ringSets[f];
				ac = RingSetManipulator.getAllInOneContainer(rs);
				temp = new int[ac.AtomCount];
				for (int g = 0; g < ac.AtomCount; g++)
				{
					atom = ac.getAtomAt(g);
					temp[g] = atom.getHydrogenCount();
					atom.setHydrogenCount(atomContainer.getBondCount(atom) - ac.getBondCount(atom) - temp[g]);
				}
				saturate(ac);
				for (int g = 0; g < ac.AtomCount; g++)
				{
					atom = ac.getAtomAt(g);
					atom.setHydrogenCount(temp[g]);
				}
			}
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:26,代码来源:SaturationChecker.cs

示例10: saturate

		/// <summary> The method is known to fail for certain compounds. For more information, see
		/// cdk.test.limitations package.
		/// 
		/// </summary>
		public virtual void  saturate(IAtomContainer atomContainer)
		{
			/* newSaturate(atomContainer);
			}
			public void oldSaturate(AtomContainer atomContainer) throws CDKException { */
			IAtom partner = null;
			IAtom atom = null;
			IAtom[] partners = null;
			IAtomType[] atomTypes1 = null;
			IAtomType[] atomTypes2 = null;
			IBond bond = null;
			for (int i = 1; i < 4; i++)
			{
				// handle atoms with degree 1 first and then proceed to higher order
				for (int f = 0; f < atomContainer.AtomCount; f++)
				{
					atom = atomContainer.getAtomAt(f);
					//logger.debug("symbol: ", atom.Symbol);
					atomTypes1 = getAtomTypeFactory(atom.Builder).getAtomTypes(atom.Symbol);
					if (atomTypes1.Length > 0)
					{
						//logger.debug("first atom type: ", atomTypes1[0]);
						if (atomContainer.getBondCount(atom) == i)
						{
							if (atom.getFlag(CDKConstants.ISAROMATIC) && atomContainer.getBondOrderSum(atom) < atomTypes1[0].BondOrderSum - atom.getHydrogenCount())
							{
								partners = atomContainer.getConnectedAtoms(atom);
								for (int g = 0; g < partners.Length; g++)
								{
									partner = partners[g];
									//logger.debug("Atom has " + partners.Length + " partners");
									atomTypes2 = getAtomTypeFactory(atom.Builder).getAtomTypes(partner.Symbol);
									if (atomTypes2.Length == 0)
										return ;
									if (atomContainer.getBond(partner, atom).getFlag(CDKConstants.ISAROMATIC) && atomContainer.getBondOrderSum(partner) < atomTypes2[0].BondOrderSum - partner.getHydrogenCount())
									{
										//logger.debug("Partner has " + atomContainer.getBondOrderSum(partner) + ", may have: " + atomTypes2[0].BondOrderSum);
										bond = atomContainer.getBond(atom, partner);
										//logger.debug("Bond order was " + bond.Order);
										bond.Order = bond.Order + 1;
										//logger.debug("Bond order now " + bond.Order);
										break;
									}
								}
							}
							if (atomContainer.getBondOrderSum(atom) < atomTypes1[0].BondOrderSum - atom.getHydrogenCount())
							{
								//logger.debug("Atom has " + atomContainer.getBondOrderSum(atom) + ", may have: " + atomTypes1[0].BondOrderSum);
								partners = atomContainer.getConnectedAtoms(atom);
								for (int g = 0; g < partners.Length; g++)
								{
									partner = partners[g];
									//logger.debug("Atom has " + partners.Length + " partners");
									atomTypes2 = getAtomTypeFactory(atom.Builder).getAtomTypes(partner.Symbol);
									if (atomTypes2.Length == 0)
										return ;
									if (atomContainer.getBondOrderSum(partner) < atomTypes2[0].BondOrderSum - partner.getHydrogenCount())
									{
										//logger.debug("Partner has " + atomContainer.getBondOrderSum(partner) + ", may have: " + atomTypes2[0].BondOrderSum);
										bond = atomContainer.getBond(atom, partner);
										//logger.debug("Bond order was " + bond.Order);
										bond.Order = bond.Order + 1;
										//logger.debug("Bond order now " + bond.Order);
										break;
									}
								}
							}
						}
					}
				}
			}
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:76,代码来源:SaturationChecker.cs

示例11: arcConstructor

        /// <summary>  Build edges of the RGraphs
        /// This method create the edge of the RGraph and
        /// calculates the incompatibility and neighbourhood
        /// relationships between RGraph nodes.
        /// 
        /// </summary>
        /// <param name="gr">  the rGraph
        /// </param>
        /// <param name="ac1"> Description of the first molecule
        /// </param>
        /// <param name="ac2"> Description of the second molecule
        /// </param>
        private static void arcConstructor(RGraph gr, IAtomContainer ac1, IAtomContainer ac2)
        {
            // each node is incompatible with himself
            for (int i = 0; i < gr.Graph.Count; i++)
            {
                RNode x = (RNode)gr.Graph[i];
                SupportClass.BitArraySupport.Set(x.Forbidden, i);
            }

            IBond a1;
            IBond a2;
            IBond b1;
            IBond b2;

            IBond[] bondsA1 = ac1.Bonds;
            IBond[] bondsA2 = ac2.Bonds;

            gr.FirstGraphSize = ac1.getBondCount();
            gr.SecondGraphSize = ac2.getBondCount();

            for (int i = 0; i < gr.Graph.Count; i++)
            {
                RNode x = (RNode)gr.Graph[i];

                // two nodes are neighbours if their adjacency
                // relationship in are equivalent in G1 and G2
                // else they are incompatible.
                for (int j = i + 1; j < gr.Graph.Count; j++)
                {
                    if (timeout > -1 && ((System.DateTime.Now.Ticks - 621355968000000000) / 10000 - start) > timeout)
                        throw new CDKException("Timeout exceeded in getOverlaps");
                    RNode y = (RNode)gr.Graph[j];

                    a1 = bondsA1[((RNode)gr.Graph[i]).RMap.Id1];
                    a2 = bondsA2[((RNode)gr.Graph[i]).RMap.Id2];
                    b1 = bondsA1[((RNode)gr.Graph[j]).RMap.Id1];
                    b2 = bondsA2[((RNode)gr.Graph[j]).RMap.Id2];

                    if (a2 is IQueryBond)
                    {
                        if (a1.Equals(b1) || a2.Equals(b2) || !queryAdjacency(a1, b1, a2, b2))
                        {
                            SupportClass.BitArraySupport.Set(x.Forbidden, j);
                            SupportClass.BitArraySupport.Set(y.Forbidden, i);
                        }
                        else if (hasCommonAtom(a1, b1))
                        {
                            SupportClass.BitArraySupport.Set(x.Extension, j);
                            SupportClass.BitArraySupport.Set(y.Extension, i);
                        }
                    }
                    else
                    {
                        if (a1.Equals(b1) || a2.Equals(b2) || (!getCommonSymbol(a1, b1).Equals(getCommonSymbol(a2, b2))))
                        {
                            SupportClass.BitArraySupport.Set(x.Forbidden, j);
                            SupportClass.BitArraySupport.Set(y.Forbidden, i);
                        }
                        else if (hasCommonAtom(a1, b1))
                        {
                            SupportClass.BitArraySupport.Set(x.Extension, j);
                            SupportClass.BitArraySupport.Set(y.Extension, i);
                        }
                    }
                }
            }
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:79,代码来源:UniversalIsomorphismTester.cs

示例12: getBitSet

        /// <summary>  Transforms an AtomContainer into a BitSet (which's size = number of bond
        /// in the atomContainer, all the bit are set to true)
        /// 
        /// </summary>
        /// <param name="ac"> AtomContainer to transform
        /// </param>
        /// <returns>     The bitSet
        /// </returns>
        public static System.Collections.BitArray getBitSet(IAtomContainer ac)
        {
            System.Collections.BitArray bs;
            int n = ac.getBondCount();

            if (n != 0)
            {
                bs = new System.Collections.BitArray((n % 64 == 0 ? n / 64 : n / 64 + 1) * 64);
                for (int i = 0; i < n; i++)
                {
                    SupportClass.BitArraySupport.Set(bs, i);
                }
            }
            else
            {
                bs = new System.Collections.BitArray(64);
            }

            return bs;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:28,代码来源:UniversalIsomorphismTester.cs

示例13: 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

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