Permalink
Browse files

check if input exists

  • Loading branch information...
1 parent 71e7faf commit 8c95108bc9f99fb90fa6089ef599372b9f52456f @fstrozzi committed Sep 25, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/bio/grid.rb
View
@@ -10,7 +10,7 @@ def initialize(input,number)
end
def self.run(options)
- options[:number] = 1 unless options[:number]
+ options[:number] = "all" unless options[:number]
grid = self.new options[:input], options[:number]
options[:uuid] = grid.uuid
groups = grid.prepare_input_groups
@@ -41,13 +41,15 @@ def self.run(options)
end
end
- def prepare_input_groups
+ def prepare_input_groups
groups = Hash.new {|h,k| h[k] = [] }
self.input.each_with_index do |location,index|
+ list = Dir.glob(location).sort
+ raise ArgumentError,"Input file or folder #{location} do not exist!" if list.empty?
if self.number == "all"
- groups["input#{index+1}"] = [Dir.glob(location).sort]
+ groups["input#{index+1}"] = [list]
else
- Dir.glob(location).sort.each_slice(self.number.to_i) {|subgroup| groups["input#{index+1}"] << subgroup}
+ list.each_slice(self.number.to_i) {|subgroup| groups["input#{index+1}"] << subgroup}
end
end
groups

0 comments on commit 8c95108

Please sign in to comment.