Example #1
0
        /// <summary>
        /// Start McGregor search and extend the mappings if possible.
        /// </summary>
        /// <param name="largestMappingSize"></param>
        /// <param name="cliqueVector"></param>
        /// <param name="compGraphNodes"></param>
        /// <exception cref="IOException"></exception>
        public void StartMcGregorIteration(int largestMappingSize,
                                           IReadOnlyList <int> cliqueVector,
                                           IReadOnlyList <int> compGraphNodes)
        {
            this.globalMCSSize = (largestMappingSize / 2);
            List <string> cTab1Copy = McGregorChecks.GenerateCTabCopy(source);

            List <string> cTab2Copy = McGregorChecks.GenerateCTabCopy(target);

            //find mapped atoms of both molecules and store these in mappedAtoms
            List <int> mappedAtoms = new List <int>();

            int mappedAtomCount = 0;

            List <int> iBondNeighborAtomsA = new List <int>();
            var        cBondNeighborsA     = new List <string>();

            List <int> iBondSetA = new List <int>();
            var        cBondSetA = new List <string>();

            List <int> iBondNeighborAtomsB = new List <int>();
            List <int> iBondSetB           = new List <int>();
            var        cBondNeighborsB     = new List <string>();
            var        cBondSetB           = new List <string>();

            int cliqueSize = cliqueVector.Count;
            int vecSize    = compGraphNodes.Count;

            int cliqueNumber = 0;

            for (int a = 0; a < cliqueSize; a++)
            {
                //go through all clique nodes
                cliqueNumber = cliqueVector[a];
                for (int b = 0; b < vecSize; b += 3)
                {
                    //go through all nodes in the compatibility graph
                    if (cliqueNumber == compGraphNodes[b + 2])
                    {
                        mappedAtoms.Add(compGraphNodes[b]);
                        mappedAtoms.Add(compGraphNodes[b + 1]);
                        mappedAtomCount++;
                    }
                }
            }

            //find unmapped atoms of molecule A
            List <int> unmappedAtomsMolA = McGregorChecks.MarkUnMappedAtoms(true, source, mappedAtoms, cliqueSize);

            int counter = 0;
            int setNumA = 0;
            int setNumB = 0;
            int localNeighborBondnumA = 0; //number of remaining molecule A bonds after the clique search, which are neighbors of the MCS_1
            int localNeighborBondNumB = 0; //number of remaining molecule B bonds after the clique search, which are neighbors of the MCS_1

            //Extract bonds which are related with unmapped atoms of molecule A.
            //In case that unmapped atoms are connected with already mapped atoms, the mapped atoms are labelled with
            //new special signs -> the result are two vectors: cBondNeighborsA and int_bonds_molA, which contain those
            //bonds of molecule A, which are relevant for the McGregorBondTypeInSensitive algorithm.
            //The special signs must be transfered to the corresponding atoms of molecule B

            QueryProcessor queryProcess = new QueryProcessor(cTab1Copy, cTab2Copy, SIGNS, localNeighborBondnumA,
                                                             setNumA, iBondNeighborAtomsA, cBondNeighborsA, cliqueSize, iBondSetA, cBondSetA);

            queryProcess.Process(source, target, unmappedAtomsMolA, mappedAtoms, counter);

            cTab1Copy             = queryProcess.CTab1;
            cTab2Copy             = queryProcess.CTab2;
            setNumA               = queryProcess.BondNumA;
            localNeighborBondnumA = queryProcess.NeighborBondNumA;
            iBondNeighborAtomsA   = queryProcess.IBondNeighboursA;
            cBondNeighborsA       = queryProcess.CBondNeighborsA;

            //find unmapped atoms of molecule B
            List <int> unmappedAtomsMolB = McGregorChecks.MarkUnMappedAtoms(false, target, mappedAtoms, cliqueSize);

            //Extract bonds which are related with unmapped atoms of molecule B.
            //In case that unmapped atoms are connected with already mapped atoms, the mapped atoms are labelled with
            //new special signs -> the result are two vectors: cBondNeighborsA and int_bonds_molB, which contain those
            //bonds of molecule B, which are relevant for the McGregorBondTypeInSensitive algorithm.
            //The special signs must be transfered to the corresponding atoms of molecule A

            TargetProcessor targetProcess = new TargetProcessor(cTab1Copy, cTab2Copy, SIGNS, localNeighborBondNumB,
                                                                setNumB, iBondNeighborAtomsB, cBondNeighborsB, localNeighborBondnumA, iBondNeighborAtomsA,
                                                                cBondNeighborsA);

            targetProcess.Process(target, unmappedAtomsMolB, cliqueSize, iBondSetB, cBondSetB, mappedAtoms, counter);

            cTab1Copy             = targetProcess.CTab1;
            cTab2Copy             = targetProcess.CTab2;
            setNumB               = targetProcess.BondNumB;
            localNeighborBondNumB = targetProcess.NeighborBondNumB;
            iBondNeighborAtomsB   = targetProcess.IBondNeighboursB;
            cBondNeighborsB       = targetProcess.CBondNeighborsB;

            bool dummy = false;

            McgregorHelper mcGregorHelper = new McgregorHelper(dummy, mappedAtomCount, mappedAtoms, localNeighborBondnumA,
                                                               localNeighborBondNumB, iBondNeighborAtomsA, iBondNeighborAtomsB, cBondNeighborsA, cBondNeighborsB,
                                                               setNumA, setNumB, iBondSetA, iBondSetB, cBondSetA, cBondSetB);

            Iterator(mcGregorHelper);
        }
