]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed each_orf
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 13 Jan 2014 10:50:03 +0000 (10:50 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Mon, 13 Jan 2014 10:50:03 +0000 (10:50 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2288 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/lib/maasha/seq.rb

index 9a8816dc53b47b60e764a98c184a44375dd36bff..7377da533d50ea34fb4dc12c3e2bfb7f05a7e944 100644 (file)
@@ -469,7 +469,7 @@ class Seq
   # Index method for Seq objects.
   def [](*args)
     entry = Seq.new
-    entry.seq_name = self.seq_name
+    entry.seq_name = self.seq_name.dup if self.seq_name
     entry.seq      = self.seq[*args]
     entry.type     = self.type
     entry.qual     = self.qual[*args] unless self.qual.nil?
@@ -485,41 +485,6 @@ class Seq
     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)
-    raise SeqError, "subsequence start: #{start} < 0"                                                if start  < 0
-    raise SeqError, "subsequence length: #{length} < 0"                                              if length < 0
-    raise SeqError, "subsequence start + length > Seq.length: #{start} + #{length} > #{self.length}" if start + length > self.length
-
-    if length == 0
-      seq  = ""
-      qual = "" unless self.qual.nil?
-    else
-      stop = start + length - 1
-
-      seq  = self.seq[start .. stop]
-      qual = self.qual[start .. stop] unless self.qual.nil?
-    end
-
-    seq_name = self.seq_name.nil? ? nil : self.seq_name.dup
-
-    Seq.new(seq_name: seq_name, seq: seq, type: self.type, qual: qual)
-  end
-
-  # Method that replaces a sequence with a subsequence from a given start position
-  # and of a given length.
-  def subseq!(start, length = self.length - start)
-    s = subseq(start, length)
-
-    self.seq_name = s.seq_name
-    self.seq      = s.seq
-    self.type     = s.type
-    self.qual     = s.qual
-
-    self
-  end
-
   # Method that returns a subsequence of a given length
   # beginning at a random position.
   def subseq_rand(length)
@@ -529,7 +494,7 @@ class Seq
       start = rand(self.length - length + 1)
     end
 
-    self.subseq(start, length)
+    self[start .. start + length]
   end
 
   # Method that returns the residue compositions of a sequence in
@@ -677,7 +642,7 @@ class Seq
 
         if (length % 3) == 0
           if size_min <= length and length <= size_max
-            subseq = self.subseq(pos_beg, length)
+            subseq = self[pos_beg ... pos_beg + length]
 
             orfs << [subseq, pos_beg, pos_end + 3]
           end