]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/seq.rb
added [] og []= to seq.rb
[biopieces.git] / code_ruby / lib / maasha / seq.rb
index f76466f583af2a18699f3aa4ee40f67fb88e250e..91e79295039e7f8e572efa0ceaf231e8e91c1bd4 100644 (file)
@@ -427,6 +427,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)