示例#1
0
 private void getBondsInRing(IAtomContainer mol, IRing ring, int[] bonds)
 {
     for (int i = 0; i < ring.getBondCount(); i++)
     {
         int m = mol.getBondNumber(ring.getBondAt(i));
         bonds[m] = 1;
     }
 }
示例#2
0
        public virtual void identifyBonds()
        {
            IAtomContainer spt = getSpanningTree();
            IRing          ring;
            int            nBasicRings = 0;

            for (int i = 0; i < E; i++)
            {
                if (!bondsInTree[i])
                {
                    ring = getRing(spt, molecule.getBondAt(i));
                    for (int b = 0; b < ring.getBondCount(); b++)
                    {
                        int m = molecule.getBondNumber(ring.getBondAt(b));
                        cb[nBasicRings][m] = 1;
                    }
                    nBasicRings++;
                }
            }
            spt = null; ring = null;
            bondsAcyclicCount = 0; bondsCyclicCount = 0;
            for (int i = 0; i < E; i++)
            {
                int s = 0;
                for (int j = 0; j < nBasicRings; j++)
                {
                    s += cb[j][i];
                }
                switch (s)
                {
                //acyclic bond
                case (0):
                {
                    bondsAcyclicCount++; break;
                }

                case (1):
                {
                    bondsCyclicCount++; break;
                }

                default:
                {
                    bondsCyclicCount++;
                }
                break;
                }
            }
        }
示例#3
0
        /// <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 static 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(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);
        }
示例#4
0
 private void getBondsInRing(IAtomContainer mol, IRing ring, int[] bonds)
 {
     for (int i = 0; i < ring.getBondCount(); i++)
     {
         int m = mol.getBondNumber(ring.getBondAt(i));
         bonds[m] = 1;
     }
 }
 /// <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);
     }
 }
 /// <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);
 }
示例#7
0
 /// <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);
 }
示例#8
0
        /// <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 static 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(giveAngleBothMethods(nextAtom, a, parent, true)) > System.Math.PI / 10)))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <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);
 }