Class: CagnutSamtools::MergeBam
- Inherits:
-
Object
- Object
- CagnutSamtools::MergeBam
- Extended by:
- Forwardable
- Defined in:
- lib/cagnut_samtools/functions/merge_bam.rb
Instance Method Summary collapse
- #generate_script ⇒ Object
-
#initialize(opts = {}) ⇒ MergeBam
constructor
A new instance of MergeBam.
- #job_params(script_name) ⇒ Object
- #queuing_options(previous_job_id = nil) ⇒ Object
- #run(previous_job_id = nil) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ MergeBam
Returns a new instance of MergeBam.
9 10 11 12 13 14 15 16 17 |
# File 'lib/cagnut_samtools/functions/merge_bam.rb', line 9 def initialize opts = {} @order = sprintf '%02i', opts[:order] @sam_dir = opts[:dirs][:input] @bam_dir = opts[:dirs][:output] @job_name = "#{prefix_name}_mgBam_#{sample_name}" @input = opts[:input].nil? ? "#{@bam_dir}/*.bam" : opts[:input] @output = "#{@bam_dir}/#{sample_name}_merged.bam" @output_bai = "#{@bam_dir}/#{sample_name}_merged.bai" end |
Instance Method Details
#generate_script ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cagnut_samtools/functions/merge_bam.rb', line 34 def generate_script script_name = "#{@order}_samtools_merge_bam" file = File.join jobs_dir, "#{script_name}.sh" path = File. '../templates/merge_bam.sh', __FILE__ template = Tilt.new path 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
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cagnut_samtools/functions/merge_bam.rb', line 46 def job_params script_name { bam_dir: @bam_dir, samtools_path: samtools_path, magic28: magic28, jobs_dir: jobs_dir, input: @input, output: @output, output_bai: @output_bai, sam_dir: @sam_dir, script_name: script_name, run_local: ::Cagnut::JobManage.run_local } end |
#queuing_options(previous_job_id = nil) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/cagnut_samtools/functions/merge_bam.rb', line 26 def previous_job_id = nil { previous_job_id: previous_job_id, adjust_memory: ['h_vmem=1G'], tools: ['samtools', 'merge_bam'] } end |
#run(previous_job_id = nil) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/cagnut_samtools/functions/merge_bam.rb', line 19 def run previous_job_id = nil puts "Submitting samtoolsMergeBam #{sample_name}" script_name = generate_script ::Cagnut::JobManage.submit script_name, @job_name, (previous_job_id) [@job_name, @output] end |