public void TestMatch1 () {
			Sequence seq = new Sequence( AlphabetType.DNA, "taaacc" );
			SeriesAll series = new SeriesAll();
			FeatureList matches;

			series.Add( new Motif( "motif1", AlphabetType.DNA, "aa", 0.5 ) );

			matches = seq.Search( 1, seq.Length, series );
			Assert.AreEqual( 4, matches.Count );
			Assert.AreEqual( "ta", matches[ 0 ].Letters() ); //There might be some error with data structure
			Assert.AreEqual( 1, matches[ 0 ].Start );
			Assert.AreEqual( "aa", matches[ 1 ].Letters() );
			Assert.AreEqual( 2, matches[ 1 ].Start );
			Assert.AreEqual( "aa", matches[ 2 ].Letters() );
			Assert.AreEqual( 3, matches[ 2 ].Start );
			Assert.AreEqual( "ac", matches[ 3 ].Letters() );
			Assert.AreEqual( 4, matches[ 3 ].Start );

			series.Add( new Gap( "gap1", 1, 2, 1 ) );
			series.Add( new Motif( "motif2", AlphabetType.DNA, "cc", 0.5 ) );
			matches = seq.Search( 1, seq.Length, series );
			Assert.AreEqual( 3, matches.Count() );
			Assert.AreEqual( "taaac", matches[ 0 ].Letters() );
			Assert.AreEqual( 0.666, ( (Match) matches[ 0 ] ).Similarity, 1e-3 );
			Assert.AreEqual( "taaacc", matches[ 1 ].Letters() );
			Assert.AreEqual( 0.833, ( (Match) matches[ 1 ] ).Similarity, 1e-3 );
			Assert.AreEqual( "aaacc", matches[ 2 ].Letters() );
			Assert.AreEqual( 1.000, ( (Match) matches[ 2 ] ).Similarity, 1e-3 );
		}
		/** Tests the match method of a series of patterns with a weighted gap */
		public void TestMatchWeightedGap () {
			Sequence seq = new Sequence( AlphabetType.DNA, "taaacc" );
			SeriesAll series = new SeriesAll();

			series.Add( new Motif( "motif1", AlphabetType.DNA, "ta", 1.0 ) );
			series.Add( new Gap( "gap", 1, 2, 1, new double[] { 0, 1 }, 0.0 ) );
			series.Add( new Motif( "motif2", AlphabetType.DNA, "cc", 0.5 ) );
			FeatureList matches = seq.Search( 1, seq.Length, series );
			Assert.AreEqual( "taaac", matches[ 0 ].Letters() );
			Assert.AreEqual( 0.500, ( (Match) matches[ 0 ] ).Similarity, 1e-3 );
			Assert.AreEqual( "taaacc", matches[ 1 ].Letters() );
			Assert.AreEqual( 1.000, ( (Match) matches[ 1 ] ).Similarity, 1e-3 );
		}
		/** Tests the match method of a series of patterns with two gaps */
		public void TestMatchTwoGaps () {
			Sequence seq = new Sequence( AlphabetType.DNA, "taaaagccc" );
			SeriesAll series = new SeriesAll();

			series.Add( new Motif( "motif1", AlphabetType.DNA, "ta", 1.0 ) );
			series.Add( new Gap( "gap1", 1, 2, 1 ) );
			series.Add( new Motif( "motif2", AlphabetType.DNA, "aa", 0.5 ) );
			series.Add( new Gap( "gap2", 1, 2, 1 ) );
			series.Add( new Motif( "motif3", AlphabetType.DNA, "cc", 1.0 ) );
			FeatureList matches = seq.Search( 1, seq.Length, series );
			Assert.AreEqual( 3, matches.Count );
			Assert.AreEqual( "taaaagcc", matches[0].Letters() );
			Assert.AreEqual( 1.0, ( (Match) matches[0] ).Similarity, 1e-1 );
			Assert.AreEqual( "taaaagccc", matches[1].Letters() );
			Assert.AreEqual( 1.0, ( (Match) matches[1] ).Similarity, 1e-1 );
			Assert.AreEqual( "taaaagccc", matches[2].Letters() );
			Assert.AreEqual( 0.9, ( (Match) matches[2] ).Similarity, 1e-1 );
		}
        /// <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;
        }
		/** Tests the match method of a series of patterns with two gaps */
		public void TestMatchSigma70 () {
			Sequence seq = new Sequence( AlphabetType.DNA, "cgagagagcg attatatcga ctaaacagaa aatgtcaaac aacttgtcaa aaaacagaag" );
			SeriesAll series = new SeriesAll();

			series.Add( new Motif( "", AlphabetType.DNA, "attata", 1.0 ) );
			series.Add( new Gap( "", 1, 200, 1 ) );
			series.Add( new Motif( "", AlphabetType.DNA, "tgtcaa", 1.0 ) );

			FeatureList matches = seq.Search( 2, seq.Length, series );
			Assert.AreEqual( 2, matches.Count );

			System.Diagnostics.Debug.WriteLine( series.ToXml().ToString() );

			//Assert.AreEqual( "taaaagcc", matches[0].Letters() );
			//Assert.AreEqual( 1.0, ( (Match) matches[0] ).Similarity, 1e-1 );
			//Assert.AreEqual( "taaaagccc", matches[1].Letters() );
			//Assert.AreEqual( 1.0, ( (Match) matches[1] ).Similarity, 1e-1 );
			//Assert.AreEqual( "taaaagccc", matches[2].Letters() );
			//Assert.AreEqual( 0.9, ( (Match) matches[2] ).Similarity, 1e-1 );
		}
		/** Tests the match method of a series of patterns with two gaps */
		public void TestMatchSigma70InChlamydia () {
			SequenceList sequences = null;

			using ( BioPatMBF_Reader reader = new BioPatMBF_Reader() ) {
				sequences = reader.Read(
					Global.GetResourceReader( "data/GenBank/NC_000117-Chlamydia trachomatis D-UW-3CX.gbk" )
				);
			}

			Sequence seq = sequences[0];
			SeriesAll series = new SeriesAll();

			series.Add( new Motif( "", AlphabetType.DNA, "attata", 1.0 ) );
			series.Add( new Gap( "", 1, 200, 1 ) );
			series.Add( new Motif( "", AlphabetType.DNA, "tgtcaa", 1.0 ) );

			FeatureList matches = seq.Search( 2, seq.Length, series );
			Assert.AreEqual( 11, matches.Count );

			//Assert.AreEqual( "taaaagcc", matches[0].Letters() );
			//Assert.AreEqual( 1.0, ( (Match) matches[0] ).Similarity, 1e-1 );
			//Assert.AreEqual( "taaaagccc", matches[1].Letters() );
			//Assert.AreEqual( 1.0, ( (Match) matches[1] ).Similarity, 1e-1 );
			//Assert.AreEqual( "taaaagccc", matches[2].Letters() );
			//Assert.AreEqual( 0.9, ( (Match) matches[2] ).Similarity, 1e-1 );
		}