public void TestConstructor () { Sequence seq = new Sequence( AlphabetType.AA, "ArTGü" ); Assert.AreEqual( 5, seq.Length ); Assert.AreEqual( "AA", seq.Alphabet.Name ); Assert.AreEqual( "ARTGX", seq.Letters() ); seq = new Sequence( AlphabetType.RNA, "AcUGz" ); Assert.AreEqual( "acugn", seq.Letters() ); seq = new Sequence( AlphabetType.RNA, seq ); Assert.AreEqual( "acugn", seq.Letters() ); seq = new Sequence( AlphabetType.UNKNOWN, "actgactg" ); Assert.AreEqual( "actgactg", seq.Letters() ); Assert.AreEqual( AlphabetFactory.Instance( AlphabetType.DNA ), seq.Alphabet ); seq = new Sequence( AlphabetType.UNKNOWN, "AMCMKQQRTAYWY" ); Assert.AreEqual( "AMCMKQQRTAYWY", seq.Letters() ); Assert.AreEqual( AlphabetFactory.Instance( AlphabetType.PROTEIN ), seq.Alphabet ); Alphabet alpha = DnaAlphabet.Instance(); Symbol[] symbols = { alpha['A'], alpha['C'], alpha['T'] }; seq = new Sequence( alpha, symbols, false ); symbols[0] = alpha['G']; //shouldnt be able to change the symbol Assert.AreEqual( "act", seq.Letters() ); }
/** Test of the string representation for sections */ public void TestLetters2 () { Sequence seq = new Sequence( AlphabetType.AA, "ARTG", true ); Assert.AreEqual( "ARTG", seq.Letters( 1, 4 ) ); Assert.AreEqual( "ARTGA", seq.Letters( 1, 5 ) ); Assert.AreEqual( "RT", seq.Letters( 2, 3 ) ); Assert.AreEqual( "GAR", seq.Letters( 4, 6 ) ); }
/** Test of the string representation */ public void TestLetters () { Sequence seq = new Sequence( AlphabetType.AA, "ARTGARTG" ); Assert.AreEqual( "ARTGARTG", seq.Letters() ); }
/// <summary> /// The implementation ensures that /// a match fails for a given position if there is no match. Otherwise the /// matcher might return a match at a different position. /// <see cref="QUT.Bio.BioPatML.Patterns.IPattern">IPattern Match(Sequence, int) method</see> /// </summary> /// <param name="sequence"> the sequence for matching</param> /// <param name="position"> position used for matching</param> /// <returns></returns> public override Match Match(Sequence sequence, int position) { String charSequence = sequence.Letters(position, sequence.Length); int startIndex = position - 1; //String charSequence = sequence.Letters(); System.Text.RegularExpressions.Match myMatch; if(!IsCaseSensitive) myMatch = Regex.Match(charSequence, RegularEx, RegexOptions.IgnoreCase); else myMatch = Regex.Match(charSequence, RegularEx); if (myMatch.Success) { //if ((myMatch.Index + (position - 1)) //Minus away the infront seq's position -1 for the start index 0 // != position - 1) int foundIndex = myMatch.Index + startIndex; if ((foundIndex) != position - 1) //if((myMatch.Index) != position - 1) { //Increment = myMatch.Index + 1 - position; Increment = foundIndex + 1 - position; return (null); } Increment = 1; Matched.Set(sequence, foundIndex + 1, myMatch.Length, sequence.Strand, 1.0); //GetMatch().Set(sequence, myMatch.Index + 1, // myMatch.Length, sequence.Strand, 1.0); return (Matched); } Increment = Math.Max(1, sequence.Length - position); return null; }