コード例 #1
0
ファイル: McGregorChecks.cs プロジェクト: roddickchen/NCDK
        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);
        }
コード例 #2
0
ファイル: McGregor.cs プロジェクト: roddickchen/NCDK
        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;
                        }
                    }
                }
            }
        }