]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed bug in shred_seq
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sat, 29 Jan 2011 16:21:40 +0000 (16:21 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Sat, 29 Jan 2011 16:21:40 +0000 (16:21 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1227 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/shred_seq

index a59b688349e56bc76de5af42e6f401a66470b620..2a70b1a98af8deada5086bf5a391dc9aa827e809 100755 (executable)
@@ -47,7 +47,12 @@ class Seq
     strand  = '+'
 
     while (sum / self.seq.length) < max_cov
-      start    = rand(self.seq.size - size)
+      if self.seq.size - size == 0
+        start = 0
+      else
+        start    = rand(self.seq.size - size)
+      end
+
       stop     = start + size - 1
       seq_name = self.seq_name + "[#{start + 1}-#{stop + 1}:#{strand}]"
       seq      = self.seq[start .. stop]
@@ -79,7 +84,7 @@ bp = Biopieces.new
 options = bp.parse(ARGV, casts)
 
 bp.each_record do |record|
-  if record.has_key? :SEQ
+  if record.has_key? :SEQ and record[:SEQ].length >= options[:size]
     entry = Seq.new(record[:SEQ_NAME], record[:SEQ], record[:SCORES])
 
     entry.shred(options[:size], options[:coverage]) do |subentry|