@qual = qual
end
+ # Method that guesses and returns the sequence type
+ # by inspecting the first 100 residues.
+ def type_guess
+ raise SeqError, "Guess failed: sequence is nil" if self.seq.nil?
+
+ case self.seq[0 ... 100].downcase
+ when /[flpqie]/ then return "protein"
+ when /[u]/ then return "rna"
+ else return "dna"
+ end
+ end
+
+ # Method that guesses and sets the sequence type
+ # by inspecting the first 100 residues.
+ def type_guess!
+ self.type = self.type_guess
+ end
+
# Returns the length of a sequence.
def length
self.seq.nil? ? 0 : self.seq.length
def test_Seq_is_protein_with_protein_sequence_type_returns_true
@entry.type = 'protein'
- assert(@entry.is_protein? == true)
+ assert_equal(true, @entry.is_protein?)
+ end
+
+ def test_Seq_type_guess_without_sequence_raises
+ assert_raise(SeqError) { @entry.type_guess }
+ end
+
+ def test_Seq_type_guess_with_protein_returns_protein
+ @entry.seq = 'atcatcrFgatcg'
+ assert_equal('protein', @entry.type_guess)
+ end
+
+ def test_Seq_type_guess_with_rna_returns_rna
+ @entry.seq = 'atcatcrUgatcg'
+ assert_equal('rna', @entry.type_guess)
+ end
+
+ def test_Seq_type_guess_with_dna_returns_dna
+ @entry.seq = 'atcatcgatcg'
+ assert_equal('dna', @entry.type_guess)
+ end
+
+ def test_Seq_type_guess_EM_without_sequence_raises
+ assert_raise(SeqError) { @entry.type_guess! }
+ end
+
+ def test_Seq_type_guess_EM_with_protein_returns_protein
+ @entry.seq = 'atcatcrFgatcg'
+ @entry.type_guess!
+ assert_equal('protein', @entry.type)
+ end
+
+ def test_Seq_type_guess_EM_with_rna_returns_rna
+ @entry.seq = 'atcatcrUgatcg'
+ @entry.type_guess!
+ assert_equal('rna', @entry.type)
+ end
+
+ def test_Seq_type_guess_EM_with_dna_returns_dna
+ @entry.seq = 'atcatcgatcg'
+ @entry.type_guess!
+ assert_equal('dna', @entry.type)
end
def test_Seq_length_is_correct