Example #2
0
        /// <summary>
        /// Start McGregor search and extend the mappings if possible.
        /// </summary>
        /// <param name="largestMappingSize"></param>
        /// <param name="presentMapping"></param>
        /// <exception cref="IOException"></exception>
        public void StartMcGregorIteration(int largestMappingSize, IReadOnlyDictionary <int, int> presentMapping)
        {
            this.globalMCSSize = (largestMappingSize / 2);
            var cTab1Copy = McGregorChecks.GenerateCTabCopy(source);
            var cTab2Copy = McGregorChecks.GenerateCTabCopy(target);

            //find mapped atoms of both molecules and store these in mappedAtoms
            List <int> mappedAtoms = new List <int>();

            //        Console.Out.WriteLine("\nMapped Atoms");
            foreach (var map in presentMapping)
            {
                //            Console.Out.WriteLine("i:" + map.Key + " j:" + map.Value);
                mappedAtoms.Add(map.Key);
                mappedAtoms.Add(map.Value);
            }
            int mappingSize = presentMapping.Count;

            List <int> iBondNeighborsA = new List <int>();
            var        cBondNeighborsA = new List <string>();

            List <int> iBondSetA = new List <int>();
            var        cBondSetA = new List <string>();

            List <int> iBondNeighborsB = new List <int>();
            List <int> iBondSetB       = new List <int>();
            var        cBondNeighborsB = new List <string>();
            var        cBondSetB       = new List <string>();

            //find unmapped atoms of molecule A

            List <int> unmappedAtomsMolA = McGregorChecks.MarkUnMappedAtoms(true, source, presentMapping);
            int        counter           = 0;
            int        gSetBondNumA      = 0;
            int        gSetBondNumB      = 0;
            int        gNeighborBondnumA = 0; //number of remaining molecule A bonds after the clique search, which are neighbors of the MCS_1
            int        gNeighborBondNumB = 0; //number of remaining molecule B bonds after the clique search, which are neighbors of the MCS_1

            QueryProcessor queryProcess = new QueryProcessor(cTab1Copy, cTab2Copy, SIGNS, gNeighborBondnumA,
                                                             gSetBondNumA, iBondNeighborsA, cBondNeighborsA, mappingSize, iBondSetA, cBondSetA);

            if (!(source is IQueryAtomContainer))
            {
                queryProcess.Process(source, target, unmappedAtomsMolA, mappedAtoms, counter);
            }
            else
            {
                queryProcess.Process((IQueryAtomContainer)source, target, unmappedAtomsMolA, mappedAtoms, counter);
            }

            cTab1Copy         = queryProcess.CTab1;
            cTab2Copy         = queryProcess.CTab2;
            gSetBondNumA      = queryProcess.BondNumA;
            gNeighborBondnumA = queryProcess.NeighborBondNumA;
            iBondNeighborsA   = queryProcess.IBondNeighboursA;
            cBondNeighborsA   = queryProcess.CBondNeighborsA;

            //find unmapped atoms of molecule B
            List <int> unmappedAtomsMolB = McGregorChecks.MarkUnMappedAtoms(false, target, presentMapping);

            //        Console.Out.WriteLine("unmappedAtomsMolB: " + unmappedAtomsMolB.Count);

            //Extract bonds which are related with unmapped atoms of molecule B.
            //In case that unmapped atoms are connected with already mapped atoms, the mapped atoms are labelled with
            //new special signs -> the result are two vectors: cBondNeighborsA and int_bonds_molB, which contain those
            //bonds of molecule B, which are relevant for the McGregorBondTypeInSensitive algorithm.
            //The special signs must be transfered to the corresponding atoms of molecule A

            TargetProcessor targetProcess = new TargetProcessor(cTab1Copy, cTab2Copy, SIGNS, gNeighborBondNumB,
                                                                gSetBondNumB, iBondNeighborsB, cBondNeighborsB, gNeighborBondnumA, iBondNeighborsA,
                                                                cBondNeighborsA);

            targetProcess.Process(target, unmappedAtomsMolB, mappingSize, iBondSetB, cBondSetB, mappedAtoms,
                                  counter);

            cTab1Copy         = targetProcess.CTab1;
            cTab2Copy         = targetProcess.CTab2;
            gSetBondNumB      = targetProcess.BondNumB;
            gNeighborBondNumB = targetProcess.NeighborBondNumB;
            iBondNeighborsB   = targetProcess.IBondNeighboursB;
            cBondNeighborsB   = targetProcess.CBondNeighborsB;

            bool dummy = false;

            McgregorHelper mcGregorHelper = new McgregorHelper(dummy, presentMapping.Count, mappedAtoms,
                                                               gNeighborBondnumA, gNeighborBondNumB, iBondNeighborsA, iBondNeighborsB, cBondNeighborsA,
                                                               cBondNeighborsB, gSetBondNumA, gSetBondNumB, iBondSetA, iBondSetB, cBondSetA, cBondSetB);

            Iterator(mcGregorHelper);
        }