当前位置: 首页>>代码示例>>C#>>正文


C# IAtomContainer.getConnectedAtoms方法代码示例

本文整理汇总了C#中IAtomContainer.getConnectedAtoms方法的典型用法代码示例。如果您正苦于以下问题:C# IAtomContainer.getConnectedAtoms方法的具体用法?C# IAtomContainer.getConnectedAtoms怎么用?C# IAtomContainer.getConnectedAtoms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAtomContainer的用法示例。


在下文中一共展示了IAtomContainer.getConnectedAtoms方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
     }
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:35,代码来源:BondTools.cs

示例2: 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;
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:35,代码来源:MorganNumbersTools.cs

示例3: calculateNumberOfImplicitHydrogens

		public virtual int calculateNumberOfImplicitHydrogens(IAtom atom, IAtomContainer container)
		{
			return this.calculateNumberOfImplicitHydrogens(atom, container.getBondOrderSum(atom), container.getMaximumBondOrder(atom), container.getConnectedAtoms(atom).Length);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:4,代码来源:ValencyHybridChecker.cs

示例4: parseChain

        /// <summary>  Parse a branch
        /// 
        /// </summary>
        /// <param name="v">                       Description of Parameter
        /// </param>
        /// <param name="buffer">                  Description of Parameter
        /// </param>
        /// <param name="container">               Description of Parameter
        /// </param>
        /// <param name="parent">                  Description of Parameter
        /// </param>
        /// <param name="chiral">                  Description of Parameter
        /// </param>
        /// <param name="doubleBondConfiguration"> Description of Parameter
        /// </param>
        /// <param name="atomsInOrderOfSmiles">    Description of Parameter
        /// </param>
        private void parseChain(System.Collections.ArrayList v, System.Text.StringBuilder buffer, IAtomContainer container, IAtom parent, bool chiral, bool[] doubleBondConfiguration, System.Collections.ArrayList atomsInOrderOfSmiles)
        {
            int positionInVector = 0;
            IAtom atom;
            //System.out.println("in parse chain. Size of tree: " + v.size());
            for (int h = 0; h < v.Count; h++)
            {
                System.Object o = v[h];
                if (o is IAtom)
                {
                    atom = (IAtom)o;
                    if (parent != null)
                    {
                        parseBond(buffer, atom, parent, container);
                    }
                    else
                    {
                        if (chiral && BondTools.isStereo(container, atom))
                        {
                            parent = (IAtom)((System.Collections.ArrayList)v[1])[0];
                        }
                    }
                    parseAtom(atom, buffer, container, chiral, doubleBondConfiguration, parent, atomsInOrderOfSmiles, v);
                    //System.out.println("in parseChain after parseAtom()");
                    /*
                    *  The principle of making chiral smiles is quite simple, although the code is
                    *  pretty uggly. The Atoms connected to the chiral center are put in sorted[] in the
                    *  order they have to appear in the smiles. Then the Vector v is rearranged according
                    *  to sorted[]
                    */
                    if (chiral && BondTools.isStereo(container, atom) && container.getBond(parent, atom) != null)
                    {
                        //System.out.println("in parseChain in isChiral");
                        IAtom[] sorted = null;
                        System.Collections.IList chiralNeighbours = container.getConnectedAtomsVector(atom);
                        if (BondTools.isTetrahedral(container, atom, false) > 0)
                        {
                            sorted = new IAtom[3];
                        }
                        if (BondTools.isTetrahedral(container, atom, false) == 1)
                        {
                            if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_DOWN)
                            {
                                for (int i = 0; i < chiralNeighbours.Count; i++)
                                {
                                    if (chiralNeighbours[i] != parent)
                                    {
                                        if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom))
                                        {
                                            sorted[2] = (IAtom)chiralNeighbours[i];
                                        }
                                        if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom))
                                        {
                                            sorted[1] = (IAtom)chiralNeighbours[i];
                                        }
                                        if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom)chiralNeighbours[i], atom))
                                        {
                                            sorted[0] = (IAtom)chiralNeighbours[i];
                                        }
                                    }
                                }
                            }
                            if (container.getBond(parent, atom).Stereo == CDKConstants.STEREO_BOND_UP)
                            {
                                for (int i = 0; i < chiralNeighbours.Count; i++)
                                {
                                    if (chiralNeighbours[i] != parent)
                                    {
                                        if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom))
                                        {
                                            sorted[1] = (IAtom)chiralNeighbours[i];
                                        }
                                        if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == 0 && !BondTools.isLeft(((IAtom)chiralNeighbours[i]), parent, atom) && !isBondBroken((IAtom)chiralNeighbours[i], atom))
                                        {
                                            sorted[2] = (IAtom)chiralNeighbours[i];
                                        }
                                        if (container.getBond((IAtom)chiralNeighbours[i], atom).Stereo == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom)chiralNeighbours[i], atom))
                                        {
                                            sorted[0] = (IAtom)chiralNeighbours[i];
                                        }
                                    }
                                }
                            }
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:SmilesGenerator.cs

