當前位置: 首頁>>代碼示例>>C#>>正文


C# Atom.getHydrogenCount方法代碼示例

本文整理匯總了C#中Atom.getHydrogenCount方法的典型用法代碼示例。如果您正苦於以下問題:C# Atom.getHydrogenCount方法的具體用法?C# Atom.getHydrogenCount怎麽用?C# Atom.getHydrogenCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Atom的用法示例。


在下文中一共展示了Atom.getHydrogenCount方法的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.getHydrogenCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。