X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fbin_vals;h=e5e73c7b4c1e5ecef4831543886b0c95825c1e5f;hb=7c0fcb47dbf02882b86fa507b7888495b0878e6f;hp=42fb7d6869eeecdec7af9412c50189ff18772338;hpb=8d7c125030571156fc837fb434e9f1cb21e81d12;p=biopieces.git diff --git a/bp_bin/bin_vals b/bp_bin/bin_vals index 42fb7d6..e5e73c7 100755 --- a/bp_bin/bin_vals +++ b/bp_bin/bin_vals @@ -29,22 +29,22 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -require 'biopieces' +require 'maasha/biopieces' casts = [] casts << {:long=>'key', :short=>'k', :type=>'string', :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil} casts << {:long=>'bin_size', :short=>'b', :type=>'uint', :mandatory=>true, :default=>10, :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.has_key? options[:key].to_sym + record[(options[:key] + "_BIN").to_sym] = (record[options[:key].to_sym].to_i / options[:bin_size]) * options[:bin_size] + end -bp.each_record do |record| - if record.has_key? options[:key] - record[(options[:key].to_s + "_BIN").to_sym] = (record[options[:key]].to_i / options[:bin_size]) * options[:bin_size] + output.puts record end - - bp.puts record end