示例5: isStartOfDoubleBond

 /// <summary>  Says if an atom is the start of a double bond configuration
 /// 
 /// </summary>
 /// <param name="a">                       The atom which is the start of configuration
 /// </param>
 /// <param name="container">               The atomContainer the atom is in
 /// </param>
 /// <param name="parent">                  The atom we came from
 /// </param>
 /// <param name="doubleBondConfiguration"> The array indicating where double bond
 /// configurations are specified (this method ensures that there is
 /// actually the possibility of a double bond configuration)
 /// </param>
 /// <returns>                          false=is not start of configuration, true=is
 /// </returns>
 private bool isStartOfDoubleBond(IAtomContainer container, IAtom a, IAtom parent, bool[] doubleBondConfiguration)
 {
     int lengthAtom = container.getConnectedAtoms(a).Length + a.getHydrogenCount();
     if (lengthAtom != 3 && (lengthAtom != 2 && (System.Object)a.Symbol != (System.Object)("N")))
     {
         return (false);
     }
     IAtom[] atoms = container.getConnectedAtoms(a);
     IAtom one = null;
     IAtom two = null;
     bool doubleBond = false;
     IAtom nextAtom = null;
     for (int i = 0; i < atoms.Length; i++)
     {
         if (atoms[i] != parent && container.getBond(atoms[i], a).Order == CDKConstants.BONDORDER_DOUBLE && isEndOfDoubleBond(container, atoms[i], a, doubleBondConfiguration))
         {
             doubleBond = true;
             nextAtom = atoms[i];
         }
         if (atoms[i] != nextAtom && one == null)
         {
             one = atoms[i];
         }
         else if (atoms[i] != nextAtom && one != null)
         {
             two = atoms[i];
         }
     }
     System.String[] morgannumbers = MorganNumbersTools.getMorganNumbersWithElementSymbol(container);
     if (one != null && ((!a.Symbol.Equals("N") && two != null && !morgannumbers[container.getAtomNumber(one)].Equals(morgannumbers[container.getAtomNumber(two)]) && doubleBond && doubleBondConfiguration[container.getBondNumber(a, nextAtom)]) || (doubleBond && a.Symbol.Equals("N") && System.Math.Abs(BondTools.giveAngleBothMethods(nextAtom, a, parent, true)) > System.Math.PI / 10)))
     {
         return (true);
     }
     else
     {
         return (false);
     }
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:53,代码来源:SmilesGenerator.cs

示例6: isEndOfDoubleBond

 /// <summary>  Says if an atom is the end of a double bond configuration
 /// 
 /// </summary>
 /// <param name="atom">                    The atom which is the end of configuration
 /// </param>
 /// <param name="container">               The atomContainer the atom is in
 /// </param>
 /// <param name="parent">                  The atom we came from
 /// </param>
 /// <param name="doubleBondConfiguration"> The array indicating where double bond
 /// configurations are specified (this method ensures that there is
 /// actually the possibility of a double bond configuration)
 /// </param>
 /// <returns>                          false=is not end of configuration, true=is
 /// </returns>
 private bool isEndOfDoubleBond(IAtomContainer container, IAtom atom, IAtom parent, bool[] doubleBondConfiguration)
 {
     if (container.getBondNumber(atom, parent) == -1 || doubleBondConfiguration.Length <= container.getBondNumber(atom, parent) || !doubleBondConfiguration[container.getBondNumber(atom, parent)])
     {
         return false;
     }
     int lengthAtom = container.getConnectedAtoms(atom).Length + atom.getHydrogenCount();
     int lengthParent = container.getConnectedAtoms(parent).Length + parent.getHydrogenCount();
     if (container.getBond(atom, parent) != null)
     {
         if (container.getBond(atom, parent).Order == CDKConstants.BONDORDER_DOUBLE && (lengthAtom == 3 || (lengthAtom == 2 && atom.Symbol.Equals("N"))) && (lengthParent == 3 || (lengthParent == 2 && parent.Symbol.Equals("N"))))
         {
             IAtom[] atoms = container.getConnectedAtoms(atom);
             IAtom one = null;
             IAtom two = null;
             for (int i = 0; i < atoms.Length; i++)
             {
                 if (atoms[i] != parent && one == null)
                 {
                     one = atoms[i];
                 }
                 else if (atoms[i] != parent && one != null)
                 {
                     two = atoms[i];
                 }
             }
             System.String[] morgannumbers = MorganNumbersTools.getMorganNumbersWithElementSymbol(container);
             if ((one != null && two == null && atom.Symbol.Equals("N") && System.Math.Abs(BondTools.giveAngleBothMethods(parent, atom, one, true)) > System.Math.PI / 10) || (!atom.Symbol.Equals("N") && one != null && two != null && !morgannumbers[container.getAtomNumber(one)].Equals(morgannumbers[container.getAtomNumber(two)])))
             {
                 return (true);
             }
             else
             {
                 return (false);
             }
         }
     }
     return (false);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:54,代码来源:SmilesGenerator.cs

示例7: 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;
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:45,代码来源:BondTools.cs

示例8: getBondLengthRMSD

 /// <summary>  Return the RMSD of bonds length between the 2 aligned molecules.
 /// 
 /// </summary>
 /// <param name="firstAtomContainer">               the (largest) first aligned AtomContainer which is the reference
 /// </param>
 /// <param name="secondAtomContainer">              the second aligned AtomContainer
 /// </param>
 /// <param name="mappedAtoms">            			Map: a Map of the mapped atoms
 /// </param>
 /// <param name="Coords3d">           			    boolean: true if moecules has 3D coords, false if molecules has 2D coords
 /// </param>
 /// <returns>                   				double: all the RMSD of bonds length
 /// </returns>
 /// <exception cref="CDK">*
 /// 
 /// </exception>
 public static double getBondLengthRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, System.Collections.IDictionary mappedAtoms, bool Coords3d)
 {
     //System.out.println("**** GT getBondLengthRMSD ****");
     //UPGRADE_TODO: Method 'java.util.Map.keySet' was converted to 'CSGraphT.SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilMapkeySet'"
     System.Collections.IEnumerator firstAtoms = new CSGraphT.SupportClass.HashSetSupport(mappedAtoms.Keys).GetEnumerator();
     IAtom centerAtomFirstMolecule = null;
     IAtom centerAtomSecondMolecule = null;
     IAtom[] connectedAtoms = null;
     double sum = 0;
     double n = 0;
     double distance1 = 0;
     double distance2 = 0;
     setVisitedFlagsToFalse(firstAtomContainer);
     setVisitedFlagsToFalse(secondAtomContainer);
     //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' 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_javautilIteratorhasNext'"
     while (firstAtoms.MoveNext())
     {
         //UPGRADE_TODO: Method 'java.util.Iterator.next' 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_javautilIteratornext'"
         centerAtomFirstMolecule = firstAtomContainer.getAtomAt(((System.Int32)firstAtoms.Current));
         centerAtomFirstMolecule.setFlag(CDKConstants.VISITED, true);
         centerAtomSecondMolecule = secondAtomContainer.getAtomAt(((System.Int32)mappedAtoms[(System.Int32)firstAtomContainer.getAtomNumber(centerAtomFirstMolecule)]));
         connectedAtoms = firstAtomContainer.getConnectedAtoms(centerAtomFirstMolecule);
         for (int i = 0; i < connectedAtoms.Length; i++)
         {
             //this step is built to know if the program has already calculate a bond length (so as not to have duplicate values)
             if (!connectedAtoms[i].getFlag(CDKConstants.VISITED))
             {
                 if (Coords3d)
                 {
                     distance1 = ((Point3d)centerAtomFirstMolecule.getPoint3d()).distance(connectedAtoms[i].getPoint3d());
                     distance2 = ((Point3d)centerAtomSecondMolecule.getPoint3d()).distance(secondAtomContainer.getAtomAt(((System.Int32)mappedAtoms[(System.Int32)firstAtomContainer.getAtomNumber(connectedAtoms[i])])).getPoint3d());
                     sum = sum + System.Math.Pow((distance1 - distance2), 2);
                     n++;
                 }
                 else
                 {
                     distance1 = ((Point2d)centerAtomFirstMolecule.getPoint2d()).distance(connectedAtoms[i].getPoint2d());
                     distance2 = ((Point2d)centerAtomSecondMolecule.getPoint2d()).distance(secondAtomContainer.getAtomAt(((System.Int32)mappedAtoms[(System.Int32)firstAtomContainer.getAtomNumber(connectedAtoms[i])])).getPoint2d());
                     sum = sum + System.Math.Pow((distance1 - distance2), 2);
                     n++;
                 }
             }
         }
     }
     setVisitedFlagsToFalse(firstAtomContainer);
     setVisitedFlagsToFalse(secondAtomContainer);
     return System.Math.Sqrt(sum / n);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:64,代码来源:GeometryTools.cs

示例9: createInvarLabel

 /// <summary> Create initial invariant labeling corresponds to step 1
 /// 
 /// </summary>
 /// <returns> Vector containting the
 /// </returns>
 private System.Collections.ArrayList createInvarLabel(IAtomContainer atomContainer)
 {
     IAtom[] atoms = atomContainer.Atoms;
     IAtom a;
     System.Text.StringBuilder inv;
     System.Collections.ArrayList vect = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
     for (int x = 0; x < atoms.Length; x++)
     {
         a = atoms[x];
         inv = new System.Text.StringBuilder();
         inv.Append(atomContainer.getConnectedAtoms(a).Length + a.getHydrogenCount()); //Num connections
         inv.Append(atomContainer.getConnectedAtoms(a).Length); //Num of non H bonds
         inv.Append(a.AtomicNumber); //Atomic number
         if (a.getCharge() < 0)
             //Sign of charge
             inv.Append(1);
         else
             inv.Append(0); //Absolute charge
         inv.Append((int)System.Math.Abs(a.getFormalCharge())); //Hydrogen count
         inv.Append(a.getHydrogenCount());
         vect.Add(new InvPair(System.Int64.Parse(inv.ToString()), a));
     }
     return vect;
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:29,代码来源:CanonicalLabeler.cs

示例10: getShortestPath

        /// <summary> Returns a list of atoms in the shortest path between two atoms.
        /// 
        /// This method uses the Djikstra algorithm to find all the atoms in the shortest
        /// path between the two specified atoms. The start and end atoms are also included
        /// in the path returned
        /// 
        /// </summary>
        /// <param name="atomContainer">The molecule to search in
        /// </param>
        /// <param name="start">The starting atom
        /// </param>
        /// <param name="end">The ending atom
        /// </param>
        /// <returns> A <code>List</code> containing the atoms in the shortest path between <code>start</code> and
        /// <code>end</code> inclusive
        /// </returns>
        public static System.Collections.IList getShortestPath(IAtomContainer atomContainer, IAtom start, IAtom end)
        {
            int natom = atomContainer.AtomCount;
            int endNumber = atomContainer.getAtomNumber(end);
            int startNumber = atomContainer.getAtomNumber(start);
            int[] d = new int[natom];
            int[] previous = new int[natom];
            for (int i = 0; i < natom; i++)
            {
                d[i] = 99999999;
                previous[i] = -1;
            }
            d[atomContainer.getAtomNumber(start)] = 0;

            System.Collections.ArrayList S = new System.Collections.ArrayList();
            System.Collections.ArrayList Q = new System.Collections.ArrayList();
            for (int i = 0; i < natom; i++)
                Q.Add((System.Int32)i);

            while (true)
            {
                if (Q.Count == 0)
                    break;

                // extract min
                int u = 999999;
                int index = 0;
                for (int i = 0; i < Q.Count; i++)
                {
                    int tmp = ((System.Int32)Q[i]);
                    if (d[tmp] < u)
                    {
                        u = d[tmp];
                        index = i;
                    }
                }
                Q.RemoveAt(index);
                S.Add(atomContainer.getAtomAt(u));
                if (u == endNumber)
                    break;

                // relaxation
                IAtom[] connected = atomContainer.getConnectedAtoms(atomContainer.getAtomAt(u));
                for (int i = 0; i < connected.Length; i++)
                {
                    int anum = atomContainer.getAtomNumber(connected[i]);
                    if (d[anum] > d[u] + 1)
                    {
                        // all edges have equals weights
                        d[anum] = d[u] + 1;
                        previous[anum] = u;
                    }
                }
            }

            System.Collections.ArrayList tmp2 = new System.Collections.ArrayList();
            int u2 = endNumber;
            while (true)
            {
                tmp2.Insert(0, atomContainer.getAtomAt(u2));
                u2 = previous[u2];
                if (u2 == startNumber)
                {
                    tmp2.Insert(0, atomContainer.getAtomAt(u2));
                    break;
                }
            }
            return tmp2;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:85,代码来源:PathTools.cs

示例11: makeUpDownBonds

 public static void makeUpDownBonds(IAtomContainer container)
 {
     for (int i = 0; i < container.AtomCount; i++)
     {
         IAtom a = container.getAtomAt(i);
         if (container.getConnectedAtoms(a).Length == 4)
         {
             int up = 0;
             int down = 0;
             int hs = 0;
             IAtom h = null;
             for (int k = 0; k < 4; k++)
             {
                 if (container.getBond(a, container.getConnectedAtoms(a)[k]).Stereo == CDKConstants.STEREO_BOND_UP)
                 {
                     up++;
                 }
                 if (container.getBond(a, container.getConnectedAtoms(a)[k]).Stereo == CDKConstants.STEREO_BOND_DOWN)
                 {
                     down++;
                 }
                 if (container.getBond(a, container.getConnectedAtoms(a)[k]).Stereo == CDKConstants.STEREO_BOND_NONE && container.getConnectedAtoms(a)[k].Symbol.Equals("H"))
                 {
                     h = container.getConnectedAtoms(a)[k];
                     hs++;
                 }
             }
             if (up == 0 && down == 1 && h != null && hs == 1)
             {
                 container.getBond(a, h).Stereo = CDKConstants.STEREO_BOND_UP;
             }
             if (up == 1 && down == 0 && h != null && hs == 1)
             {
                 container.getBond(a, h).Stereo = CDKConstants.STEREO_BOND_DOWN;
             }
         }
     }
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:38,代码来源:BondTools.cs

示例12: 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;
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:41,代码来源:BondTools.cs

示例13: 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)
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:BondTools.cs

示例14: getBestAlignmentForLabel

 /// <summary>  Determines the best alignment for the label of an atom in 2D space. It
 /// returns 1 if left aligned, and -1 if right aligned.
 /// See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
 /// 
 /// </summary>
 /// <param name="container"> Description of the Parameter
 /// </param>
 /// <param name="atom">      Description of the Parameter
 /// </param>
 /// <returns>            The bestAlignmentForLabel value
 /// </returns>
 public static int getBestAlignmentForLabel(IAtomContainer container, IAtom atom)
 {
     IAtom[] connectedAtoms = container.getConnectedAtoms(atom);
     int overallDiffX = 0;
     for (int i = 0; i < connectedAtoms.Length; i++)
     {
         IAtom connectedAtom = connectedAtoms[i];
         //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
         overallDiffX = overallDiffX + (int)(connectedAtom.X2d - atom.X2d);
     }
     if (overallDiffX <= 0)
     {
         return 1;
     }
     else
     {
         return -1;
     }
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:30,代码来源:GeometryTools.cs

示例15: saturate

		/// <summary> The method is known to fail for certain compounds. For more information, see
		/// cdk.test.limitations package.
		/// 
		/// </summary>
		public virtual void  saturate(IAtomContainer atomContainer)
		{
			/* newSaturate(atomContainer);
			}
			public void oldSaturate(AtomContainer atomContainer) throws CDKException { */
			IAtom partner = null;
			IAtom atom = null;
			IAtom[] partners = null;
			IAtomType[] atomTypes1 = null;
			IAtomType[] atomTypes2 = null;
			IBond bond = null;
			for (int i = 1; i < 4; i++)
			{
				// handle atoms with degree 1 first and then proceed to higher order
				for (int f = 0; f < atomContainer.AtomCount; f++)
				{
					atom = atomContainer.getAtomAt(f);
					//logger.debug("symbol: ", atom.Symbol);
					atomTypes1 = getAtomTypeFactory(atom.Builder).getAtomTypes(atom.Symbol);
					if (atomTypes1.Length > 0)
					{
						//logger.debug("first atom type: ", atomTypes1[0]);
						if (atomContainer.getBondCount(atom) == i)
						{
							if (atom.getFlag(CDKConstants.ISAROMATIC) && atomContainer.getBondOrderSum(atom) < atomTypes1[0].BondOrderSum - atom.getHydrogenCount())
							{
								partners = atomContainer.getConnectedAtoms(atom);
								for (int g = 0; g < partners.Length; g++)
								{
									partner = partners[g];
									//logger.debug("Atom has " + partners.Length + " partners");
									atomTypes2 = getAtomTypeFactory(atom.Builder).getAtomTypes(partner.Symbol);
									if (atomTypes2.Length == 0)
										return ;
									if (atomContainer.getBond(partner, atom).getFlag(CDKConstants.ISAROMATIC) && atomContainer.getBondOrderSum(partner) < atomTypes2[0].BondOrderSum - partner.getHydrogenCount())
									{
										//logger.debug("Partner has " + atomContainer.getBondOrderSum(partner) + ", may have: " + atomTypes2[0].BondOrderSum);
										bond = atomContainer.getBond(atom, partner);
										//logger.debug("Bond order was " + bond.Order);
										bond.Order = bond.Order + 1;
										//logger.debug("Bond order now " + bond.Order);
										break;
									}
								}
							}
							if (atomContainer.getBondOrderSum(atom) < atomTypes1[0].BondOrderSum - atom.getHydrogenCount())
							{
								//logger.debug("Atom has " + atomContainer.getBondOrderSum(atom) + ", may have: " + atomTypes1[0].BondOrderSum);
								partners = atomContainer.getConnectedAtoms(atom);
								for (int g = 0; g < partners.Length; g++)
								{
									partner = partners[g];
									//logger.debug("Atom has " + partners.Length + " partners");
									atomTypes2 = getAtomTypeFactory(atom.Builder).getAtomTypes(partner.Symbol);
									if (atomTypes2.Length == 0)
										return ;
									if (atomContainer.getBondOrderSum(partner) < atomTypes2[0].BondOrderSum - partner.getHydrogenCount())
									{
										//logger.debug("Partner has " + atomContainer.getBondOrderSum(partner) + ", may have: " + atomTypes2[0].BondOrderSum);
										bond = atomContainer.getBond(atom, partner);
										//logger.debug("Bond order was " + bond.Order);
										bond.Order = bond.Order + 1;
										//logger.debug("Bond order now " + bond.Order);
										break;
									}
								}
							}
						}
					}
				}
			}
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:76,代码来源:SaturationChecker.cs


注:本文中的IAtomContainer.getConnectedAtoms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。