From: martinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Date: Fri, 18 Mar 2011 16:29:49 +0000 (+0000)
Subject: fixed stdin read for fastq and ruby code
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c77dcc6c7371dec0c66fe42bc2fde38d5fcbdcb8;p=biopieces.git

fixed stdin read for fastq and ruby code

git-svn-id: http://biopieces.googlecode.com/svn/trunk@1293 74ccb610-7750-0410-82ae-013aeee3265d
---

diff --git a/code_ruby/Maasha/lib/biopieces.rb b/code_ruby/Maasha/lib/biopieces.rb
index 2ab9aa7..05658e4 100644
--- a/code_ruby/Maasha/lib/biopieces.rb
+++ b/code_ruby/Maasha/lib/biopieces.rb
@@ -453,6 +453,7 @@ class OptionHandler
   def options_check_files(cast)
     if cast[:type] == 'files!' and @options.has_key? cast[:long]
       @options[cast[:long]].each do |path|
+        next if path == "-"
         raise ArgumentError, "File not readable: '#{path}'" unless File.readable? path
       end
     end
@@ -570,7 +571,11 @@ class Stream < IO
   # specified in options[:stream_out] or options[:data_out].
   def self.open(options, mode, stdio)
     if mode == "r"
-      $stdin.tty? ? read(options[:stream_in]) : stdio
+      if options[:data_in].first == "-"
+        self.nread(["-"])
+      else
+        $stdin.tty? ? read(options[:stream_in]) : stdio
+      end
     elsif mode == "w"
       options[:stream_out] ? self.write(options[:stream_out], options[:compress]) : stdio
     else
diff --git a/code_ruby/Maasha/lib/fastq.rb b/code_ruby/Maasha/lib/fastq.rb
index 2988785..44a9013 100644
--- a/code_ruby/Maasha/lib/fastq.rb
+++ b/code_ruby/Maasha/lib/fastq.rb
@@ -34,7 +34,10 @@ class Fastq
   # Class method allowing open to be used on (zipped) files.
   # See File.open.
   def self.open(*args)
-    if File.pipe? *args.first
+    tyt = *args
+    if tyt.first == "-"
+      ios = self.new(STDIN)
+    elsif File.pipe? *args.first
       ios = self.new(File.open(*args))
     else
       ios = self.zopen(*args)