本文整理汇总了C#中IAtomContainer.getConnectedBonds方法的典型用法代码示例。如果您正苦于以下问题:C# IAtomContainer.getConnectedBonds方法的具体用法?C# IAtomContainer.getConnectedBonds怎么用?C# IAtomContainer.getConnectedBonds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAtomContainer
的用法示例。
在下文中一共展示了IAtomContainer.getConnectedBonds方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: newSaturate
/// <summary> Saturates a molecule by setting appropriate bond orders.
///
/// </summary>
/// <cdk.keyword> bond order, calculation </cdk.keyword>
/// <cdk.created> 2003-10-03 </cdk.created>
public virtual void newSaturate(IAtomContainer atomContainer)
{
//logger.info("Saturating atomContainer by adjusting bond orders...");
bool allSaturated = this.allSaturated(atomContainer);
if (!allSaturated)
{
bool succeeded = newSaturate(atomContainer.Bonds, atomContainer);
IBond[] bonds = atomContainer.Bonds;
for (int i = 0; i < bonds.Length; i++)
{
if (bonds[i].Order == 2 && bonds[i].getFlag(CDKConstants.ISAROMATIC) && (bonds[i].getAtomAt(0).Symbol.Equals("N") && bonds[i].getAtomAt(1).Symbol.Equals("N")))
{
int atomtohandle = 0;
if (bonds[i].getAtomAt(0).Symbol.Equals("N"))
atomtohandle = 1;
IBond[] bondstohandle = atomContainer.getConnectedBonds(bonds[i].getAtomAt(atomtohandle));
for (int k = 0; k < bondstohandle.Length; k++)
{
if (bondstohandle[k].Order == 1 && bondstohandle[k].getFlag(CDKConstants.ISAROMATIC))
{
bondstohandle[k].Order = 2;
bonds[i].Order = 1;
break;
}
}
}
}
if (!succeeded)
{
throw new CDKException("Could not saturate this atomContainer!");
}
}
}
示例2: calculateNumberOfImplicitHydrogens
public virtual int calculateNumberOfImplicitHydrogens(IAtom atom, IAtomContainer container, bool throwExceptionForUnknowAtom)
{
return this.calculateNumberOfImplicitHydrogens(atom, container.getBondOrderSum(atom), container.getConnectedBonds(atom), throwExceptionForUnknowAtom);
}
示例3: breadthFirstTargetSearch
/// <summary> Performs a breadthFirstTargetSearch in an AtomContainer starting with a
/// particular sphere, which usually consists of one start atom. While
/// searching the graph, the method marks each visited atom. It then puts all
/// the atoms connected to the atoms in the given sphere into a new vector
/// which forms the sphere to search for the next recursive method call.
/// The method keeps track of the sphere count and returns it as soon
/// as the target atom is encountered.
///
/// </summary>
/// <param name="ac"> The AtomContainer in which the path search is to be performed.
/// </param>
/// <param name="sphere"> The sphere of atoms to start with. Usually just the starting atom
/// </param>
/// <param name="target"> The target atom to be searched
/// </param>
/// <param name="pathLength">The current path length, incremented and passed in recursive calls. Call this method with "zero".
/// </param>
/// <param name="cutOff"> Stop the path search when this cutOff sphere count has been reached
/// </param>
/// <returns> The shortest path between the starting sphere and the target atom
/// </returns>
public static int breadthFirstTargetSearch(IAtomContainer ac, System.Collections.ArrayList sphere, IAtom target, int pathLength, int cutOff)
{
if (pathLength == 0)
resetFlags(ac);
pathLength++;
if (pathLength > cutOff)
{
return -1;
}
IAtom atom;
IAtom nextAtom;
System.Collections.ArrayList newSphere = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
for (int f = 0; f < sphere.Count; f++)
{
atom = (IAtom)sphere[f];
IBond[] bonds = ac.getConnectedBonds(atom);
for (int g = 0; g < bonds.Length; g++)
{
if (!bonds[g].getFlag(CDKConstants.VISITED))
{
bonds[g].setFlag(CDKConstants.VISITED, true);
}
nextAtom = bonds[g].getConnectedAtom(atom);
if (!nextAtom.getFlag(CDKConstants.VISITED))
{
if (nextAtom == target)
{
return pathLength;
}
newSphere.Add(nextAtom);
nextAtom.setFlag(CDKConstants.VISITED, true);
}
}
}
if (newSphere.Count > 0)
{
return breadthFirstTargetSearch(ac, newSphere, target, pathLength, cutOff);
}
return -1;
}
示例4: makeAtomsMapOfBondsMap
/// <summary> This makes a map of matching atoms out of a map of matching bonds as produced by the get(Subgraph|Ismorphism)Map methods.
///
/// </summary>
/// <param name="l"> The list produced by the getMap method.
/// </param>
/// <param name="g1"> The first atom container.
/// </param>
/// <param name="g2"> The second one (first and second as in getMap)
/// </param>
/// <returns> The mapping found projected on g1. This is a List of RMap objects containing Ids of matching atoms.
/// </returns>
public static System.Collections.IList makeAtomsMapOfBondsMap(System.Collections.IList l, IAtomContainer g1, IAtomContainer g2)
{
if (l == null)
return (l);
IBond[] bonds1 = g1.Bonds;
IBond[] bonds2 = g2.Bonds;
System.Collections.IList result = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
for (int i = 0; i < l.Count; i++)
{
IBond bond1 = bonds1[((RMap)l[i]).Id1];
IBond bond2 = bonds2[((RMap)l[i]).Id2];
IAtom[] atom1 = bond1.getAtoms();
IAtom[] atom2 = bond2.getAtoms();
for (int j = 0; j < 2; j++)
{
IBond[] bondsConnectedToAtom1j = g1.getConnectedBonds(atom1[j]);
for (int k = 0; k < bondsConnectedToAtom1j.Length; k++)
{
if (bondsConnectedToAtom1j[k] != bond1)
{
IBond testBond = bondsConnectedToAtom1j[k];
for (int m = 0; m < l.Count; m++)
{
IBond testBond2;
if (((RMap)l[m]).Id1 == g1.getBondNumber(testBond))
{
testBond2 = bonds2[((RMap)l[m]).Id2];
for (int n = 0; n < 2; n++)
{
System.Collections.IList bondsToTest = g2.getConnectedBondsVector(atom2[n]);
if (bondsToTest.Contains(testBond2))
{
RMap map;
if (j == n)
{
map = new RMap(g1.getAtomNumber(atom1[0]), g2.getAtomNumber(atom2[0]));
}
else
{
map = new RMap(g1.getAtomNumber(atom1[1]), g2.getAtomNumber(atom2[0]));
}
if (!result.Contains(map))
{
result.Add(map);
}
RMap map2;
if (j == n)
{
map2 = new RMap(g1.getAtomNumber(atom1[1]), g2.getAtomNumber(atom2[1]));
}
else
{
map2 = new RMap(g1.getAtomNumber(atom1[0]), g2.getAtomNumber(atom2[1]));
}
if (!result.Contains(map2))
{
result.Add(map2);
}
}
}
}
}
}
}
}
}
return (result);
}
示例5: depthFirstTargetSearch
/// <summary> Recursivly perfoms a depth first search in a molecular graphs contained in
/// the AtomContainer molecule, starting at the root atom and returning when it
/// hits the target atom.
/// CAUTION: This recursive method sets the VISITED flag of each atom
/// does not reset it after finishing the search. If you want to do the
/// operation on the same collection of atoms more than once, you have
/// to set all the VISITED flags to false before each operation
/// by looping of the atoms and doing a
/// "atom.setFlag((CDKConstants.VISITED, false));"
///
/// </summary>
/// <param name="molecule">The
/// AtomContainer to be searched
/// </param>
/// <param name="root"> The root atom
/// to start the search at
/// </param>
/// <param name="target"> The target
/// </param>
/// <param name="path"> An
/// AtomContainer to be filled with the path
/// </param>
/// <returns> true if the
/// target atom was found during this function call
/// </returns>
public static bool depthFirstTargetSearch(IAtomContainer molecule, IAtom root, IAtom target, IAtomContainer path)
{
IBond[] bonds = molecule.getConnectedBonds(root);
IAtom nextAtom;
root.setFlag(CDKConstants.VISITED, true);
for (int f = 0; f < bonds.Length; f++)
{
nextAtom = bonds[f].getConnectedAtom(root);
if (!nextAtom.getFlag(CDKConstants.VISITED))
{
path.addAtom(nextAtom);
path.addBond(bonds[f]);
if (nextAtom == target)
{
return true;
}
else
{
if (!depthFirstTargetSearch(molecule, nextAtom, target, path))
{
// we did not find the target
path.removeAtom(nextAtom);
path.removeElectronContainer(bonds[f]);
}
else
{
return true;
}
}
}
}
return false;
}
示例6: breadthFirstSearch
/// <summary> Performs a breadthFirstSearch in an AtomContainer starting with a
/// particular sphere, which usually consists of one start atom. While
/// searching the graph, the method marks each visited atom. It then puts all
/// the atoms connected to the atoms in the given sphere into a new vector
/// which forms the sphere to search for the next recursive method call. All
/// atoms that have been visited are put into a molecule container. This
/// breadthFirstSearch does thus find the connected graph for a given start
/// atom.
///
/// </summary>
/// <param name="ac"> The AtomContainer to be searched
/// </param>
/// <param name="sphere"> A sphere of atoms to start the search with
/// </param>
/// <param name="molecule">A molecule into which all the atoms and bonds are stored
/// that are found during search
/// </param>
public static void breadthFirstSearch(IAtomContainer ac, System.Collections.ArrayList sphere, IMolecule molecule, int max)
{
IAtom atom;
IAtom nextAtom;
System.Collections.ArrayList newSphere = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
for (int f = 0; f < sphere.Count; f++)
{
atom = (IAtom)sphere[f];
//System.out.println("atoms "+ atom + f);
//System.out.println("sphere size "+ sphere.size());
molecule.addAtom(atom);
// first copy LonePair's and SingleElectron's of this Atom as they need
// to be copied too
IElectronContainer[] eContainers = ac.getConnectedElectronContainers(atom);
//System.out.println("found #ec's: " + eContainers.length);
for (int i = 0; i < eContainers.Length; i++)
{
if (!(eContainers[i] is IBond))
{
// ok, no bond, thus LonePair or SingleElectron
// System.out.println("adding non bond " + eContainers[i]);
molecule.addElectronContainer(eContainers[i]);
}
}
// now look at bonds
IBond[] bonds = ac.getConnectedBonds(atom);
for (int g = 0; g < bonds.Length; g++)
{
if (!bonds[g].getFlag(CDKConstants.VISITED))
{
molecule.addBond(bonds[g]);
bonds[g].setFlag(CDKConstants.VISITED, true);
}
nextAtom = bonds[g].getConnectedAtom(atom);
if (!nextAtom.getFlag(CDKConstants.VISITED))
{
// System.out.println("wie oft???");
newSphere.Add(nextAtom);
nextAtom.setFlag(CDKConstants.VISITED, true);
}
}
if (max > -1 && molecule.AtomCount > max)
return;
}
if (newSphere.Count > 0)
{
breadthFirstSearch(ac, newSphere, molecule, max);
}
}
示例7: isAromatic
/// <summary> Tests the <code>ring</code> in the <code>molecule</code> for aromaticity. Uses the
/// Hückle rule (4n + 2) pie electrons. sp<sup>2</sup> hybridized C contibute 1 electron non
/// sp<sup>2</sup> hybridized heteroatoms contribute 2 electrons (N and O should never be sp in
/// or anything else in a ring and d electron elements get to complicated)
/// sp<sup>2</sup> hybridized heteroatoms contribute 1 electron hybridization is worked out by
/// counting the number of bonds with order 2. Therefore sp<sup>2</sup> hybridization is assumed
/// if there is one bond of order 2. Otherwise sp<sup>3</sup> hybridization is assumed.
///
/// </summary>
/// <param name="ring"> the ring to test
/// </param>
/// <param name="atomContainer"> the AtomContainer the ring is in
/// </param>
/// <returns> true if the ring is aromatic false otherwise.
/// </returns>
protected internal static bool isAromatic(IRing ring, IAtomContainer atomContainer)
{
IAtom[] ringAtoms = ring.Atoms;
int eCount = 0;
IBond[] conectedBonds;
int numDoubleBond = 0;
bool allConnectedBondsSingle;
for (int i = 0; i < ringAtoms.Length; i++)
{
IAtom atom = ringAtoms[i];
numDoubleBond = 0;
allConnectedBondsSingle = true;
conectedBonds = atomContainer.getConnectedBonds(atom);
for (int j = 0; j < conectedBonds.Length; j++)
{
IBond bond = conectedBonds[j];
if (bond.Order == 2 && ring.contains(bond))
{
numDoubleBond++;
}
// Count the Electron if bond order = 1.5
else if (bond.Order == 1.5 && ring.contains(bond))
{
numDoubleBond = 1;
}
if (bond.Order != 1)
{
allConnectedBondsSingle = false;
}
}
if (numDoubleBond == 1)
{
//C or heteroatoms both contibute 1 electron in sp2 hybridized form
eCount++;
}
else if (!atom.Symbol.Equals("C"))
{
//Heteroatom probably in sp3 hybrid therefore 2 electrons contributed.
eCount = eCount + 2;
}
else if (atom.getFlag(CDKConstants.ISAROMATIC))
{
eCount++;
}
else if (allConnectedBondsSingle && atom.Symbol.Equals("C") && atom.getFormalCharge() == 1.0)
{
// This is for tropylium and kinds.
// Dependence on hybridisation would be better:
// empty p-orbital is needed
continue;
}
else
{
return false;
}
}
if (eCount - 2 != 0 && (eCount - 2) % 4 == 0)
{
return true;
}
return false;
}
示例8: isSquarePlanar
/// <summary> Says if an atom as a center of a square planar chirality
///
/// </summary>
/// <param name="a"> The atom which is the center
/// </param>
/// <param name="container"> The atomContainer the atom is in
/// </param>
/// <returns> true=is square planar, false=is not
/// </returns>
public static bool isSquarePlanar(IAtomContainer container, IAtom a)
{
IAtom[] atoms = container.getConnectedAtoms(a);
if (atoms.Length != 4)
{
return (false);
}
IBond[] bonds = container.getConnectedBonds(a);
int normal = 0;
int up = 0;
int down = 0;
for (int i = 0; i < bonds.Length; i++)
{
if (bonds[i].Stereo == CDKConstants.STEREO_BOND_UNDEFINED || bonds[i].Stereo == CDKConstants.STEREO_BOND_NONE)
{
normal++;
}
if (bonds[i].Stereo == CDKConstants.STEREO_BOND_UP)
{
up++;
}
if (bonds[i].Stereo == CDKConstants.STEREO_BOND_DOWN)
{
down++;
}
}
if (up == 2 && down == 2 && !stereosAreOpposite(container, a))
{
return true;
}
return false;
}
示例9: isStereo
/// <summary> Says if an atom as a center of any valid stereo configuration or not
///
/// </summary>
/// <param name="a"> The atom which is the center
/// </param>
/// <param name="container"> The atomContainer the atom is in
/// </param>
/// <returns> true=is a stereo atom, false=is not
/// </returns>
public static bool isStereo(IAtomContainer container, IAtom a)
{
IAtom[] atoms = container.getConnectedAtoms(a);
if (atoms.Length < 4 || atoms.Length > 6)
{
return (false);
}
IBond[] bonds = container.getConnectedBonds(a);
int stereo = 0;
for (int i = 0; i < bonds.Length; i++)
{
if (bonds[i].Stereo != 0)
{
stereo++;
}
}
if (stereo == 0)
{
return false;
}
int differentAtoms = 0;
for (int i = 0; i < atoms.Length; i++)
{
bool isDifferent = true;
for (int k = 0; k < i; k++)
{
if (atoms[i].Symbol.Equals(atoms[k].Symbol))
{
isDifferent = false;
break;
}
}
if (isDifferent)
{
differentAtoms++;
}
}
if (differentAtoms != atoms.Length)
{
int[] morgannumbers = MorganNumbersTools.getMorganNumbers(container);
System.Collections.ArrayList differentSymbols = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
for (int i = 0; i < atoms.Length; i++)
{
if (!differentSymbols.Contains(atoms[i].Symbol))
{
differentSymbols.Add(atoms[i].Symbol);
}
}
int[] onlyRelevantIfTwo = new int[2];
if (differentSymbols.Count == 2)
{
for (int i = 0; i < atoms.Length; i++)
{
if (differentSymbols.IndexOf(atoms[i].Symbol) == 0)
{
onlyRelevantIfTwo[0]++;
}
else
{
onlyRelevantIfTwo[1]++;
}
}
}
bool[] symbolsWithDifferentMorganNumbers = new bool[differentSymbols.Count];
System.Collections.ArrayList[] symbolsMorganNumbers = new System.Collections.ArrayList[differentSymbols.Count];
for (int i = 0; i < symbolsWithDifferentMorganNumbers.Length; i++)
{
symbolsWithDifferentMorganNumbers[i] = true;
symbolsMorganNumbers[i] = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
}
for (int k = 0; k < atoms.Length; k++)
{
int elementNumber = differentSymbols.IndexOf(atoms[k].Symbol);
if (symbolsMorganNumbers[elementNumber].Contains((System.Int32)morgannumbers[container.getAtomNumber(atoms[k])]))
{
symbolsWithDifferentMorganNumbers[elementNumber] = false;
}
else
{
symbolsMorganNumbers[elementNumber].Add((System.Int32)morgannumbers[container.getAtomNumber(atoms[k])]);
}
}
int numberOfSymbolsWithDifferentMorganNumbers = 0;
for (int i = 0; i < symbolsWithDifferentMorganNumbers.Length; i++)
{
if (symbolsWithDifferentMorganNumbers[i] == true)
{
numberOfSymbolsWithDifferentMorganNumbers++;
}
}
if (numberOfSymbolsWithDifferentMorganNumbers != differentSymbols.Count)
//.........这里部分代码省略.........
示例10: isTrigonalBipyramidalOrOctahedral
/// <summary> Says if an atom as a center of a trigonal-bipyramidal or actahedral
/// chirality
///
/// </summary>
/// <param name="a"> The atom which is the center
/// </param>
/// <param name="container"> The atomContainer the atom is in
/// </param>
/// <returns> true=is square planar, false=is not
/// </returns>
public static int isTrigonalBipyramidalOrOctahedral(IAtomContainer container, IAtom a)
{
IAtom[] atoms = container.getConnectedAtoms(a);
if (atoms.Length < 5 || atoms.Length > 6)
{
return (0);
}
IBond[] bonds = container.getConnectedBonds(a);
int normal = 0;
int up = 0;
int down = 0;
for (int i = 0; i < bonds.Length; i++)
{
if (bonds[i].Stereo == CDKConstants.STEREO_BOND_UNDEFINED || bonds[i].Stereo == CDKConstants.STEREO_BOND_NONE)
{
normal++;
}
if (bonds[i].Stereo == CDKConstants.STEREO_BOND_UP)
{
up++;
}
if (bonds[i].Stereo == CDKConstants.STEREO_BOND_DOWN)
{
down++;
}
}
if (up == 1 && down == 1)
{
if (atoms.Length == 5)
return 1;
else
return 2;
}
return 0;
}
示例11: isTetrahedral
/// <summary> Says if an atom as a center of a tetrahedral chirality
///
/// </summary>
/// <param name="a"> The atom which is the center
/// </param>
/// <param name="container"> The atomContainer the atom is in
/// </param>
/// <returns> 0=is not tetrahedral;>1 is a certain depiction of
/// tetrahedrality (evaluated in parse chain)
/// </returns>
public static int isTetrahedral(IAtomContainer container, IAtom a, bool strict)
{
IAtom[] atoms = container.getConnectedAtoms(a);
if (atoms.Length != 4)
{
return (0);
}
IBond[] bonds = container.getConnectedBonds(a);
int normal = 0;
int up = 0;
int down = 0;
for (int i = 0; i < bonds.Length; i++)
{
if (bonds[i].Stereo == CDKConstants.STEREO_BOND_NONE || bonds[i].Stereo == CDKConstants.STEREO_BOND_UNDEFINED)
{
normal++;
}
if (bonds[i].Stereo == CDKConstants.STEREO_BOND_UP)
{
up++;
}
if (bonds[i].Stereo == CDKConstants.STEREO_BOND_DOWN)
{
down++;
}
}
if (up == 1 && down == 1)
{
return 1;
}
if (up == 2 && down == 2)
{
if (stereosAreOpposite(container, a))
{
return 2;
}
return 0;
}
if (up == 1 && down == 0 && !strict)
{
return 3;
}
if (down == 1 && up == 0 && !strict)
{
return 4;
}
if (down == 2 && up == 1 && !strict)
{
return 5;
}
if (down == 1 && up == 2 && !strict)
{
return 6;
}
return 0;
}