From: martinahansen Date: Sat, 29 Jan 2011 16:21:40 +0000 (+0000) Subject: fixed bug in shred_seq X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=15bee5c1f1a081fa2924c65cc89e4683be6b2c45;p=biopieces.git fixed bug in shred_seq git-svn-id: http://biopieces.googlecode.com/svn/trunk@1227 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/shred_seq b/bp_bin/shred_seq index a59b688..2a70b1a 100755 --- a/bp_bin/shred_seq +++ b/bp_bin/shred_seq @@ -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|