本文整理汇总了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)
{
//.........这里部分代码省略.........