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