]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/read_fastq
updated biopieces_installer.sh
[biopieces.git] / bp_bin / read_fastq
index 063edd6ce2883bbe5b46f286c59175c71cf55456..923a3b057c7198b9792a799fa82e4b2102d26f8a 100755 (executable)
@@ -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