本文整理汇总了C#中IAtomContainer.setAtomAt方法的典型用法代码示例。如果您正苦于以下问题:C# IAtomContainer.setAtomAt方法的具体用法?C# IAtomContainer.setAtomAt怎么用?C# IAtomContainer.setAtomAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAtomContainer
的用法示例。
在下文中一共展示了IAtomContainer.setAtomAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: replaceAtomByAtom
public static bool replaceAtomByAtom(IAtomContainer container, IAtom atom, IAtom newAtom)
{
if (!container.contains(atom))
{
// it should complain
return false;
}
else
{
container.setAtomAt(container.getAtomNumber(atom), newAtom);
IElectronContainer[] electronContainers = container.ElectronContainers;
for (int i = 0; i < electronContainers.Length; i++)
{
if (electronContainers[i] is IBond)
{
IBond bond = (IBond)electronContainers[i];
if (bond.contains(atom))
{
for (int j = 0; j < bond.AtomCount; j++)
{
if (atom.Equals(bond.getAtomAt(j)))
{
bond.setAtomAt(newAtom, j);
}
}
}
}
else if (electronContainers[i] is ILonePair)
{
ILonePair lonePair = (ILonePair)electronContainers[i];
if (atom.Equals(lonePair.Atom))
{
lonePair.Atom = newAtom;
}
}
}
return true;
}
}
示例2: readSGroup
/// <summary> Reads labels.</summary>
public virtual void readSGroup(IAtomContainer readData)
{
bool foundEND = false;
while (Ready && !foundEND)
{
System.String command = readCommand();
if ("END SGROUP".Equals(command))
{
foundEND = true;
}
else
{
//logger.debug("Parsing Sgroup line: " + command);
SupportClass.Tokenizer tokenizer = new SupportClass.Tokenizer(command);
// parse the index
System.String indexString = tokenizer.NextToken();
//logger.warn("Skipping external index: " + indexString);
// parse command type
System.String type = tokenizer.NextToken();
// parse the external index
System.String externalIndexString = tokenizer.NextToken();
//logger.warn("Skipping external index: " + externalIndexString);
// the rest are key=value fields
System.Collections.Hashtable options = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
if (command.IndexOf("=") != -1)
{
options = parseOptions(exhaustStringTokenizer(tokenizer));
}
// now interpret line
if (type.StartsWith("SUP"))
{
System.Collections.IEnumerator keys = options.Keys.GetEnumerator();
int atomID = -1;
System.String label = "";
//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("ATOMS"))
{
SupportClass.Tokenizer atomsTokenizer = new SupportClass.Tokenizer(value_Renamed);
System.Int32.Parse(atomsTokenizer.NextToken()); // should be 1, int atomCount =
atomID = System.Int32.Parse(atomsTokenizer.NextToken());
}
else if (key.Equals("LABEL"))
{
label = value_Renamed;
}
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);
}
if (atomID != -1 && label.Length > 0)
{
IAtom atom = readData.getAtomAt(atomID - 1);
if (!(atom is IPseudoAtom))
{
atom = readData.Builder.newPseudoAtom(atom);
}
((IPseudoAtom)atom).Label = label;
readData.setAtomAt(atomID - 1, atom);
}
}
}
else
{
//logger.warn("Skipping unrecognized SGROUP type: " + type);
}
}
}
}