class CagnutBwa::Mem
Public Class Methods
new(opts = {})
click to toggle source
# File lib/cagnut_bwa/functions/mem.rb, line 9 def initialize opts = {} @order = sprintf '%02i', opts[:order] @input = opts[:input].nil? ? "#{seqs_path}" : opts[:input] @input2 = File.expand_path fetch_filename, File.dirname(@input) abort('Cant recognized sequence files') if @input2.nil? @output = "#{opts[:dirs][:output]}/#{sample_name}_mem.sam" @job_name = "#{prefix_name}_#{sample_name}_mem*" end
Public Instance Methods
fetch_filename()
click to toggle source
# File lib/cagnut_bwa/functions/mem.rb, line 18 def fetch_filename filename = File.basename(@input) if filename.match '_R1_' filename.gsub '_R1_', '_R2_' elsif filename.match '_1_' filename.gsub '_1_', '_2_' end end
generate_script()
click to toggle source
# File lib/cagnut_bwa/functions/mem.rb, line 53 def generate_script script_name = "#{@order}_bwa_mem" file = File.join jobs_dir, "#{script_name}.sh" template = Tilt.new(File.expand_path '../templates/mem.sh', __FILE__) File.open(file, 'w') do |f| f.puts template.render Object.new, job_params(script_name) end File.chmod(0700, file) script_name end
job_params(script_name)
click to toggle source
# File lib/cagnut_bwa/functions/mem.rb, line 64 def job_params script_name { jobs_dir: jobs_dir, script_name: script_name, output: @output, mem_params: mem_options, run_local: ::Cagnut::JobManage.run_local } end
mem_options()
click to toggle source
# File lib/cagnut_bwa/functions/mem.rb, line 41 def mem_options array = mem_params.dup array.insert 1, 'mem' array << "-M" array << "-R \"#{rg_str}\"" array << "#{ref_fasta}" array << "#{@input}" array << "#{@input2}" array << "> #{@output}" array.uniq end
queuing_options(previous_job_id = nil)
click to toggle source
# File lib/cagnut_bwa/functions/mem.rb, line 34 def queuing_options previous_job_id = nil { previous_job_id: previous_job_id, tools: ['bwa', 'mem'] } end
run(previous_job_id = nil)
click to toggle source
# File lib/cagnut_bwa/functions/mem.rb, line 27 def run previous_job_id = nil puts "Submitting bwaMem #{sample_name}" script_name = generate_script ::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id) [@job_name, @output] end