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


C# Atom.setHydrogenCount方法代码示例

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


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

示例1: assembleAtom

		/// <summary>  Description of the Method
		/// 
		/// </summary>
		/// <param name="s">                          Description of the Parameter
		/// </param>
		/// <returns>                             Description of the Return Value
		/// </returns>
		/// <exception cref="InvalidSmilesException"> Description of the Exception
		/// </exception>
		private Atom assembleAtom(System.String s)
		{
			//logger.debug("assembleAtom(): Assembling atom from: ", s);
			Atom atom = null;
			int position = 0;
			System.String currentSymbol = null;
			System.Text.StringBuilder isotopicNumber = new System.Text.StringBuilder();
			char mychar;
			//logger.debug("Parse everythings before and including element symbol");
			do 
			{
				try
				{
					mychar = s[position];
					//logger.debug("Parsing char: " + mychar);
					if ((mychar >= 'A' && mychar <= 'Z') || (mychar >= 'a' && mychar <= 'z'))
					{
						currentSymbol = getElementSymbol(s, position);
						if (currentSymbol == null)
						{
							throw new InvalidSmilesException("Expected element symbol, found null!");
						}
						else
						{
							//logger.debug("Found element symbol: ", currentSymbol);
							position = position + currentSymbol.Length;
							if (currentSymbol.Length == 1)
							{
								if (!(currentSymbol.ToUpper()).Equals(currentSymbol))
								{
									currentSymbol = currentSymbol.ToUpper();
									atom = new Atom(currentSymbol);
									atom.Hybridization = CDKConstants.HYBRIDIZATION_SP2;
									if (atom.getHydrogenCount() > 0)
									{
										atom.setHydrogenCount(atom.getHydrogenCount() - 1);
									}
								}
								else
								{
									atom = new Atom(currentSymbol);
								}
							}
							else
							{
								atom = new Atom(currentSymbol);
							}
							//logger.debug("Made atom: ", atom);
						}
						break;
					}
					else if (mychar >= '0' && mychar <= '9')
					{
						isotopicNumber.Append(mychar);
						position++;
					}
					else if (mychar == '*')
					{
						currentSymbol = "*";
						atom = new PseudoAtom(currentSymbol);
						//logger.debug("Made atom: ", atom);
						position++;
						break;
					}
					else
					{
						throw new InvalidSmilesException("Found unexpected char: " + mychar);
					}
				}
				catch (InvalidSmilesException exc)
				{
					//logger.error("InvalidSmilesException while parsing atom string: " + s);
					//logger.debug(exc);
					throw exc;
				}
				catch (System.Exception exception)
				{
					//logger.error("Could not parse atom string: ", s);
					//logger.debug(exception);
					throw new InvalidSmilesException("Could not parse atom string: " + s);
				}
			}
			while (position < s.Length);
			if (isotopicNumber.ToString().Length > 0)
			{
				try
				{
					atom.MassNumber = System.Int32.Parse(isotopicNumber.ToString());
				}
				catch (System.Exception exception)
				{
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:SmilesParser.cs


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