Permalink
Browse files

added non-numerical parameters sampling and improved unique output id…

…entifiers
  • Loading branch information...
1 parent 1a6404d commit 2e24a768b10d3b2183cfa8e37b6901b67eebf691 @fstrozzi committed Sep 24, 2012
Showing with 20 additions and 6 deletions.
  1. +2 −1 Gemfile
  2. +4 −0 bin/bio-grid
  3. +8 −1 lib/bio/grid.rb
  4. +5 −4 lib/bio/grid/job.rb
  5. +1 −0 lib/bioruby-grid.rb
View
@@ -2,12 +2,13 @@ source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
-
+gem "uuid"
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem "rspec", "~> 2.8.0"
gem "rdoc", "~> 3.12"
gem "bundler", "> 1.0.0"
gem "jeweler", "~> 1.8.4"
+ gem "uuid"
end
View
@@ -38,6 +38,10 @@ optparse = OptionParser.new do |opts|
options[:clean] = true
end
+ opts.on("-a","--params PARAM1,PARAM2...",Array,"List of parameters to use for sampling") do |params|
+ options[:params] = params
+ end
+
opts.on("-d","--dry","Dry run. Just write the job scripts without sending them in queue (for debugging or testing)") {options[:dry] = true}
opts.on("-t","--test","Start the mapping only with the first group of reads (e.g. for testing parameters)") do |test|
View
@@ -20,7 +20,14 @@ def self.run(options)
range.each do |value|
cmd_line = options[:cmd].gsub(/<(\d+),(\d+)(,\d+)*>/,value.to_s)
job = Bio::Grid::Job.new(options) # inherit global options
- job.options[:parameter_value] = "-param-#{value}"
+ job.options[:parameter_value] = "-param:#{value}"
+ job.execute(cmd_line,inputs,input1,groups,index)
+ end
+ elsif options[:params]
+ options[:params].each do |p|
+ cmd_line = options[:cmd].gsub(/<param>|<parameter>/,p)
+ job = Bio::Grid::Job.new(options)
+ job.options[:parameter_value] = "-param:#{p}"
job.execute(cmd_line,inputs,input1,groups,index)
end
else
View
@@ -2,10 +2,11 @@ module Bio
class Grid
class Job
- attr_accessor :options, :instructions, :job_output, :runner
+ attr_accessor :options, :instructions, :job_output, :runner, :uuid
def initialize(options)
@options = options
self.instructions = []
+ self.uuid = UUID.new.generate.split("-").first
end
def set_output_dir
@@ -21,13 +22,13 @@ def set_commandline(cmd_line,inputs,input1,groups,index)
job_output = ""
if commandline =~/<output>\.(\S+)/
extension = $1
- job_output = self.options[:output]+"/#{Time.now.to_i}"+self.options[:name]+"_output_%03d" % (index+1).to_s + "#{self.options[:parameter_value]}"
+ job_output = self.options[:output]+"/#{self.uuid}_"+self.options[:name]+"_output_%03d" % (index+1).to_s + "#{self.options[:parameter_value]}"
commandline.gsub!(/<output>/,job_output)
job_output << ".#{extension}"
else
self.options[:output_folder] = true
- commandline.gsub!(/<output>/,self.options[:output]+"/#{Time.now.to_i}_"+self.options[:name])
- job_output = self.options[:output]+"/#{Time.now.to_i}_"+self.options[:name]
+ job_output = self.options[:output]+"/#{self.uuid}_"+self.options[:name]
+ commandline.gsub!(/<output>/,job_output)
end
self.instructions << commandline+"\n"
self.job_output = job_output
View
@@ -1,2 +1,3 @@
+require 'uuid'
require 'bio/grid'
require 'bio/grid/job'

0 comments on commit 2e24a76

Please sign in to comment.