Class: CagnutBwa::AlnOneFastq
- Inherits:
-
Object
- Object
- CagnutBwa::AlnOneFastq
- Extended by:
- Forwardable
- Defined in:
- lib/cagnut_bwa/functions/aln_one_fastq.rb
Instance Method Summary collapse
- #aln_params_for_r1 ⇒ Object
- #aln_params_for_r2 ⇒ Object
- #fetch_filename(file) ⇒ Object
- #generate_script ⇒ Object
-
#initialize(opts = {}) ⇒ AlnOneFastq
constructor
A new instance of AlnOneFastq.
- #queuing_options(previous_job_id = nil) ⇒ Object
- #run(previous_job_id = nil) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ AlnOneFastq
Returns a new instance of AlnOneFastq.
9 10 11 12 13 14 15 16 17 |
# File 'lib/cagnut_bwa/functions/aln_one_fastq.rb', line 9 def initialize opts = {} @order = sprintf '%02i', opts[:order] @input = opts[:input].nil? ? "#{seqs_path}" : opts[:input] abort('Cant recognized sequence files') if @input.nil? @input2 = File. fetch_filename(@input), File.dirname(@input) if @input.match '_1_' @output = "#{opts[:dirs][:output]}/#{File.basename(@input).gsub('.gz', '').gsub('.txt','.sai')}" @output2 = "#{opts[:dirs][:output]}/#{fetch_filename(@output)}" if @input.match '_1_' @job_name = "#{prefix_name}_#{sample_name}_Aln_one_fastq" end |
Instance Method Details
#aln_params_for_r1 ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/cagnut_bwa/functions/aln_one_fastq.rb', line 46 def aln_params_for_r1 array = aln_params.dup array.insert 1, 'aln' array << "#{ref_fasta}" array << "-f #{@output}" array << "#{@input}" array.uniq end |
#aln_params_for_r2 ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/cagnut_bwa/functions/aln_one_fastq.rb', line 55 def aln_params_for_r2 array = aln_params.dup array.insert 1, 'aln' array << "#{ref_fasta}" array << "-f #{@output2}" array << "#{@input2}" array.uniq end |
#fetch_filename(file) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/cagnut_bwa/functions/aln_one_fastq.rb', line 19 def fetch_filename file filename = File.basename(file) if filename.match '_R1_' filename.gsub '_R1_', '_R2_' elsif filename.match '_1_' filename.gsub '_1_', '_2_' end end |
#generate_script ⇒ Object
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 |
# File 'lib/cagnut_bwa/functions/aln_one_fastq.rb', line 64 def generate_script script_name = "#{@order}_bwa_aln_one_fastq" file = File.join jobs_dir, "#{script_name}.sh" File.open(file, 'w') do |f| f.puts <<-BASH.strip_heredoc #!/bin/bash echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs" if [[ #{@input} =~ _1_ ]] then #{aln_params_for_r2.join(" \\\n ")} \\ #{::Cagnut::JobManage.run_local} else fi #{aln_params_for_r1.join(" \\\n ")} \\ #{::Cagnut::JobManage.run_local} if [ ! -s "#{@output}" ] then echo "Missing SAI:#{@output} file!" exit 100 fi echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs" BASH end File.chmod(0700, file) script_name end |
#queuing_options(previous_job_id = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cagnut_bwa/functions/aln_one_fastq.rb', line 35 def previous_job_id = nil threads = 2 { previous_job_id: previous_job_id, var_env: [fastq_dir, sai_dir, threads], adjust_memory: ['h_vmem=3.4G'], parallel_env: [threads], tools: ['bwa', 'aln'] } end |
#run(previous_job_id = nil) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/cagnut_bwa/functions/aln_one_fastq.rb', line 28 def run previous_job_id = nil puts "Submitting bwa_aln_one_fastq #{sample_name}" script_name = generate_script ::Cagnut::JobManage.submit script_name, @job_name, (previous_job_id) @job_name end |