public bool GetMaxCommonFragmentsNotUsed(HasseNode Node1, HasseNode Node2, bool dbg,
                                                 HasseFragmentInsertionQueue NewFragmentList, int MinimumOverlap)
        {
            // this Node is directly below both Node1 and Node2
            // it can match several places
            CountMCS++;
            string strSeed  = this.KeyString.Replace("*", "");
            string str1     = Node1.KeyString;
            string str2     = Node2.KeyString;
            bool   FoundMCS = false;

            // we are only interested in matches strictly larger than seed
            if (strSeed.Length + 1 > MinimumOverlap)
            {
                MinimumOverlap = strSeed.Length + 1;
            }

            int MatchPosA = GetNextMatch(0, strSeed, str1);

            while (MatchPosA > -1)
            {
                int MatchPosB = GetNextMatch(0, strSeed, str2);
                while (MatchPosB > -1)
                {
                    Match M = new Match(strSeed, MatchPosA, 0, str1, MatchPosB, 0, str2);
                    M.ExpandMCSMatch();
                    //MatchPosA= M.LastPosInA;
                    //MatchPosB = M.LastPosInB;
                    string debugInfo = "MCS " + Node1.GetID().ToString() + " " + Node2.GetID().ToString();
                    if (true == ProcessMatch(M, MinimumOverlap, NewFragmentList, new HasseNode[2] {
                        Node1, Node2
                    }, debugInfo))
                    {
                        FoundMCS = true;
                    }
                    MatchPosB = GetNextMatch(MatchPosB + 1, strSeed, str2);
                }
                MatchPosA = GetNextMatch(MatchPosA + 1, strSeed, str1);
            }

            return(FoundMCS);
        }
        public override bool GetMaxCommonFragments(HasseNode Node1, HasseNode Node2, bool dbg,
                                                   HasseFragmentInsertionQueue NewFragmentList, int MinimumOverlap)
        {
            CountMCS++;
            string str1     = Node1.KeyString;
            string str2     = Node2.KeyString;
            bool   FoundMCS = false;

            StringMatcher sm = new StringMatcher();

            sm.Initialise(str1, str2);
            Match m = null;

            do
            {
                m = sm.nextMatch();
                if (m == null)
                {
                    break;
                }
                if (m.LastPosInA - m.FirstPosInA < MinimumOverlap - 1)
                {
                    continue;
                }
                //System.Diagnostics.Debug.WriteLine(m.StrA.Substring(m.FirstPosInA, m.LastPosInA - m.FirstPosInA + 1));
                //System.Diagnostics.Debug.WriteLine(m.StrB.Substring(m.FirstPosInB, m.LastPosInB - m.FirstPosInB + 1));
                string debugInfo = "MCS " + Node1.GetID().ToString() + " " + Node2.GetID().ToString();
                if (true == ProcessMatch(m, MinimumOverlap, NewFragmentList, new HasseNode[2] {
                    Node1, Node2
                }, debugInfo))
                {
                    FoundMCS = true;
                }
            } while (true);
            return(FoundMCS);
        }
Пример #3
0
        private void WriteNode(HasseNode N)
        {
            //System.Diagnostics.Debug.WriteLine(((ChemHasseNode)N).GetName());
            //DotFile.WriteLine("node[shape = rounded];");
            DotFile.Write(DoubleQuoted(N.KeyString));
            DotFile.Write(" ["); // start node attributes

            switch (LabelMode)
            {
                case labelMode.NO_LABELS:
                    DotFile.Write(" label=\"\" "); //empty label
                    break;
                case labelMode.USE_NODE_ID:
                    DotFile.Write(" label=" + DoubleQuoted(N.GetID().ToString()));
                    break;

                case labelMode.USE_MOLNAME:
                    if (((ChemHasseNode)N).GetName() != "")
                    {
                        DotFile.Write(" label=" + DoubleQuoted(((ChemHasseNode)N).GetName()));
                    }
                    else
                    {
                        DotFile.Write(" label=" + DoubleQuoted(N.GetID().ToString()));
                    }
                    break;

                case labelMode.USE_NODE_KEY:
                    // need not do anything, the node key is shown by default
                    break;

                case labelMode.USE_NODE_LABEL:
                    DotFile.Write(" label=" + DoubleQuoted(N.LabelText));
                    break;

                default:
                    throw new Exception("unhandled labelmode");
            }

            if (N.DrawingColor!="" ) DotFile.Write(" color=" + N.DrawingColor + " ");

            if (UseImage && N.ImageFileName.Length > 0)
            {
                DotFile.Write(" image=\"" + N.ImageFileName + "\"");
            }

            if (N.HasNodeType (HasseNode.HasseNodeTypes.REAL) || N.NodeType == HasseNode.HasseNodeTypes.ROOT )
            { DotFile.Write(" shape=ellipse "); }
            else
            { DotFile.Write(" shape=none "); }

            DotFile.Write("] "); // end node attributes
            DotFile.WriteLine(";");
        }
