class CagnutGatk::PrintReads

Public Class Methods

new(opts = {}) click to toggle source
# 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

Public Instance Methods

cluster_options(previous_job_id = nil) click to toggle source
# File lib/cagnut_gatk/functions/print_reads.rb, line 38
def cluster_options previous_job_id = nil
  {
    previous_job_id: previous_job_id,
    adjust_memory: ['h_vmem=6G'],
    tools: ['gatk', 'print_reads']
  }
end
file_basename() click to toggle source
# File lib/cagnut_gatk/functions/print_reads.rb, line 17
def file_basename
  @basename ||= File.basename @input
end
generate_script() click to toggle source
# 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.expand_path '../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) click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/cagnut_gatk/functions/print_reads.rb, line 74
def params_combination
  {
    'java' => modified_java_array,
    'params' => print_reads_options
  }
end
print_reads_options() click to toggle source
replace_filename(target) click to toggle source
# 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) click to toggle source
# 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, cluster_options(previous_job_id)
  [@job_name, @output]
end