seq_new
end
- # Method to shuffle a sequence readomly inline.
+ # Method to return a new Seq object with shuffled sequence.
+ def shuffle
+ Seq.new(self.seq_name, self.seq.split('').shuffle!.join, self.type, self.qual)
+ end
+
+ # Method to shuffle a sequence randomly inline.
def shuffle!
self.seq = self.seq.split('').shuffle!.join
self
@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")
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) }