@entry = Seq.new
end
- # def test_Seq# autoremoves whitespace, newlines, and carriage returns
+ # # autoremoves whitespace, newlines, and carriage returns
+ # def test_Seq_strip
# dna = Seq.new
# dna.seq = "A\tT\r\tC\nG "
# assert_equal(dna.seq, "ATCG")
def test_Seq_reverse_returns_correctly
@entry.seq = "ATCG"
- assert_equal("GCTA", @entry.reverse.seq)
+ new_entry = @entry.reverse
+ assert_equal("GCTA", new_entry.seq)
+ assert_equal("ATCG", @entry.seq)
+ end
+
+ def test_Seq_reverse_bang_returns_correctly
+ @entry.seq = "ATCG"
+ @entry.reverse!
+ assert_equal("GCTA", @entry.seq)
end
def test_Seq_complement_raises_if_no_sequence
def test_Seq_complement_for_DNA_is_correct
@entry.seq = 'ATCGatcg'
@entry.type = 'dna'
- assert_equal("TAGCtagc", @entry.complement)
+ comp = @entry.complement
+ assert_equal("TAGCtagc", comp.seq)
+ assert_equal("ATCGatcg", @entry.seq)
end
def test_Seq_complement_for_RNA_is_correct
@entry.seq = 'AUCGaucg'
@entry.type = 'rna'
- assert_equal("UAGCuagc", @entry.complement)
+ comp = @entry.complement
+ assert_equal("UAGCuagc", comp.seq)
+ assert_equal("AUCGaucg", @entry.seq)
+ end
+
+ def test_Seq_complement_bang_raises_if_no_sequence
+ @entry.type = 'dna'
+ assert_raise(SeqError) { @entry.complement! }
+ end
+
+ def test_Seq_complement_bang_raises_on_bad_type
+ @entry.seq = 'ATCG'
+ @entry.type = 'protein'
+ assert_raise(SeqError) { @entry.complement! }
end
- def test_Seq_reverse_complement_for_DNA_is_correct
+ def test_Seq_complement_bang_for_DNA_is_correct
@entry.seq = 'ATCGatcg'
@entry.type = 'dna'
- assert_equal("cgatCGAT", @entry.reverse_complement.seq)
+ assert_equal("TAGCtagc", @entry.complement!.seq)
end
- def test_Seq_reverse_complement_for_RNA_is_correct
+ def test_Seq_complement_bang_for_RNA_is_correct
@entry.seq = 'AUCGaucg'
@entry.type = 'rna'
- assert_equal("cgauCGAU", @entry.reverse_complement.seq)
+ assert_equal("UAGCuagc", @entry.complement!.seq)
end
+
def test_Seq_hamming_distance_returns_correctly
seq1 = Seq.new("test1", "ATCG")
seq2 = Seq.new("test2", "atgg")
end
end
+ def test_Seq_shuffle_returns_correctly
+ orig = "actgactgactgatcgatcgatcgatcgtactg"
+ @entry.seq = "actgactgactgatcgatcgatcgatcgtactg"
+ entry_shuf = @entry.shuffle
+ assert_equal(orig, @entry.seq)
+ assert_not_equal(@entry.seq, entry_shuf.seq)
+ end
+
+ def test_Seq_shuffle_bang_returns_correctly
+ @entry.seq = "actgactgactgatcgatcgatcgatcgtactg"
+ assert_not_equal(@entry.seq, @entry.shuffle!.seq)
+ end
+
def test_Seq_subseq_with_start_lt_0_raises
@entry.seq = "ATCG"
assert_raise(SeqError) { @entry.subseq(-1, 1) }