Class: Bio::Grid
- Inherits:
-
Object
- Object
- Bio::Grid
- Defined in:
- lib/bio/grid.rb,
lib/bio/grid/job.rb
Defined Under Namespace
Classes: Job
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#number ⇒ Object
Returns the value of attribute number.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input, number, uuid) ⇒ Grid
constructor
A new instance of Grid.
- #prepare_input_groups ⇒ Object
Constructor Details
#initialize(input, number, uuid) ⇒ Grid
Returns a new instance of Grid.
6 7 8 9 10 |
# File 'lib/bio/grid.rb', line 6 def initialize(input,number, uuid) @input = input @number = number @uuid = uuid ? uuid : UUID.new.generate.split("-").first end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
5 6 7 |
# File 'lib/bio/grid.rb', line 5 def input @input end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/bio/grid.rb', line 5 def number @number end |
#uuid ⇒ Object
Returns the value of attribute uuid.
5 6 7 |
# File 'lib/bio/grid.rb', line 5 def uuid @uuid end |
Class Method Details
.run(options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bio/grid.rb', line 12 def self.run() [:number] = "all" unless [:number] grid = self.new [:input], [:number], [:uuid] [:uuid] = grid.uuid unless [:uuid] groups = grid.prepare_input_groups inputs = groups.keys.sort groups[inputs.shift].each_with_index do |input1,index| if [:cmd]=~/<(\d+),(\d+)(,\d+)*>/ step = ($3) ? $3.tr(",","").to_i : 1 range = Range.new($1.to_i,$2.to_i,false).step(step).to_a range.each do |value| cmd_line = [:cmd].gsub(/<(\d+),(\d+)(,\d+)*>/,value.to_s) job = Bio::Grid::Job.new() # inherit global options job.[:parameter_value] = "-param:#{value}" job.execute(cmd_line,inputs,input1,groups,index) end elsif [:params] [:params].each do |p| cmd_line = [:cmd].gsub(/<param>|<parameter>/,p) job = Bio::Grid::Job.new() job.[:parameter_value] = "-param:#{p}" job.execute(cmd_line,inputs,input1,groups,index) end else job = Bio::Grid::Job.new() # inherit global options job.execute([:cmd],inputs,input1,groups,index) end break if [:test] end end |
Instance Method Details
#prepare_input_groups ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bio/grid.rb', line 44 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}"] = [list] else list.each_slice(self.number.to_i) {|subgroup| groups["input#{index+1}"] << subgroup} end end groups end |