Пример #4
0
        private void WriteNode(HasseNode N)
        {
            //System.Diagnostics.Debug.WriteLine(((ChemHasseNode)N).GetName());
            //DotFile.WriteLine("node[shape = rounded];");
            DotFile.Write(DoubleQuoted(N.KeyString));
            DotFile.Write(" ["); // start node attributes

            switch (LabelMode)
            {
            case labelMode.NO_LABELS:
                DotFile.Write(" label=\"\" ");     //empty label
                break;

            case labelMode.USE_NODE_ID:
                DotFile.Write(" label=" + DoubleQuoted(N.GetID().ToString()));
                break;

            case labelMode.USE_MOLNAME:
                if (((ChemHasseNode)N).GetName() != "")
                {
                    DotFile.Write(" label=" + DoubleQuoted(((ChemHasseNode)N).GetName()));
                }
                else
                {
                    DotFile.Write(" label=" + DoubleQuoted(N.GetID().ToString()));
                }
                break;

            case labelMode.USE_NODE_KEY:
                // need not do anything, the node key is shown by default
                break;

            case labelMode.USE_NODE_LABEL:
                DotFile.Write(" label=" + DoubleQuoted(N.LabelText));
                break;

            default:
                throw new Exception("unhandled labelmode");
            }

            if (N.DrawingColor != "")
            {
                DotFile.Write(" color=" + N.DrawingColor + " ");
            }

            if (UseImage && N.ImageFileName.Length > 0)
            {
                DotFile.Write(" image=\"" + N.ImageFileName + "\"");
            }

            if (N.HasNodeType(HasseNode.HasseNodeTypes.REAL) || N.NodeType == HasseNode.HasseNodeTypes.ROOT)
            {
                DotFile.Write(" shape=ellipse ");
            }
            else
            {
                DotFile.Write(" shape=none ");
            }

            DotFile.Write("] "); // end node attributes
            DotFile.WriteLine(";");
        }
Пример #5
0
        public bool GetMaxCommonFragmentsNotUsed(HasseNode Node1, HasseNode Node2, bool dbg,
            HasseFragmentInsertionQueue NewFragmentList, int MinimumOverlap)
        {
            // this Node is directly below both Node1 and Node2
            // it can match several places
            CountMCS ++;
            string strSeed = this.KeyString.Replace("*", "");
            string str1 = Node1.KeyString;
            string str2 = Node2.KeyString;
            bool FoundMCS = false;
            // we are only interested in matches strictly larger than seed
            if (strSeed.Length + 1 > MinimumOverlap) { MinimumOverlap = strSeed.Length + 1; }

            int MatchPosA = GetNextMatch(0,strSeed,str1);
            while(MatchPosA>-1){
                int MatchPosB = GetNextMatch(0,strSeed,str2);
                while(MatchPosB>-1){

                    Match M = new Match( strSeed,MatchPosA, 0, str1, MatchPosB, 0, str2);
                    M.ExpandMCSMatch();
                    //MatchPosA= M.LastPosInA;
                    //MatchPosB = M.LastPosInB;
                    string debugInfo = "MCS " + Node1.GetID().ToString () + " " + Node2.GetID().ToString ();
                    if (true == ProcessMatch(M, MinimumOverlap, NewFragmentList, new HasseNode[2] { Node1, Node2 }, debugInfo))
                    { FoundMCS = true; }
                    MatchPosB = GetNextMatch(MatchPosB +1,strSeed,str2);
                }
                MatchPosA = GetNextMatch(MatchPosA +1,strSeed,str1);
            }

            return FoundMCS;
        }
Пример #6
0
        public override bool GetMaxCommonFragments(HasseNode Node1, HasseNode Node2, bool dbg,
            HasseFragmentInsertionQueue NewFragmentList, int MinimumOverlap)
        {
            CountMCS++;
            string str1 = Node1.KeyString;
            string str2 = Node2.KeyString;
            bool FoundMCS = false;

            StringMatcher sm = new StringMatcher();
            sm.Initialise(str1, str2);
            Match m = null;
            do
            {
                m = sm.nextMatch();
                if (m == null) break;
                if (m.LastPosInA - m.FirstPosInA < MinimumOverlap-1) continue;
                //System.Diagnostics.Debug.WriteLine(m.StrA.Substring(m.FirstPosInA, m.LastPosInA - m.FirstPosInA + 1));
                //System.Diagnostics.Debug.WriteLine(m.StrB.Substring(m.FirstPosInB, m.LastPosInB - m.FirstPosInB + 1));
                string debugInfo = "MCS " + Node1.GetID().ToString() + " " + Node2.GetID().ToString();
                if (true == ProcessMatch(m, MinimumOverlap, NewFragmentList, new HasseNode[2] { Node1, Node2 }, debugInfo))
                { FoundMCS = true; }

            } while (true);
            return FoundMCS;
        }