Exemple #1
0
        private void ExtendMapping(int xIndex, int yIndex, McgregorHelper mcGregorHelper, List <int> additionalMapping,
                                   List <int> currentMapping)
        {
            int atom1MoleculeA = mcGregorHelper.GetIBondNeighborAtomsA()[xIndex * 3 + 0];
            int atom2MoleculeA = mcGregorHelper.GetIBondNeighborAtomsA()[xIndex * 3 + 1];
            int atom1MoleculeB = mcGregorHelper.GetIBondNeighborAtomsB()[yIndex * 3 + 0];
            int atom2MoleculeB = mcGregorHelper.GetIBondNeighborAtomsB()[yIndex * 3 + 1];

            IAtom r1A          = source.Atoms[atom1MoleculeA];
            IAtom r2A          = source.Atoms[atom2MoleculeA];
            IBond reactantBond = source.GetBond(r1A, r2A);

            IAtom p1B         = target.Atoms[atom1MoleculeB];
            IAtom p2B         = target.Atoms[atom2MoleculeB];
            IBond productBond = target.GetBond(p1B, p2B);

            //      Bond Order Check Introduced by Asad

            if (McGregorChecks.IsMatchFeasible(source, reactantBond, target, productBond, IsBondMatch))
            {
                for (int indexZ = 0; indexZ < mcGregorHelper.MappedAtomCount; indexZ++)
                {
                    int mappedAtom1 = currentMapping[indexZ * 2 + 0];
                    int mappedAtom2 = currentMapping[indexZ * 2 + 1];

                    if ((mappedAtom1 == atom1MoleculeA) && (mappedAtom2 == atom1MoleculeB))
                    {
                        additionalMapping.Add(atom2MoleculeA);
                        additionalMapping.Add(atom2MoleculeB);
                    }
                    else if ((mappedAtom1 == atom1MoleculeA) && (mappedAtom2 == atom2MoleculeB))
                    {
                        additionalMapping.Add(atom2MoleculeA);
                        additionalMapping.Add(atom1MoleculeB);
                    }
                    else if ((mappedAtom1 == atom2MoleculeA) && (mappedAtom2 == atom1MoleculeB))
                    {
                        additionalMapping.Add(atom1MoleculeA);
                        additionalMapping.Add(atom2MoleculeB);
                    }
                    else if ((mappedAtom1 == atom2MoleculeA) && (mappedAtom2 == atom2MoleculeB))
                    {
                        additionalMapping.Add(atom1MoleculeA);
                        additionalMapping.Add(atom1MoleculeB);
                    }
                }//for loop
            }
        }
Exemple #2
0
        internal static bool IsFurtherMappingPossible(IAtomContainer source, IAtomContainer target,
                                                      McgregorHelper mcGregorHelper, bool shouldMatchBonds)
        {
            int neighborBondNumA    = mcGregorHelper.NeighborBondNumA;
            int neighborBondNumB    = mcGregorHelper.NeighborBondNumB;
            var iBondNeighborAtomsA = mcGregorHelper.GetIBondNeighborAtomsA();
            var iBondNeighborAtomsB = mcGregorHelper.GetIBondNeighborAtomsB();
            var cBondNeighborsA     = mcGregorHelper.GetCBondNeighborsA();
            var cBondNeighborsB     = mcGregorHelper.GetCBondNeighborsB();

            for (int row = 0; row < neighborBondNumA; row++)
            {
                //            Console.Out.WriteLine("i " + row);
                string g1A = cBondNeighborsA[row * 4 + 0];
                string g2A = cBondNeighborsA[row * 4 + 1];

                for (int column = 0; column < neighborBondNumB; column++)
                {
                    string g1B = cBondNeighborsB[column * 4 + 0];
                    string g2B = cBondNeighborsB[column * 4 + 1];

                    if (IsAtomMatch(g1A, g2A, g1B, g2B))
                    {
                        try
                        {
                            int indexI      = iBondNeighborAtomsA[row * 3 + 0];
                            int indexIPlus1 = iBondNeighborAtomsA[row * 3 + 1];

                            int indexJ      = iBondNeighborAtomsB[column * 3 + 0];
                            int indexJPlus1 = iBondNeighborAtomsB[column * 3 + 1];

                            IAtom r1A          = source.Atoms[indexI];
                            IAtom r2A          = source.Atoms[indexIPlus1];
                            IBond reactantBond = source.GetBond(r1A, r2A);

                            IAtom p1B         = target.Atoms[indexJ];
                            IAtom p2B         = target.Atoms[indexJPlus1];
                            IBond productBond = target.GetBond(p1B, p2B);

                            if (IsMatchFeasible(source, reactantBond, target, productBond, shouldMatchBonds))
                            {
                                return(true);
                            }
                        }
                        catch (Exception e)
                        {
                            Console.Out.WriteLine(e.StackTrace);
                        }
                    }
                }
            }

            return(false);
        }
