]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/seq.rb
added new match.rb and tests
[biopieces.git] / code_ruby / lib / maasha / seq.rb
index d13cdaba9dde6cb68ff5c44f93a9759d5d6174d1..6c0f35b358e67135b35c4032b7fc9e9a78e6e0fb 100644 (file)
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 require 'maasha/bits'
-require 'maasha/seq/backtrack'
 require 'maasha/seq/digest'
-#require 'maasha/seq/patscan'
-require 'maasha/seq/patternmatcher'
 require 'maasha/seq/trim'
 require 'narray'
 
+autoload :BackTrack, 'maasha/seq/backtrack.rb'
+autoload :Dynamic,   'maasha/seq/dynamic.rb'
+
 # Residue alphabets
 DNA     = %w[a t c g]
 RNA     = %w[a u c g]
@@ -76,9 +76,6 @@ SCORE_MAX  = 40
 class SeqError < StandardError; end
 
 class Seq
-  #include Patscan
-  include PatternMatcher
-  include BackTrack
   include Digest
   include Trim
 
@@ -538,8 +535,21 @@ class Seq
     self
   end
 
+  # Method that determines if a quality score string can be
+  # absolutely identified as base 33.
+  def qual_base33?
+    self.qual.match(/[!-:]/)
+  end
+
+  # Method that determines if a quality score string can be
+  # absolutely identified as base 64.
+  def qual_base64?
+    self.qual.match(/[K-h]/)
+  end
+
   # Method to convert quality scores inbetween formats.
   # Sanger     base 33, range  0-40 
+  # 454        base 64, range  0-40 
   # Solexa     base 64, range -5-40 
   # Illumina13 base 64, range  0-40 
   # Illumina15 base 64, range  3-40 
@@ -550,6 +560,7 @@ class Seq
 
       case from.downcase
       when "sanger"     then na_qual -= 33
+      when "454"        then na_qual -= 64
       when "solexa"     then na_qual -= 64
       when "illumina13" then na_qual -= 64
       when "illumina15" then na_qual -= 64
@@ -559,6 +570,7 @@ class Seq
 
       case to.downcase
       when "sanger"     then na_qual += 33
+      when "454"        then na_qual += 64
       when "solexa"     then na_qual += 64
       when "illumina13" then na_qual += 64
       when "illumina15" then na_qual += 64