Class: CagnutGatk::PrintReads
- Inherits:
-
Object
- Object
- CagnutGatk::PrintReads
- Extended by:
- Forwardable
- Defined in:
- lib/cagnut_gatk/functions/print_reads.rb
Instance Method Summary collapse
- #cluster_options(previous_job_id = nil) ⇒ Object
- #file_basename ⇒ Object
- #generate_script ⇒ Object
-
#initialize(opts = {}) ⇒ PrintReads
constructor
A new instance of PrintReads.
- #job_params(script_name) ⇒ Object
- #modified_java_array ⇒ Object
- #output_file ⇒ Object
- #params_combination ⇒ Object
- #print_reads_options ⇒ Object
- #replace_filename(target) ⇒ Object
- #run(previous_job_id = nil) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ PrintReads
Returns a new instance of PrintReads.
9 10 11 12 13 14 15 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 9 def initialize opts = {} @order = sprintf '%02i', opts[:order] @job_name = "#{prefix_name}_PrintReads_#{sample_name}" @input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_realn.bam" : opts[:input] @output = "#{opts[:dirs][:output]}/#{output_file}" @bqsr_file = "#{opts[:dirs][:contrast]}/#{replace_filename('_recal.csv')}" end |
Instance Method Details
#cluster_options(previous_job_id = nil) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 38 def previous_job_id = nil { previous_job_id: previous_job_id, adjust_memory: ['h_vmem=6G'], tools: ['gatk', 'print_reads'] } end |
#file_basename ⇒ Object
17 18 19 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 17 def file_basename @basename ||= File.basename @input end |
#generate_script ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 46 def generate_script script_name = "#{@order}_gatk_print_reads" file = File.join jobs_dir, "#{script_name}.sh" path = File. '../templates/print_reads.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
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 81 def job_params script_name { script_name: script_name, jobs_dir: jobs_dir, output: @output, bqsr_file: @bqsr_file, print_reads_params: params_combination, run_local: ::Cagnut::JobManage.run_local, } end |
#modified_java_array ⇒ Object
69 70 71 72 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 69 def modified_java_array array = print_reads_params['java'].dup array.unshift(java_path).uniq end |
#output_file ⇒ Object
25 26 27 28 29 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 25 def output_file output = replace_filename '_recal.bam' return output unless output == file_basename abort 'Input file is not correctly' end |
#params_combination ⇒ Object
74 75 76 77 78 79 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 74 def params_combination { 'java' => modified_java_array, 'params' => } end |
#print_reads_options ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 58 def ary = print_reads_params['params'].dup ary << "-T PrintReads" ary << "-R #{ref_fasta}" ary << "-I #{@input}" ary << "-o #{@output}" ary << "-BQSR #{@bqsr_file}" ary << "-L #{target_flanks_file}" if target_flanks_file ary.uniq end |
#replace_filename(target) ⇒ Object
21 22 23 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 21 def replace_filename target file_basename.gsub '_realn.bam', target end |
#run(previous_job_id = nil) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/cagnut_gatk/functions/print_reads.rb', line 31 def run previous_job_id = nil puts "Submitting PrintReads #{sample_name}" script_name = generate_script ::Cagnut::JobManage.submit script_name, @job_name, (previous_job_id) [@job_name, @output] end |