X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fread_fastq;h=923a3b057c7198b9792a799fa82e4b2102d26f8a;hb=4bb57fda5e415393a6074b13d424d3f0019d6847;hp=063edd6ce2883bbe5b46f286c59175c71cf55456;hpb=494dc53ebd515b1e3e9b91bbebf43059899ca4ce;p=biopieces.git diff --git a/bp_bin/read_fastq b/bp_bin/read_fastq index 063edd6..923a3b0 100755 --- a/bp_bin/read_fastq +++ b/bp_bin/read_fastq @@ -1,6 +1,6 @@ #!/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 @@ -38,34 +38,34 @@ casts << {:long=>'solexa', :short=>'s', :type=>'flag', :mandatory=>false, :de 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