#!/usr/bin/env ruby
-# Copyright (C) 2007-2010 Martin A. Hansen.
+# Copyright (C) 2007-2011 Martin A. Hansen.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
PHRED_SCORES = Regexp.new('[!"#$%&\'()*+,-./0123456789:]')
-bp = Biopieces.new
-
-options = bp.parse(ARGV, casts)
-
-bp.each_record do |record|
- bp.puts record
-end
+options = Biopieces.options_parse(ARGV, casts)
num = 0
last = false
-if options.has_key? :data_in
- options[:data_in].each do |file|
- Fastq.open(file, mode='r') do |fastq|
- fastq.each do |entry|
- entry.convert_phred2illumina! if entry.qual.match PHRED_SCORES
- entry.convert_solexa2illumina! if options[:solexa]
- bp.puts entry.to_bp
- num += 1
-
- if options.has_key? :num and options[:num] == num
- last = true
- break
+Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
+ input.each_record do |record|
+ output.puts record
+ end
+
+ if options.has_key? :data_in
+ options[:data_in].each do |file|
+ Fastq.open(file, mode='r') do |fastq|
+ fastq.each do |entry|
+ entry.convert_phred2illumina! if entry.qual.match PHRED_SCORES
+ entry.convert_solexa2illumina! if options[:solexa]
+ output.puts entry.to_bp
+ num += 1
+
+ if options.has_key? :num and options[:num] == num
+ last = true
+ break
+ end
end
end
- end
- break if last
+ break if last
+ end
end
end