]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/seq.rb
fixed score base bug in sff.rb
[biopieces.git] / code_ruby / lib / maasha / seq.rb
index 92ce19edaee4a9176487272a8f1a89c32c7ee806..d8a73d31ba8d660fa08bb6aac9c0c24f91137151 100644 (file)
@@ -416,6 +416,15 @@ class Seq
     self
   end
 
+  # Method to add two Seq objects.
+  def +(entry)
+    new_entry = Seq.new()
+    new_entry.seq  = self.seq  + entry.seq
+    new_entry.type = self.type              if self.type == entry.type
+    new_entry.qual = self.qual + entry.qual if self.qual and entry.qual
+    new_entry
+  end
+
   # Method to concatenate sequence entries.
   def <<(entry)
     raise SeqError, "sequences of different types" unless self.type == entry.type
@@ -427,6 +436,25 @@ class Seq
     self
   end
 
+  # Index method for Seq objects.
+  def [](*args)
+    entry = Seq.new
+    entry.seq_name = self.seq_name
+    entry.seq      = self.seq[*args]
+    entry.type     = self.type
+    entry.qual     = self.qual[*args] unless self.qual.nil?
+
+    entry
+  end
+
+  # Index assignment method for Seq objects.
+  def []=(*args, entry)
+    self.seq[*args]  = entry.seq[*args]
+    self.qual[*args] = entry.qual[*args] unless self.qual.nil?
+
+    self
+  end
+
   # Method that returns a subsequence of from a given start position
   # and of a given length.
   def subseq(start, length = self.length - start)
@@ -444,7 +472,9 @@ class Seq
       qual = self.qual[start .. stop] unless self.qual.nil?
     end
 
-    Seq.new(self.seq_name, seq, self.type, qual)    # TODO changed self.seq_name.dup to self.seq_name -> consequence?
+    seq_name = self.seq_name.nil? ? nil : self.seq_name.dup
+
+    Seq.new(seq_name, seq, self.type, qual)
   end
 
   # Method that replaces a sequence with a subsequence from a given start position