/** Tests the weigthed matching */ public void TestMatchWeighted () { Gap gap = new Gap( "test", 1, 4, 1, new double[] { 0.5, 0.5, 0.5 }, 0.0 ); Sequence seq = new Sequence( AlphabetType.DNA, "actga" ); Match match = gap.Match( seq, 1 ); Assert.AreEqual( "a", match.Letters() ); Assert.AreEqual( 1.0, match.Similarity, 1e-1 ); }
public void Setup() { series = new SeriesBest("series", 0.0); motif = new Motif("motif", AlphabetType.DNA, "accg", 1.0); gap = new Gap("gap", 3, 3); gap.Impact = 0.0; series.Add(motif); series.Add(gap); }
public void TestMatchVariablePattern() { Sequence seq = new Sequence(AlphabetType.DNA, "tttaagaacaagttt"); Gap gap = new Gap("gap", 1, 4, 1, new double[] { 0.0, 0.1, 1.0, 0.5 }, 0.0); Iteration iteration; Match match; iteration = new Iteration("test", gap, 1, 3, 0.0); match = iteration.Match(seq, 4); Assert.AreEqual("aagaacaag", match.Letters()); Assert.AreEqual(1.0, match.Similarity, 1e-3); }
public void TestMatch () { Gap gap = new Gap( "test", 0, 3, 1 ); Sequence seq = new Sequence( AlphabetType.DNA, "act" ); FeatureList matches = seq.Search( 0, 0, gap ); Assert.AreEqual( 9, matches.Count ); Assert.AreEqual( "", matches[ 0 ].Letters() ); Assert.AreEqual( "a", matches[ 1 ].Letters() ); Assert.AreEqual( "ac", matches[ 2 ].Letters() ); Assert.AreEqual( "act", matches[ 3 ].Letters() ); Assert.AreEqual( "", matches[ 4 ].Letters() ); Assert.AreEqual( "c", matches[ 5 ].Letters() ); Assert.AreEqual( "ct", matches[ 6 ].Letters() ); Assert.AreEqual( "", matches[ 7 ].Letters() ); Assert.AreEqual( "t", matches[ 8 ].Letters() ); }
/** Tests the weigthed matching */ public void TestMatchWeighted1 () { Gap gap = new Gap( "test", 1, 4, 1, new double[] { 1, 5, 10 }, 0.0 ); Sequence seq = new Sequence( AlphabetType.DNA, "actga" ); Match match = gap.Match( seq, 1 ); Assert.AreEqual( "a", match.Letters() ); Assert.AreEqual( 0.1, match.Similarity, 1e-1 ); Assert.AreEqual( 0, gap.Increment ); match = gap.Match( seq, 1 ); Assert.AreEqual( "ac", match.Letters() ); Assert.AreEqual( 0.5, match.Similarity, 1e-1 ); Assert.AreEqual( 0, gap.Increment ); match = gap.Match( seq, 1 ); Assert.AreEqual( "act", match.Letters() ); Assert.AreEqual( 1.0, match.Similarity, 1e-1 ); Assert.AreEqual( 0, gap.Increment ); match = gap.Match( seq, 1 ); Assert.AreEqual( "actg", match.Letters() ); Assert.AreEqual( 1.0, match.Similarity, 1e-1 ); Assert.AreEqual( 1, gap.Increment ); }
/** Tests the matching with increment. */ public void TestMatchIncrement () { Gap gap = new Gap( "test", 1, 8, 1.7 ); Sequence seq = new Sequence( AlphabetType.DNA, "actgactg" ); Match match = gap.Match( seq, 1 ); Assert.AreEqual( "a", match.Letters() ); Assert.AreEqual( 0, gap.Increment ); match = gap.Match( seq, 1 ); Assert.AreEqual( "act", match.Letters() ); Assert.AreEqual( 0, gap.Increment ); match = gap.Match( seq, 1 ); Assert.AreEqual( "actg", match.Letters() ); Assert.AreEqual( 0, gap.Increment ); match = gap.Match( seq, 1 ); Assert.AreEqual( "actgac", match.Letters() ); Assert.AreEqual( 0, gap.Increment ); match = gap.Match( seq, 1 ); Assert.AreEqual( "actgactg", match.Letters() ); Assert.AreEqual( 1, gap.Increment ); }
/** Tests the weigthed matching */ public void TestMatchWeighted2 () { Gap gap = new Gap( "test", 1, 4, 1, new double[] { 1, 5, 10 }, 0.0 ); Sequence seq = new Sequence( AlphabetType.DNA, "act" ); FeatureList matches = seq.Search( 0, 0, gap ); Assert.AreEqual( 6, matches.Count ); Assert.AreEqual( "a", matches[ 0 ].Letters() ); Assert.AreEqual( 0.1, ( (Match) matches[ 0 ] ).Similarity, 1e-1 ); Assert.AreEqual( "ac", matches[ 1 ].Letters() ); Assert.AreEqual( 0.5, ( (Match) matches[ 1 ] ).Similarity, 1e-1 ); Assert.AreEqual( "act", matches[ 2 ].Letters() ); Assert.AreEqual( 1.0, ( (Match) matches[ 2 ] ).Similarity, 1e-1 ); Assert.AreEqual( "c", matches[ 3 ].Letters() ); Assert.AreEqual( 0.1, ( (Match) matches[ 3 ] ).Similarity, 1e-1 ); Assert.AreEqual( "ct", matches[ 4 ].Letters() ); Assert.AreEqual( 0.5, ( (Match) matches[ 4 ] ).Similarity, 1e-1 ); Assert.AreEqual( "t", matches[ 5 ].Letters() ); Assert.AreEqual( 0.1, ( (Match) matches[ 5 ] ).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; }