public void TestConvertPosition () { Sequence seq = new Sequence( AlphabetType.DNA, "actgat" ); Sequence sub1 = new Sequence( seq, 2, 4, +1 ); Assert.AreEqual( 2, seq.Position( sub1, 1 ) ); Assert.AreEqual( 1, sub1.Position( seq, 2 ) ); Sequence sub2 = new Sequence( sub1, 1, 3, +1 ); Assert.AreEqual( 2, seq.Position( sub2, 1 ) ); Assert.AreEqual( 1, sub1.Position( seq, 2 ) ); Assert.AreEqual( 1, sub1.Position( sub1, 1 ) ); Assert.AreEqual( 1, sub1.Position( sub2, 1 ) ); sub2 = new Sequence( sub1, 1, 3, -1 ); Assert.AreEqual( 4, seq.Position( sub2, 1 ) ); Assert.AreEqual( 1, sub2.Position( seq, 4 ) ); Assert.AreEqual( 3, sub2.Position( sub1, 1 ) ); Assert.AreEqual( 1, sub1.Position( sub2, 3 ) ); sub1 = new Sequence( seq, 2, 4, -1 ); Assert.AreEqual( 4, seq.Position( sub1, 1 ) ); Assert.AreEqual( 1, sub1.Position( seq, 4 ) ); sub2 = new Sequence( sub1, 1, 3, +1 ); Assert.AreEqual( 2, seq.Position( sub2, 1 ) ); Assert.AreEqual( 1, sub2.Position( seq, 2 ) ); Assert.AreEqual( 3, sub2.Position( sub1, 1 ) ); Assert.AreEqual( 1, sub1.Position( sub2, 3 ) ); sub2 = new Sequence( sub1, 1, 3, -1 ); Assert.AreEqual( 4, seq.Position( sub2, 1 ) ); Assert.AreEqual( 1, sub2.Position( seq, 4 ) ); Assert.AreEqual( 1, sub2.Position( sub1, 1 ) ); Assert.AreEqual( 1, sub1.Position( sub2, 1 ) ); }
/// <summary> /// Implementation of the <see cref="QUT.Bio.BioPatML.Patterns.IPattern">pattern interface</see>. /// </summary> /// <param name="sequence">Sequence to compare with.</param> /// <param name="position">Matching position.</param> /// <returns>The result.</returns> public override Match Match(Sequence sequence, int position) { int absAlignPos = AlignPosition(); int absPos = sequence.Position() + position - 1; Increment = absAlignPos - absPos; Matched.Set(sequence, position + Increment, 0, sequence.Strand, 1.0); return Matched; }
public void TestPosition () { Sequence seq = new Sequence( AlphabetType.DNA, "actg" ); Assert.AreEqual( 1, seq.Position() ); }