class Bio::Conduit::Step
Constants
- UNITCONV
Attributes
info[R]
name[R]
resources[R]
Public Class Methods
new(name, hash, resources, addpath = true)
click to toggle source
# File lib/bio/conduit/process.rb, line 24 def initialize(name, hash, resources, addpath = true) @name = name @info = hash @resources = resources if addpath if @info['run'].is_a?(String) @info['run'] = ["mkdir -p <sample_output_path/>#{@name}", "cd <sample_output_path/>#{@name}", @info['run']] elsif @info['run'].is_a?(Array) @info['run'].unshift("mkdir -p <sample_output_path/>#{@name}", "cd <sample_output_path/>#{@name}") end end end
Public Instance Methods
+(other)
click to toggle source
# File lib/bio/conduit/process.rb, line 50 def +(other) name = self.name + "_" + other.name resources = self.resources.merge(other.resources) info = self.info.merge(other.info) do |k, first, second| case k when 'mem', 'cpu', 'nodes' matched1 = /\A(\d+)([kmgtb]?)/.match(first) matched2 = /\A(\d+)([kmgtb]?)/.match(second) if (matched1[1].to_i * Bio::Conduit::Step::UNITCONV[matched1[2]]) > (matched2[1].to_i * Bio::Conduit::Step::UNITCONV[matched2[2]]) first elsif (matched1[1].to_i * Bio::Conduit::Step::UNITCONV[matched1[2]]) < (matched2[1].to_i * Bio::Conduit::Step::UNITCONV[matched2[2]]) second else first end else if first.is_a?(String) && second.is_a?(String) [first, second] elsif first.is_a?(Array) && second.is_a?(String) first + [second] elsif first.is_a?(String) && second.is_a?(Array) [first] + second else first + second end end end Bio::Conduit::Step.new(name, info, resources, false) end
create_jobscript(sample, template)
click to toggle source
# File lib/bio/conduit/process.rb, line 80 def create_jobscript(sample, template) total_resources = @resources.merge(sample['resources']) total_resources['sample_path'] = sample['path'] total_resources['sample'] = sample['name'] total_resources['sample_output_path'] = "#{total_resources['output'].chomp('/')}" + "#{sample.has_key?('group') ? "/#{sample['group']}" : ''}" + "/#{sample['name']}" @jobname = sample['name'] + "_" + @name @commands = @info['run'].is_a?(Array) ? @info['run'].join("\n") : @info['run'].clone subslist = {} @commands.scan(/(\<([\w\/]+)\>)/).each do |entry| entry[1].scan(/[^\/]+/).each do |res| entry[1].sub!(/#{res}/, total_resources[res]) end @commands.sub!(/#{entry[0]}/, entry[1]) end return ERB.new(template, nil, '-').result(binding) end
dependence?()
click to toggle source
# File lib/bio/conduit/process.rb, line 38 def dependence? return @info.has_key?('pre') end
dependency()
click to toggle source
# File lib/bio/conduit/process.rb, line 42 def dependency if self.dependence? return @info['pre'] else return nil end end