]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/sff.rb
fixed score base bug in sff.rb
[biopieces.git] / code_ruby / lib / maasha / sff.rb
index b0ec7386ef18530e063cf8ed84be150110317a9d..6b277e39b9c9b0e602c08ec386e56968e64df613 100644 (file)
@@ -195,7 +195,11 @@ class Read
 
   # Method that converts a Read object's data to a Biopiece record (a hash).
   def to_bp
-    coordinates_get
+    # Simulated SFF files may not have coordinates.
+    begin
+      coordinates_get
+    rescue
+    end
 
     hash = {}
 
@@ -206,7 +210,7 @@ class Read
     hash[:CLIP_QUAL_RIGHT]    = self.clip_qual_right    - 1
     hash[:CLIP_ADAPTOR_LEFT]  = self.clip_adapter_left  - 1
     hash[:CLIP_ADAPTOR_RIGHT] = self.clip_adaptor_right - 1
-    hash[:SCORES]             = self.quality_scores.map { |i| (i += 64).chr }.join ""
+    hash[:SCORES]             = self.quality_scores.map { |i| (i += Seq::SCORE_BASE).chr }.join ""
     hash[:X_POS]              = self.x_pos
     hash[:Y_POS]              = self.y_pos
 
@@ -215,7 +219,7 @@ class Read
 
   # Method that converts a Read object's data to a Seq object.
   def to_seq
-    Seq.new(self.name, self.bases, nil, self.quality_scores.map { |i| (i += 64).chr }.join("") )
+    Seq.new(self.name, self.bases, nil, self.quality_scores.map { |i| (i += Seq::SCORE_BASE).chr }.join("") )
   end
 
   # Method that soft masks the sequence (i.e. lowercases sequence) according to