X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fshred_seq;h=322916426e606dd11259eb6f34757486296e039d;hb=5de6112b70b59420b245ce636a8b2e3c90acbe00;hp=f9e1a42d1181fe204cfadf8cde7c232fbb505aa0;hpb=674f7ca55a64bce4d447c0e5a51f43d6c70df07d;p=biopieces.git diff --git a/bp_bin/shred_seq b/bp_bin/shred_seq index f9e1a42..3229164 100755 --- a/bp_bin/shred_seq +++ b/bp_bin/shred_seq @@ -29,8 +29,8 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -require 'biopieces' -require 'seq' +require 'maasha/biopieces' +require 'maasha/seq' require 'pp' class Seq @@ -51,7 +51,7 @@ class Seq while coverage(sum) < max_cov entry = self.subseq_rand(size) - entry.revcomp if strand == '-' + entry.reverse!.complement! if strand == '-' if block_given? yield entry @@ -79,21 +79,22 @@ casts = [] casts << {:long=>'size', :short=>'s', :type=>'uint', :mandatory=>true, :default=>500, :allowed=>nil, :disallowed=>'0'} casts << {:long=>'coverage', :short=>'c', :type=>'uint', :mandatory=>true, :default=>100, :allowed=>nil, :disallowed=>'0'} -bp = Biopieces.new +options = Biopieces.options_parse(ARGV, casts) -options = bp.parse(ARGV, casts) +Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| + input.each_record do |record| + if record[:SEQ] and record[:SEQ].length >= options[:size] + entry = Seq.new_bp(record) + entry.type = :dna -bp.each_record do |record| - if record.has_key? :SEQ and record[:SEQ].length >= options[:size] - entry = Seq.new(record[:SEQ_NAME], record[:SEQ], record[:SCORES]) - entry.type = 'dna' - - entry.shred(options[:size], options[:coverage]) do |subentry| - bp.puts subentry.to_bp + entry.shred(options[:size], options[:coverage]) do |subentry| + output.puts subentry.to_bp + end end end end + # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<