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


C# IAtomContainer.addBond方法代码示例

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


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

示例1: bondAtom

 /// <summary>
 /// Rebonds one atom by looking up nearby atom using the binary space partition tree.
 /// </summary>
 private void bondAtom(IAtomContainer container, IAtom atom)
 {
     double myCovalentRadius = atom.CovalentRadius;
     double searchRadius = myCovalentRadius + maxCovalentRadius + bondTolerance;
     Point tupleAtom = new Point(atom.X3d, atom.Y3d, atom.Z3d);
     Bspt.EnumerateSphere e = bspt.enumHemiSphere(tupleAtom, searchRadius);
     while (e.MoveNext())
     {
         IAtom atomNear = ((TupleAtom)e.Current).Atom;
         if (atomNear != atom && container.getBond(atom, atomNear) == null)
         {
             bool isBonded_ = isBonded(myCovalentRadius, atomNear.CovalentRadius, e.foundDistance2());
             if (isBonded_)
             {
                 IBond bond = atom.Builder.newBond(atom, atomNear, 1.0);
                 container.addBond(bond);
             }
         }
     }
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:23,代码来源:RebondTool.cs

示例2: processConnections

        /// <summary> Processes the content from the connections field of the INChI.
        /// Typical values look like 1-2-4-6-5-3-1, from INChI=1.12Beta/C6H6/c1-2-4-6-5-3-1/h1-6H.
        /// 
        /// </summary>
        /// <param name="bondsEncoding">the content of the INChI connections field
        /// </param>
        /// <param name="container">    the atomContainer parsed from the formula field
        /// </param>
        /// <param name="source">       the atom to build the path upon. If -1, then start new path
        /// 
        /// </param>
        /// <seealso cref="processFormula">
        /// </seealso>
        public virtual void processConnections(System.String bondsEncoding, IAtomContainer container, int source)
        {
            //logger.debug("Parsing bond data: ", bondsEncoding);

            IBond bondToAdd = null;
            /* Fixme: treatment of branching is too limited! */
            System.String remainder = bondsEncoding;
            while (remainder.Length > 0)
            {
                //logger.debug("Bond part: ", remainder);
                if (remainder[0] == '(')
                {
                    System.String branch = chopBranch(remainder);
                    processConnections(branch, container, source);
                    if (branch.Length + 2 <= remainder.Length)
                    {
                        remainder = remainder.Substring(branch.Length + 2);
                    }
                    else
                    {
                        remainder = "";
                    }
                }
                else
                {
                    Regex pattern = new Regex("^(\\d+)-?(.*)");
                    //Pattern pattern = Pattern.compile("^(\\d+)-?(.*)");
                    //Matcher matcher = pattern.matcher(remainder);
                    Match matcher = pattern.Match(remainder);
                    //if (matcher.matches())
                    if (matcher != null && matcher.Success)
                    {
                        System.String targetStr = matcher.Groups[1].Value;
                        int target = System.Int32.Parse(targetStr);
                        //logger.debug("Source atom: ", source);
                        //logger.debug("Target atom: ", targetStr);
                        IAtom targetAtom = container.getAtomAt(target - 1);
                        if (source != -1)
                        {
                            IAtom sourceAtom = container.getAtomAt(source - 1);
                            bondToAdd = container.Builder.newBond(sourceAtom, targetAtom, 1.0);
                            container.addBond(bondToAdd);
                        }
                        remainder = matcher.Groups[2].Value;
                        source = target;
                        //logger.debug("  remainder: ", remainder);
                    }
                    else
                    {
                        //logger.error("Could not get next bond info part");
                        return;
                    }
                }
            }
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:68,代码来源:INChIContentProcessorTool.cs

示例3: readBondBlock


//.........这里部分代码省略.........
                            //logger.warn("Query order types are not supported (yet). File a bug if you need it");
                        }
                        else
                        {
                            bond.Order = (double)order;
                        }
                    }
                    catch (System.Exception exception)
                    {
                        System.String error = "Error while parsing bond index";
                        //logger.error(error);
                        //logger.debug(exception);
                        throw new CDKException(error, exception);
                    }
                    // parse index atom 1
                    try
                    {
                        System.String indexAtom1String = tokenizer.NextToken();
                        int indexAtom1 = System.Int32.Parse(indexAtom1String);
                        IAtom atom1 = readData.getAtomAt(indexAtom1 - 1);
                        bond.setAtomAt(atom1, 0);
                    }
                    catch (System.Exception exception)
                    {
                        System.String error = "Error while parsing index atom 1 in bond";
                        //logger.error(error);
                        //logger.debug(exception);
                        throw new CDKException(error, exception);
                    }
                    // parse index atom 2
                    try
                    {
                        System.String indexAtom2String = tokenizer.NextToken();
                        int indexAtom2 = System.Int32.Parse(indexAtom2String);
                        IAtom atom2 = readData.getAtomAt(indexAtom2 - 1);
                        bond.setAtomAt(atom2, 1);
                    }
                    catch (System.Exception exception)
                    {
                        System.String error = "Error while parsing index atom 2 in bond";
                        //logger.error(error);
                        //logger.debug(exception);
                        throw new CDKException(error, exception);
                    }
                    // the rest are key=value fields
                    if (command.IndexOf("=") != -1)
                    {
                        System.Collections.Hashtable options = parseOptions(exhaustStringTokenizer(tokenizer));
                        System.Collections.IEnumerator keys = options.Keys.GetEnumerator();
                        //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'"
                        while (keys.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'"
                            System.String key = (System.String)keys.Current;
                            System.String value_Renamed = (System.String)options[key];
                            try
                            {
                                if (key.Equals("CFG"))
                                {
                                    int configuration = System.Int32.Parse(value_Renamed);
                                    if (configuration == 0)
                                    {
                                        bond.Stereo = CDKConstants.STEREO_BOND_NONE;
                                    }
                                    else if (configuration == 1)
                                    {
                                        bond.Stereo = CDKConstants.STEREO_BOND_UP;
                                    }
                                    else if (configuration == 2)
                                    {
                                        bond.Stereo = CDKConstants.STEREO_BOND_UNDEFINED;
                                    }
                                    else if (configuration == 3)
                                    {
                                        bond.Stereo = CDKConstants.STEREO_BOND_DOWN;
                                    }
                                }
                                else
                                {
                                    //logger.warn("Not parsing key: " + key);
                                }
                            }
                            catch (System.Exception exception)
                            {
                                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                                System.String error = "Error while parsing key/value " + key + "=" + value_Renamed + ": " + exception.Message;
                                //logger.error(error);
                                //logger.debug(exception);
                                throw new CDKException(error, exception);
                            }
                        }
                    }

                    // storing bond
                    readData.addBond(bond);
                    //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'"
                    //logger.debug("Added bond: " + bond);
                }
            }
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:MDLV3000Reader.cs

