/** test for case insensitivity of a match */
        public void TestCaseInsensitivity()
        {
            RegularExp regx;

            regx = new RegularExp("test", "act", true);
            Assert.IsNotNull(regx.Match(new Sequence(AlphabetType.DNA, "act"), 1));

            regx = new RegularExp("test", "act", true);
            Assert.IsNotNull(regx.Match(new Sequence(AlphabetType.DNA, "ACT"), 1));


            regx = new RegularExp("test", "ACT", true);
            Assert.IsNull(regx.Match(new Sequence(AlphabetType.DNA, "act"), 1));

            //---
            regx = new RegularExp("test", "Act", true);
            Assert.IsNull(regx.Match(new Sequence(AlphabetType.DNA, "ACT"), 1));

            regx = new RegularExp("test", "Act", false);
            Assert.IsNotNull(regx.Match(new Sequence(AlphabetType.DNA, "act"), 1));


            regx = new RegularExp("test", "Act", false);
            Assert.IsNotNull(regx.Match(new Sequence(AlphabetType.DNA, "ACT"), 1));
        }
        public void TestMatch()
        {
            Sequence seq = new Sequence(AlphabetType.DNA, "acctccgg");
            RegularExp regx = new RegularExp("test","ctc.");
            Match myMatch = regx.Match(seq, 1);

            Assert.AreEqual(null, myMatch);

            myMatch = regx.Match(seq, 3);
            Assert.AreEqual(3, myMatch.Start);
            Assert.AreEqual(4, myMatch.Length);
            Assert.AreEqual(1, myMatch.Strand);
            Assert.AreEqual(1.0, myMatch.Similarity, 1e-2);

            regx = new RegularExp("test", "acc");
            myMatch = regx.Match(seq, 1);
            Assert.AreEqual(1, myMatch.Start);

            regx = new RegularExp("test", "cgg");
            myMatch = regx.Match(seq, 6);
            Assert.AreEqual(8, myMatch.End);

            //last test
            
            //ISSUE: could be star problem
            regx = new RegularExp("test", "c.*g");
            FeatureList matches = seq.Search(0, 0, regx);
            Assert.AreEqual(4, matches.Count);
            Assert.AreEqual("cctccgg", matches[0].Letters());
            Assert.AreEqual("ctccgg", matches[1].Letters());
            Assert.AreEqual("ccgg", matches[2].Letters());
            Assert.AreEqual("cgg", matches[3].Letters());


        }
        public void TestTest()
        {
            Sequence seq = new Sequence(AlphabetType.DNA, "acctccctcccgacgg");
            RegularExp regx = new RegularExp("test","ctc.");

            Match myMatch = regx.Match(seq, 3);

            Assert.IsNotNull(myMatch);

            FeatureList matches = seq.Search(0, 0, regx);
            Assert.IsNotNull(matches);
        }
        /// <summary>
        /// 
        /// Reads a pattern from a starting specified node. This method
        /// recursivly calls the reading methods of the different patterns.
        /// </summary>
        /// <param name="node">Node of the pattern the reading starts with.</param>
        /// <param name="definition">Pattern definition which pattern list will be extended 
        /// with the pattern and all its sub-patterns read.
        /// </param>
        /// <returns>The read pattern or null if there is no pattern to read.</returns>
        /// <exception cref="System.SystemException">Thrown when unknown pattern was found</exception>
        public static IPattern ReadPattern
                    (XmlNode node, Definition definition)
        {
            while (node != null
                    && node.NodeType != XmlNodeType.Element)

                node = node.NextSibling; //Iterate thru the list of nodes until it is an element

            IPattern pattern = null;
            String mode = XMLHelper.GetAttrValueString(node, "mode");

            switch (node.Name)
            {
                case "Any":
                    pattern = new Any();
                    break;

                case "Alignment":
                    pattern = new Alignment();
                    break;

                case "Composition" :
                    pattern = new Composition();
                    break;

                case "Constraint":
                    pattern = new Constraint();
                    break;

                case "Iteration":
                    pattern = new Iteration();
                    break;

                case "Logic":
                    pattern = new Logic();
                    break;

                case "Motif":
                    pattern = new Motif();
                    break;

                case "PWM":
                    pattern = new PWM();
                    break;

                case "Regex":
                    pattern = new RegularExp();
                    break;

                case "Prosite":
                    pattern = new Prosite();
                    break;

                case "Block":
                    pattern = new Block();
                    break;

                case "Gap":
                    pattern = new Gap();
                    break;

                case "Repeat":
                    pattern = new Repeat();
                    break;

                case "Series":
                    pattern = mode.Equals("ALL") ? 
                        pattern = new SeriesAll() : pattern = new SeriesBest();
                    break;

                case "Set":
                    pattern = mode.Equals("ALL") ?
                       pattern = new SetAll() : pattern = new SetBest();
                    break;

                case "Void":
                    pattern = new VoidPattern();
                    break;

                case "Use":
                    pattern = new Use();
                    break;

                throw new SystemException
                    ("Unknown pattern found: " + node.Name);
 
            }

 
            pattern.ReadNode(node, definition);      // read the node data and initialize the pattern
            definition.Patterns.Add
                            (0, pattern); //Always adding the element to last index
 
            return pattern;
        }