Class: CagnutBwa::Mem
- Inherits:
-
Object
- Object
- CagnutBwa::Mem
- Extended by:
- Forwardable
- Defined in:
- lib/cagnut_bwa/functions/mem.rb
Instance Method Summary collapse
- #fetch_filename ⇒ Object
- #generate_script ⇒ Object
-
#initialize(opts = {}) ⇒ Mem
constructor
A new instance of Mem.
- #job_params(script_name) ⇒ Object
- #mem_options ⇒ Object
- #queuing_options(previous_job_id = nil) ⇒ Object
- #run(previous_job_id = nil) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Mem
Returns a new instance of Mem.
9 10 11 12 13 14 15 16 |
# 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. 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 |
Instance Method Details
#fetch_filename ⇒ Object
18 19 20 21 22 23 24 25 |
# 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 ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# 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. '../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) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# 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: , run_local: ::Cagnut::JobManage.run_local } end |
#mem_options ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cagnut_bwa/functions/mem.rb', line 41 def 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) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/cagnut_bwa/functions/mem.rb', line 34 def previous_job_id = nil { previous_job_id: previous_job_id, tools: ['bwa', 'mem'] } end |
#run(previous_job_id = nil) ⇒ Object
27 28 29 30 31 32 |
# 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, (previous_job_id) [@job_name, @output] end |