Class: CagnutGatk::IndelRealigner
- Inherits:
-
Object
- Object
- CagnutGatk::IndelRealigner
- Extended by:
- Forwardable
- Defined in:
- lib/cagnut_gatk/functions/indel_realigner.rb
Instance Method Summary collapse
- #cluster_options(previous_job_id = nil) ⇒ Object
- #generate_script ⇒ Object
- #indel_realigner_options ⇒ Object
-
#initialize(opts = {}) ⇒ IndelRealigner
constructor
A new instance of IndelRealigner.
- #modified_java_array ⇒ Object
- #params_combination ⇒ Object
- #run(previous_job_id = nil) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ IndelRealigner
Returns a new instance of IndelRealigner.
10 11 12 13 14 15 16 |
# File 'lib/cagnut_gatk/functions/indel_realigner.rb', line 10 def initialize opts = {} @order = sprintf '%02i', opts[:order] @job_name = "#{prefix_name}_indelRealigner_#{sample_name}" @interval_list = opts[:interval_list] @input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_markdup.bam" : opts[:input] @output = "#{opts[:dirs][:output]}/#{sample_name}_realn.bam" end |
Instance Method Details
#cluster_options(previous_job_id = nil) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/cagnut_gatk/functions/indel_realigner.rb', line 25 def previous_job_id = nil { previous_job_id: previous_job_id, adjust_memory: ['h_vmem=8G'], tools: ['gatk', 'indel_realigner'] } end |
#generate_script ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/cagnut_gatk/functions/indel_realigner.rb', line 57 def generate_script script_name = "#{@order}_gatk_indel_realigner" file = File.join jobs_dir, "#{script_name}.sh" File.open(file, 'w') do |f| f.puts <<-BASH.strip_heredoc #!/bin/bash cd "#{jobs_dir}/../" echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs" # Check for intervals file if [ ! -s "#{@interval_list}" ];then echo "Error: Missing interval file: "#{@interval_list}" from realignTargetCreator_#{sample_name}" exit 100 fi #{params_combination['java'].join("\s")} \\ #{params_combination['params'].join(" \\\n ")} \\ #{::Cagnut::JobManage.run_local} EXITSTATUS=$? #force error when missing @output if [ ! -s "#{@output}" ] then echo "Missing @output BAM #{@output}" exit 100 fi # Check BAM EOF BAM_28=$(tail -c 28 #{@output}|xxd -p) if [ "#{magic28}" != "$BAM_28" ] then echo "Error with BAM EOF" 1>&2 exit 100 fi echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs" exit $EXITSTATUS BASH end File.chmod(0700, file) script_name end |
#indel_realigner_options ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cagnut_gatk/functions/indel_realigner.rb', line 33 def array = indel_realigner_params['params'].dup array << "-T IndelRealigner" array << "-R #{ref_fasta}" array << "-targetIntervals #{@interval_list}" array << "-I #{@input}" array << "-o #{@output}" array << "-known #{dbsnp_ref_indels}" if dbsnp_ref_indels array.uniq! array.uniq end |
#modified_java_array ⇒ Object
45 46 47 48 |
# File 'lib/cagnut_gatk/functions/indel_realigner.rb', line 45 def modified_java_array array = indel_realigner_params['java'].dup array.unshift(java_path).uniq end |
#params_combination ⇒ Object
50 51 52 53 54 55 |
# File 'lib/cagnut_gatk/functions/indel_realigner.rb', line 50 def params_combination @params_combination_hash ||= { 'java' => modified_java_array, 'params' => } end |
#run(previous_job_id = nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/cagnut_gatk/functions/indel_realigner.rb', line 18 def run previous_job_id = nil puts "Submitting indel_realigner #{sample_name}" script_name = generate_script ::Cagnut::JobManage.submit script_name, @job_name, (previous_job_id) [@job_name, @output] end |