]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/seq.rb
added test for length of seq/qual mismatch
[biopieces.git] / code_ruby / lib / maasha / seq.rb
index 73bf0552938cef82fa937aa43ff7be23b190c94b..fd83ba3282d28c561358fb9383c18e324d9a7ed4 100644 (file)
@@ -30,6 +30,7 @@ require 'narray'
 autoload :BackTrack,   'maasha/seq/backtrack'
 autoload :Dynamic,     'maasha/seq/dynamic'
 autoload :Homopolymer, 'maasha/seq/homopolymer'
+autoload :Hamming,     'maasha/seq/hamming'
 autoload :Levenshtein, 'maasha/seq/levenshtein'
 autoload :Ambiguity,   'maasha/seq/ambiguity'
 
@@ -134,6 +135,10 @@ class Seq
     @seq      = seq
     @type     = type
     @qual     = qual
+
+    if @qual
+      raise SeqError, "Sequence length and score length mismatch: #{@seq.length} != #{@qual.length}" if @seq.length != @qual.length
+    end
   end
 
   # Method that guesses and returns the sequence type
@@ -387,7 +392,7 @@ class Seq
   # two Sequence objects (case insensitive).
   def hamming_distance(entry, options = nil)
     if options and options[:ambiguity]
-      Ambiguity.hamming_distance(self.seq, entry.seq)
+      Hamming.distance(self.seq, entry.seq)
     else
       self.seq.upcase.hamming_distance(entry.seq.upcase)
     end