Beispiel #1
0
        public override void SearchMCS(bool shouldMatchBonds)
        {
            CDKRMapHandler rmap = new CDKRMapHandler();

            try
            {
                if ((source.Atoms.Count == target.Atoms.Count) && source.Bonds.Count == target.Bonds.Count)
                {
                    rOnPFlag = true;
                    rmap.CalculateOverlapsAndReduceExactMatch(source, target, shouldMatchBonds);
                }
                else if (source.Atoms.Count > target.Atoms.Count && source.Bonds.Count != target.Bonds.Count)
                {
                    rOnPFlag = true;
                    rmap.CalculateOverlapsAndReduce(source, target, shouldMatchBonds);
                }
                else
                {
                    rOnPFlag = false;
                    rmap.CalculateOverlapsAndReduce(target, source, shouldMatchBonds);
                }

                SetAllMapping();
                SetAllAtomMapping();
                SetFirstMapping();
                SetFirstAtomMapping();
            }
            catch (CDKException)
            {
                rmap = null;
            }
        }
Beispiel #2
0
        public override bool IsSubgraph(bool shouldMatchBonds)
        {
            CDKRMapHandler rmap = new CDKRMapHandler();

            try
            {
                if ((source.Atoms.Count == target.Atoms.Count) && source.Bonds.Count == target.Bonds.Count)
                {
                    rOnPFlag = true;
                    rmap.CalculateIsomorphs(source, target, shouldMatchBonds);
                }
                else if (source.Atoms.Count > target.Atoms.Count && source.Bonds.Count != target.Bonds.Count)
                {
                    rOnPFlag = true;
                    rmap.CalculateSubGraphs(source, target, shouldMatchBonds);
                }
                else
                {
                    rOnPFlag = false;
                    rmap.CalculateSubGraphs(target, source, shouldMatchBonds);
                }

                SetAllMapping();
                SetAllAtomMapping();
                SetFirstMapping();
                SetFirstAtomMapping();
            }
            catch (CDKException)
            {
                rmap = null;
                //            Console.Error.WriteLine("WARNING: graphContainer: most probably time out error ");
            }

            return(GetFirstMapping().Count != 0);
        }
Beispiel #3
0
        public void TestSetTimeoutFlag()
        {
            bool timeoutFlag = false;
            var  instance    = new CDKRMapHandler();

            instance.IsTimedOut = timeoutFlag;
            Assert.AreNotEqual(true, instance.IsTimedOut);
        }
Beispiel #4
0
        public void TestCalculateOverlapsAndReduce()
        {
            var            sp        = new SmilesParser(builder);
            var            Molecule1 = sp.ParseSmiles("O1C=CC=C1");
            var            Molecule2 = sp.ParseSmiles("C1CCCC1");
            CDKRMapHandler instance  = new CDKRMapHandler();

            instance.CalculateOverlapsAndReduce(Molecule1, Molecule2, true);
            Assert.IsNotNull(FinalMappings.Instance.Count);
        }
Beispiel #5
0
        public void TestIsTimeoutFlag()
        {
            CDKRMapHandler instance  = new CDKRMapHandler();
            bool           expResult = true;

            instance.IsTimedOut = true;
            bool result = instance.IsTimedOut;

            Assert.AreEqual(expResult, result);
        }
Beispiel #6
0
        public void TestCalculateOverlapsAndReduceExactMatch()
        {
            var            sp        = new SmilesParser(builder);
            var            Molecule1 = sp.ParseSmiles("O1C=CC=C1");
            var            Molecule2 = sp.ParseSmiles("O1C=CC=C1");
            CDKRMapHandler instance  = new CDKRMapHandler();

            instance.CalculateOverlapsAndReduceExactMatch(Molecule1, Molecule2, true);
            // TODO review the generated test code and remove the default call to fail.
            Assert.IsNotNull(FinalMappings.Instance.Count);
        }
Beispiel #7
0
        public void TestGetMappings()
        {
            var            sp        = new SmilesParser(builder);
            var            Molecule1 = sp.ParseSmiles("O1C=CC=C1");
            var            Molecule2 = sp.ParseSmiles("O1C=CC=C1");
            CDKRMapHandler instance  = new CDKRMapHandler();

            instance.CalculateOverlapsAndReduceExactMatch(Molecule1, Molecule2, true);
            var result = instance.Mappings;

            Assert.AreEqual(2, result.Count);
        }
Beispiel #8
0
        public void TestSetMappings()
        {
            var map = new SortedDictionary <int, int>
            {
                [0] = 0,
                [1] = 1
            };
            var mappings = new List <IReadOnlyDictionary <int, int> > {
                map
            };

            CDKRMapHandler instance = new CDKRMapHandler
            {
                Mappings = mappings
            };

            Assert.IsNotNull(instance.Mappings);
        }