本文整理汇总了C#中IAtomContainer类的典型用法代码示例。如果您正苦于以下问题:C# IAtomContainer类的具体用法?C# IAtomContainer怎么用?C# IAtomContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAtomContainer类属于命名空间,在下文中一共展示了IAtomContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateFragments
public IEnumerable<IAtomContainer> GenerateFragments(IAtomContainer compound, string compoundId, CancellationToken isCancelled)
{
var fragmenter = new Fragmenter(spectrum.Peaks.ToList(), config);
// This might throw an OutOfMemoryException, but I want it to be thrown not silently fail
return fragmenter.GenerateFragmentsEfficient(compound, true, config.TreeDepth, compoundId, isCancelled);
}
示例2: AddImplicitHydrogens
public bool AddImplicitHydrogens(IAtomContainer molecule)
{
try
{
var builder = molecule.getBuilder();
var matcher = CDKAtomTypeMatcher.getInstance(builder);
foreach (var atom in molecule.atoms().ToWindowsEnumerable<IAtom>())
{
var type = matcher.findMatchingAtomType(molecule, atom);
AtomTypeManipulator.configure(atom, type);
}
var hAdder = CDKHydrogenAdder.getInstance(builder);
hAdder.addImplicitHydrogens(molecule);
AtomContainerManipulator.convertImplicitToExplicitHydrogens(molecule);
}
//there is a bug in cdk?? error happens when there is a S or Ti in the molecule
catch (IllegalArgumentException)
{
return false;
}
return true;
}
示例3: isConnected
/// <summary> Check whether a set of atoms in an atomcontainer is connected
///
/// </summary>
/// <param name="atomContainer"> The AtomContainer to be check for connectedness
/// </param>
/// <returns> true if the AtomContainer is connected
/// </returns>
public static bool isConnected(IAtomContainer atomContainer)
{
IAtomContainer ac = atomContainer.Builder.newAtomContainer();
IAtom atom = null;
IMolecule molecule = atomContainer.Builder.newMolecule();
System.Collections.ArrayList sphere = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
for (int f = 0; f < atomContainer.AtomCount; f++)
{
atom = atomContainer.getAtomAt(f);
atomContainer.getAtomAt(f).setFlag(CDKConstants.VISITED, false);
ac.addAtom(atomContainer.getAtomAt(f));
}
IBond[] bonds = atomContainer.Bonds;
for (int f = 0; f < bonds.Length; f++)
{
bonds[f].setFlag(CDKConstants.VISITED, false);
ac.addBond(bonds[f]);
}
atom = ac.getAtomAt(0);
sphere.Add(atom);
atom.setFlag(CDKConstants.VISITED, true);
PathTools.breadthFirstSearch(ac, sphere, molecule);
if (molecule.AtomCount == atomContainer.AtomCount)
{
return true;
}
return false;
}
示例4: getMorganNumbers
/// <summary> Makes an array containing the morgan numbers of the atoms of atomContainer.
///
/// </summary>
/// <param name="atomContainer"> The atomContainer to analyse.
/// </param>
/// <returns> The morgan numbers value.
/// </returns>
public static int[] getMorganNumbers(IAtomContainer atomContainer)
{
int[] morganMatrix;
int[] tempMorganMatrix;
int N = atomContainer.AtomCount;
morganMatrix = new int[N];
tempMorganMatrix = new int[N];
IAtom[] atoms = null;
for (int f = 0; f < N; f++)
{
morganMatrix[f] = atomContainer.getBondCount(f);
tempMorganMatrix[f] = atomContainer.getBondCount(f);
}
for (int e = 0; e < N; e++)
{
for (int f = 0; f < N; f++)
{
morganMatrix[f] = 0;
atoms = atomContainer.getConnectedAtoms(atomContainer.getAtomAt(f));
for (int g = 0; g < atoms.Length; g++)
{
morganMatrix[f] += tempMorganMatrix[atomContainer.getAtomNumber(atoms[g])];
}
}
Array.Copy(morganMatrix, 0, tempMorganMatrix, 0, N);
}
return tempMorganMatrix;
}
示例5: translateAllPositive
//UPGRADE_NOTE: The initialization of '//logger' was moved to static method 'org.openscience.cdk.geometry.GeometryTools'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
//private static LoggingTool //logger;
/// <summary> Adds an automatically calculated offset to the coordinates of all atoms
/// such that all coordinates are positive and the smallest x or y coordinate
/// is exactly zero, using an external set of coordinates.
/// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
///
/// </summary>
/// <param name="atomCon"> AtomContainer for which all the atoms are translated to
/// positive coordinates
/// </param>
/// <param name="renderingCoordinates"> The set of coordinates to use coming from RendererModel2D
/// </param>
//UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
public static void translateAllPositive(IAtomContainer atomCon, System.Collections.Hashtable renderingCoordinates)
{
//UPGRADE_TODO: The equivalent in .NET for field 'java.lang.Double.MAX_VALUE' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
double minX = System.Double.MaxValue;
//UPGRADE_TODO: The equivalent in .NET for field 'java.lang.Double.MAX_VALUE' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
double minY = System.Double.MaxValue;
IAtom[] atoms = atomCon.Atoms;
for (int i = 0; i < atoms.Length; i++)
{
//UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
if (renderingCoordinates[atoms[i]] == null && atoms[i].getPoint2d() != null)
{
renderingCoordinates[atoms[i]] = new Point2d(atoms[i].getPoint2d().x, atoms[i].getPoint2d().y);
}
//UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
if (renderingCoordinates[atoms[i]] != null)
{
//UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
if (((Point2d)renderingCoordinates[atoms[i]]).x < minX)
{
//UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
minX = ((Point2d)renderingCoordinates[atoms[i]]).x;
}
//UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
if (((Point2d)renderingCoordinates[atoms[i]]).y < minY)
{
//UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
minY = ((Point2d)renderingCoordinates[atoms[i]]).y;
}
}
}
//logger.debug("Translating: minx=" + minX + ", minY=" + minY);
translate2D(atomCon, minX * (-1), minY * (-1), renderingCoordinates);
}
示例6: rebond
/// <summary> Rebonding using a Binary Space Partition Tree. Note, that any bonds
/// defined will be deleted first. It assumes the unit of 3D space to
/// be 1 Âle;ngstrom.
/// </summary>
public virtual void rebond(IAtomContainer container)
{
container.removeAllBonds();
maxCovalentRadius = 0.0;
// construct a new binary space partition tree
bspt = new Bspt(3);
IAtom[] atoms = container.Atoms;
for (int i = atoms.Length; --i >= 0; )
{
IAtom atom = atoms[i];
double myCovalentRadius = atom.CovalentRadius;
if (myCovalentRadius == 0.0)
{
//throw new CDKException("Atom(s) does not have covalentRadius defined.");
}
else
{
if (myCovalentRadius > maxCovalentRadius)
maxCovalentRadius = myCovalentRadius;
TupleAtom tupleAtom = new TupleAtom(atom);
bspt.addTuple(tupleAtom);
}
}
// rebond all atoms
for (int i = atoms.Length; --i >= 0; )
{
bondAtom(container, atoms[i]);
}
}
示例7: isValidDoubleBondConfiguration
/// <summary>
/// Tells if a certain bond is center of a valid double bond configuration.
/// </summary>
/// <param name="container"> The atomcontainer.
/// </param>
/// <param name="bond"> The bond.
/// </param>
/// <returns> true=is a potential configuration, false=is not.
/// </returns>
public static bool isValidDoubleBondConfiguration(IAtomContainer container, IBond bond)
{
IAtom[] atoms = bond.getAtoms();
IAtom[] connectedAtoms = container.getConnectedAtoms(atoms[0]);
IAtom from = null;
for (int i = 0; i < connectedAtoms.Length; i++)
{
if (connectedAtoms[i] != atoms[1])
{
from = connectedAtoms[i];
}
}
bool[] array = new bool[container.Bonds.Length];
for (int i = 0; i < array.Length; i++)
{
array[i] = true;
}
if (isStartOfDoubleBond(container, atoms[0], from, array) && isEndOfDoubleBond(container, atoms[1], atoms[0], array) && !bond.getFlag(CDKConstants.ISAROMATIC))
{
return (true);
}
else
{
return (false);
}
}
示例8: GetResultRow
public ResultRow GetResultRow(IAtomContainer originalCompound, IEnumerable<IAtomContainer> fragments, string compoundId)
{
var assignFragmentHits = AssignHits(fragments);
var fragsPics = assignFragmentHits.AllHits.Reverse();
return new ResultRow(compoundId, originalCompound, fragsPics);
}
示例9: ResultRow
public ResultRow(
string id,
IAtomContainer originalCompound,
IEnumerable<PeakMolPair> fragmentPics)
{
this.id = id;
this.fragmentPics = fragmentPics;
bondEnergy = new BondEnergyCalculator(originalCompound).TotalBondEnergy();
}
示例10: getAtomById
/// <summary> Returna an atom in an atomcontainer identified by id
///
/// </summary>
/// <param name="ac">The AtomContainer to search in
/// </param>
/// <param name="id">The id to search for
/// </param>
/// <returns> An atom having id id
/// </returns>
/// <throws> CDKException There is no such atom </throws>
public static IAtom getAtomById(IAtomContainer ac, System.String id)
{
for (int i = 0; i < ac.AtomCount; i++)
{
if (ac.getAtomAt(i).ID != null && ac.getAtomAt(i).ID.Equals(id))
return ac.getAtomAt(i);
}
throw new CDKException("no suc atom");
}
示例11: GenerateFragments
public ResultRow GenerateFragments(IAtomContainer compound, string compoundId, CancellationToken isCancelled)
{
if (!hydrogenAdder.AddImplicitHydrogens(compound))
{
return null;
}
var fragments = fragmentGenerator.GenerateFragments(compound, compoundId, isCancelled);
return hitsMatcher.GetResultRow(compound, fragments, compoundId);
}
示例12: PeakMolPair
public PeakMolPair(IAtomContainer ac, Peak peak, double matchedMass, string molecularFormula, double hydrogenPenalty, double bondDissociationEnergy, string neutralChange)
{
this.ac = ac;
this.peak = peak;
MatchedMass = matchedMass;
MolecularFormula = molecularFormula;
HydrogenPenalty = hydrogenPenalty;
BondDissociationEnergy = bondDissociationEnergy;
NeutralChange = neutralChange;
}
示例13: MatchByMass
private bool MatchByMass(IAtomContainer ac, double peak, double mzabs, double mzppm, out double matchedMass, out double hydrogenPenalty, out int hydrogensAdded)
{
matchedMass = 0;
hydrogenPenalty = 0;
hydrogensAdded = 0;
double mass;
//speed up and neutral loss matching!
if (ac.getProperty("FragmentMass") != null && (string)ac.getProperty("FragmentMass") != "")
{
mass = double.Parse(ac.getProperty("FragmentMass").ToString(), CultureInfo.InvariantCulture);
}
else
{
mass = MolecularFormulaTools.GetMonoisotopicMass(GetMolecularFormula(ac));
}
var peakLow = peak - mzabs - PpmTool.GetPPMDeviation(peak, mzppm);
var peakHigh = peak + mzabs + PpmTool.GetPPMDeviation(peak, mzppm);
//now try to add/remove neutral hydrogens ...at most the treedepth
var treeDepth = int.Parse((String)ac.getProperty("TreeDepth"));
for (var i = 0; i <= treeDepth; i++)
{
var hMass = i * hydrogenMass;
if ((mass + hMass) >= peakLow && (mass + hMass) <= peakHigh)
{
matchedMass = Math.Round(mass + hMass, 4);
//now add a bond energy equivalent to a H-C bond
hydrogenPenalty = (i * 1000);
hydrogensAdded = i;
return true;
}
if ((mass - hMass) >= peakLow && (mass - hMass) <= peakHigh)
{
matchedMass = Math.Round(mass - hMass, 4);
//now add a bond energy equivalent to a H-C bond
hydrogenPenalty = (i * 1000);
hydrogensAdded = -i;
return true;
}
}
return false;
}
示例14: saturate
/// <summary> Saturates a molecule by setting appropriate bond orders.
///
/// </summary>
/// <cdk.keyword> bond order, calculation </cdk.keyword>
/// <summary>
/// </summary>
/// <cdk.created> 2003-10-03 </cdk.created>
public virtual void saturate(IAtomContainer atomContainer)
{
//logger.info("Saturating atomContainer by adjusting bond orders...");
bool allSaturated = this.allSaturated(atomContainer);
if (!allSaturated)
{
//logger.info("Saturating bond orders is needed...");
bool succeeded = saturate(atomContainer.Bonds, atomContainer);
if (!succeeded)
{
throw new CDKException("Could not saturate this atomContainer!");
}
}
}
示例15: processFormula
/// <summary> Processes the content from the formula field of the INChI.
/// Typical values look like C6H6, from INChI=1.12Beta/C6H6/c1-2-4-6-5-3-1/h1-6H.
/// </summary>
public virtual IAtomContainer processFormula(IAtomContainer parsedContent, System.String atomsEncoding)
{
//logger.debug("Parsing atom data: ", atomsEncoding);
Regex pattern = new Regex("([A-Z][a-z]?)(\\d+)?(.*)");
//Pattern pattern = Pattern.compile("([A-Z][a-z]?)(\\d+)?(.*)");
System.String remainder = atomsEncoding;
while (remainder.Length > 0)
{
//logger.debug("Remaining: ", remainder);
Match matcher = pattern.Match(remainder);
//Matcher matcher = pattern.matcher(remainder);
//if (matcher.matches())
if (matcher != null && matcher.Success)
{
System.String symbol = matcher.Groups[1].Value;
//logger.debug("Atom symbol: ", symbol);
if (symbol.Equals("H"))
{
// don't add explicit hydrogens
}
else
{
System.String occurenceStr = matcher.Groups[2].Value;
int occurence = 1;
if (occurenceStr != null)
{
occurence = System.Int32.Parse(occurenceStr);
}
//logger.debug(" occurence: ", occurence);
for (int i = 1; i <= occurence; i++)
{
parsedContent.addAtom(parsedContent.Builder.newAtom(symbol));
}
}
remainder = matcher.Groups[3].Value;
if (remainder == null)
remainder = "";
//logger.debug(" Remaining: ", remainder);
}
else
{
//logger.error("No match found!");
remainder = "";
}
//logger.debug("NO atoms: ", parsedContent.AtomCount);
}
return parsedContent;
}