]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed type bug in ruby code
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 13 Aug 2010 08:51:56 +0000 (08:51 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 13 Aug 2010 08:51:56 +0000 (08:51 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1057 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/swapcase_seq
code_python/Cjung/Args.pyc
code_ruby/Maasha/lib/biopieces.rb
code_ruby/Maasha/test/test_biopieces.rb

index 9681ae2df1b1338e9c32038cf8e760303477f89f..4831f2aa1abd15375c0b0423269ef30a6c5424fe 100755 (executable)
@@ -35,7 +35,7 @@ casts = []
 
 bp = Biopieces.new
 
-options = bp.parse(ARGV,casts)
+options = bp.parse(ARGV, casts)
 
 bp.each_record do |record|
   record["SEQ"].swapcase! if record.has_key? "SEQ"
index 795e1a5b55df1872c78e3b6dd439ae10af66b542..4c39c4a68733e7fdac49e939fe26d08e98449439 100644 (file)
Binary files a/code_python/Cjung/Args.pyc and b/code_python/Cjung/Args.pyc differ
index 4dc51b1da66bac1a3ed68e9a753de17482da8dd6..3bc2cc23e746f7ef7e4dc52139d61c2c9e045372 100644 (file)
@@ -61,6 +61,7 @@ class Biopieces
   # records in the stream.
   def each_record
     @in = Stream::open(@options, mode="r", @input) unless @in.is_a? IO
+    return if @in.nil?
 
     record = {}
 
@@ -448,9 +449,9 @@ class OptionHandler
   def options_check_allowed(cast)
     if cast[:allowed] and @options.has_key? cast[:long]
       allowed_hash = {}
-      cast[:allowed].split(',').each { |a| allowed_hash[a] = 1 }
+      cast[:allowed].split(',').each { |a| allowed_hash[a.to_s] = 1 }
   
-      raise ArgumentError, "Argument '#{@options[cast[:long]]}' to --#{cast[:long]} not allowed" unless allowed_hash.has_key? @options[cast[:long]]
+      raise ArgumentError, "Argument '#{@options[cast[:long]]}' to --#{cast[:long]} not allowed" unless allowed_hash.has_key? @options[cast[:long]].to_s
     end
   end
   
@@ -458,7 +459,7 @@ class OptionHandler
   def options_check_disallowed(cast)
     if cast[:disallowed] and @options.has_key? cast[:long]
       cast[:disallowed].split(',').each do |val|
-        raise ArgumentError, "Argument '#{@options[cast[:long]]}' to --#{cast[:long]} is disallowed" if val == @options[cast[:long]]
+        raise ArgumentError, "Argument '#{@options[cast[:long]]}' to --#{cast[:long]} is disallowed" if val.to_s == @options[cast[:long]].to_s
       end
     end
   end
@@ -550,6 +551,7 @@ class Stream < IO
 
   # Opens a reads stream to a list of files.
   def self.read(files)
+    return if files.nil? #TODO case/when
     self.zipped?(files) ? self.zread(files) : self.nread(files)
   end
 
index 0f97107790f8adc629f6db964223b89cbe3ab875..9770bc3966ede80aa979c5f8e09ee35b0a0ff244 100755 (executable)
@@ -1,6 +1,30 @@
 #!/usr/bin/env ruby
 # $:.unshift File.join(File.dirname(__FILE__),'..','lib')
 
+# Copyright (C) 2007-2010 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
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# This software is part of the Biopieces framework (www.biopieces.org).
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
 require 'test/unit'
 require 'mocha'
 require 'biopieces'
@@ -115,7 +139,7 @@ class OptionTest < Test::Unit::TestCase
   end
 
   test "Biopieces#parse with legal allowed cast values don't raise" do
-    ["foo,bar",nil].each do |allowed|
+    ["foo,bar,0",nil].each do |allowed|
       argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>allowed, :disallowed=>nil}]
       assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }
@@ -131,7 +155,7 @@ class OptionTest < Test::Unit::TestCase
   end
 
   test "Biopieces#parse with legal disallowed cast values don't raise" do
-    ["foo,bar",nil].each do |disallowed|
+    ["foo,bar,0",nil].each do |disallowed|
       argv  = []
       casts = [{:long=>"foo", :short=>"f", :type=>"int", :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>disallowed}]
       assert_nothing_raised(CastError) { @bp.parse(argv, casts, SCRIPT_PATH) }