X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fread_fasta;h=8bc5874f55dc0a6399e78c6a29167af9fdb773c1;hb=381ac0da9f2a23e39e5fe3708b120cea3530b8d6;hp=9b77008554c1dece44c0fcb257d7c9375bcf87b4;hpb=494dc53ebd515b1e3e9b91bbebf43059899ca4ce;p=biopieces.git diff --git a/bp_bin/read_fasta b/bp_bin/read_fasta index 9b77008..8bc5874 100755 --- a/bp_bin/read_fasta +++ b/bp_bin/read_fasta @@ -35,32 +35,34 @@ casts = [] casts << {:long=>'data_in', :short=>'i', :type=>'files!', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil} casts << {:long=>'num', :short=>'n', :type=>'uint', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>'0'} -bp = Biopieces.new +options = Biopieces.options_parse(ARGV, casts) -options = bp.parse(ARGV, casts) - -bp.each_record do |record| - bp.puts record -end +Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| + unless options[:data_in] and options[:data_in].first == '-' + input.each_record do |record| + output.puts record + end + end -num = 0 -last = false + num = 0 + last = false -if options.has_key? :data_in - options[:data_in].each do |file| - Fasta.open(file, mode='r') do |fasta| - fasta.each do |entry| - bp.puts entry.to_bp - num += 1 + if options[:data_in] + options[:data_in].each do |file| + Fasta.open(file, mode='r') do |fasta| + fasta.each do |entry| + output.puts entry.to_bp + num += 1 - if options.has_key? :num and options[:num] == num - last = true - break + if options[:num] and options[:num] == num + last = true + break + end end end - end - break if last + break if last + end end end