示例4: addExplicitHydrogensToSatisfyValency

		/// <summary> Method that saturates an atom in a molecule by adding explicit hydrogens.
		/// 
		/// </summary>
		/// <param name="atom">     Atom to saturate
		/// </param>
		/// <param name="container">AtomContainer containing the atom
		/// </param>
		/// <param name="count">    Number of hydrogens to add
		/// </param>
		/// <param name="totalContainer">In case you have a container containing multiple structures, this is the total container, whereas container is a partial structure
		/// 
		/// </param>
		/// <cdk.keyword>           hydrogen, adding </cdk.keyword>
		/// <cdk.keyword>           explicit hydrogen </cdk.keyword>
		public virtual IAtomContainer addExplicitHydrogensToSatisfyValency(IAtomContainer container, IAtom atom, int count, IAtomContainer totalContainer)
		{
			//boolean create2DCoordinates = GeometryTools.has2DCoordinates(container);
			
			IIsotope isotope = IsotopeFactory.getInstance(container.Builder).getMajorIsotope("H");
			atom.setHydrogenCount(0);
			IAtomContainer changedAtomsAndBonds = container.Builder.newAtomContainer();
			for (int i = 1; i <= count; i++)
			{
				IAtom hydrogen = container.Builder.newAtom("H");
				IsotopeFactory.getInstance(container.Builder).configure(hydrogen, isotope);
				totalContainer.addAtom(hydrogen);
				IBond newBond = container.Builder.newBond((IAtom) atom, hydrogen, 1.0);
				totalContainer.addBond(newBond);
				changedAtomsAndBonds.addAtom(hydrogen);
				changedAtomsAndBonds.addBond(newBond);
			}
			return changedAtomsAndBonds;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:33,代码来源:HydrogenAdder.cs

示例5: depthFirstTargetSearch

 /// <summary> Recursivly perfoms a depth first search in a molecular graphs contained in
 /// the AtomContainer molecule, starting at the root atom and returning when it
 /// hits the target atom.
 /// CAUTION: This recursive method sets the VISITED flag of each atom
 /// does not reset it after finishing the search. If you want to do the
 /// operation on the same collection of atoms more than once, you have
 /// to set all the VISITED flags to false before each operation
 /// by looping of the atoms and doing a
 /// "atom.setFlag((CDKConstants.VISITED, false));"
 /// 
 /// </summary>
 /// <param name="molecule">The
 /// AtomContainer to be searched
 /// </param>
 /// <param name="root">    The root atom
 /// to start the search at
 /// </param>
 /// <param name="target">  The target
 /// </param>
 /// <param name="path">    An
 /// AtomContainer to be filled with the path
 /// </param>
 /// <returns> true if the
 /// target atom was found during this function call
 /// </returns>
 public static bool depthFirstTargetSearch(IAtomContainer molecule, IAtom root, IAtom target, IAtomContainer path)
 {
     IBond[] bonds = molecule.getConnectedBonds(root);
     IAtom nextAtom;
     root.setFlag(CDKConstants.VISITED, true);
     for (int f = 0; f < bonds.Length; f++)
     {
         nextAtom = bonds[f].getConnectedAtom(root);
         if (!nextAtom.getFlag(CDKConstants.VISITED))
         {
             path.addAtom(nextAtom);
             path.addBond(bonds[f]);
             if (nextAtom == target)
             {
                 return true;
             }
             else
             {
                 if (!depthFirstTargetSearch(molecule, nextAtom, target, path))
                 {
                     // we did not find the target
                     path.removeAtom(nextAtom);
                     path.removeElectronContainer(bonds[f]);
                 }
                 else
                 {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:58,代码来源:PathTools.cs


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