Exemple #3
0
        private void SetModifedArcs(McgregorHelper mcGregorHelper)
        {
            int neighborBondNumA    = mcGregorHelper.NeighborBondNumA;
            int neighborBondNumB    = mcGregorHelper.NeighborBondNumB;
            var iBondNeighborAtomsA = mcGregorHelper.GetIBondNeighborAtomsA();
            var iBondNeighborAtomsB = mcGregorHelper.GetIBondNeighborAtomsB();
            var cBondNeighborsA     = mcGregorHelper.GetCBondNeighborsA();
            var cBondNeighborsB     = mcGregorHelper.GetCBondNeighborsB();

            for (int row = 0; row < neighborBondNumA; row++)
            {
                for (int column = 0; column < neighborBondNumB; column++)
                {
                    string g1A = cBondNeighborsA[row * 4 + 0];
                    string g2A = cBondNeighborsA[row * 4 + 1];
                    string g1B = cBondNeighborsB[column * 4 + 0];
                    string g2B = cBondNeighborsB[column * 4 + 1];

                    if (MatchGAtoms(g1A, g2A, g1B, g2B))
                    {
                        int indexI      = iBondNeighborAtomsA[row * 3 + 0];
                        int indexIPlus1 = iBondNeighborAtomsA[row * 3 + 1];

                        IAtom r1A          = source.Atoms[indexI];
                        IAtom r2A          = source.Atoms[indexIPlus1];
                        IBond reactantBond = source.GetBond(r1A, r2A);

                        int indexJ      = iBondNeighborAtomsB[column * 3 + 0];
                        int indexJPlus1 = iBondNeighborAtomsB[column * 3 + 1];

                        IAtom p1B         = target.Atoms[indexJ];
                        IAtom p2B         = target.Atoms[indexJPlus1];
                        IBond productBond = target.GetBond(p1B, p2B);
                        if (McGregorChecks.IsMatchFeasible(source, reactantBond, target, productBond, IsBondMatch))
                        {
                            modifiedARCS[row * neighborBondNumB + column] = 1;
                        }
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// The function is called in function partsearch. The function is given a temporary matrix and a position (row/column)
        /// within this matrix. First the function sets all entries to zero, which can be exlcuded in respect to the current
        /// atom by atom matching. After this the function replaces all entries in the same row and column of the current
        /// position by zeros. Only the entry of the current position is set to one.
        /// Return value "count_arcsleft" counts the number of arcs, which are still in the matrix.
        /// </summary>
        internal static void RemoveRedundantArcs(int row, int column, IList <int> marcs, McgregorHelper mcGregorHelper)
        {
            int neighborBondNumA    = mcGregorHelper.NeighborBondNumA;
            int neighborBondNumB    = mcGregorHelper.NeighborBondNumB;
            var iBondNeighborAtomsA = mcGregorHelper.GetIBondNeighborAtomsA();
            var iBondNeighborAtomsB = mcGregorHelper.GetIBondNeighborAtomsB();
            int g1Atom = iBondNeighborAtomsA[row * 3 + 0];
            int g2Atom = iBondNeighborAtomsA[row * 3 + 1];
            int g3Atom = iBondNeighborAtomsB[column * 3 + 0];
            int g4Atom = iBondNeighborAtomsB[column * 3 + 1];

            for (int x = 0; x < neighborBondNumA; x++)
            {
                int rowAtom1 = iBondNeighborAtomsA[x * 3 + 0];
                int rowAtom2 = iBondNeighborAtomsA[x * 3 + 1];

                for (int y = 0; y < neighborBondNumB; y++)
                {
                    int columnAtom3 = iBondNeighborAtomsB[y * 3 + 0];
                    int columnAtom4 = iBondNeighborAtomsB[y * 3 + 1];

                    if (McGregorChecks.Cases(g1Atom, g2Atom, g3Atom, g4Atom, rowAtom1, rowAtom2, columnAtom3,
                                             columnAtom4))
                    {
                        marcs[x * neighborBondNumB + y] = 0;
                    }
                }
            }

            for (int v = 0; v < neighborBondNumA; v++)
            {
                marcs[v * neighborBondNumB + column] = 0;
            }

            for (int w = 0; w < neighborBondNumB; w++)
            {
                marcs[row * neighborBondNumB + w] = 0;
            }

            marcs[row * neighborBondNumB + column] = 1;
        }