Class: CagnutBwa::SampOneFastq
- Inherits:
-
Object
- Object
- CagnutBwa::SampOneFastq
- Extended by:
- Forwardable
- Defined in:
- lib/cagnut_bwa/functions/samp_one_fastq.rb
Instance Method Summary collapse
- #bwa_samp_one_fastq(script_name) ⇒ Object
- #fetch_filename(file) ⇒ Object
- #generate_script ⇒ Object
- #initizaline(opts = {}) ⇒ Object
- #job_params(script_name) ⇒ Object
- #queuing_options(previous_job_id = nil) ⇒ Object
- #run(previous_job_id = nil) ⇒ Object
- #samp_one_fastq_options ⇒ Object
- #samse_one_fastq_options ⇒ Object
Instance Method Details
#bwa_samp_one_fastq(script_name) ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/cagnut_bwa/functions/samp_one_fastq.rb', line 73 def bwa_samp_one_fastq script_name file = File.join jobs_dir, "#{@order}_#{script_name}.sh" path = File. "../templates/#{script_name}.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) end |
#fetch_filename(file) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/cagnut_bwa/functions/samp_one_fastq.rb', line 20 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
45 46 47 48 49 |
# File 'lib/cagnut_bwa/functions/samp_one_fastq.rb', line 45 def generate_script script_name = data_type == 'ONEFASTQ' ? 'bwa_samp_one_fastq' : 'bwa_samse_one_fastq' bwa_samp_one_fastq script_name script_name end |
#initizaline(opts = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cagnut_bwa/functions/samp_one_fastq.rb', line 9 def initizaline opts = {} @order = sprintf '%02i', opts[:order] @job_name = "#{prefix_name}_#{sample_name}_Samp" @seq = opts[:input].nil? ? "#{seqs_path}" : opts[:input] abort('Cant recognized sequence files') if @seq.nil? @sai = "#{opts[:dirs][:input]}/#{File.basename(@seq).gsub('.gz', '').gsub('.txt','.sai')}" @seq2 = @seq.match('_1_') ? "#{File.(fetch_filename(@seq), File.dirname(@seq))}" : '' @sai2 = @sai.match('_1_') ? "#{opts[:dirs][:input]}/#{fetch_filename(@sai)}" : '' @output = "#{opts[:dirs][:output]}/#{sample_name}_sequence.aligned.sam.gz" end |
#job_params(script_name) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cagnut_bwa/functions/samp_one_fastq.rb', line 83 def job_params script_name { jobs_dir: jobs_dir, script_name: script_name, output: @output, seq: @seq, seq2: @seq2, samp_options: (data_type == 'ONEFASTQ' ? 'samp_one_fastq_options' : 'samse_one_fastq_options'), run_local: ::Cagnut::JobManage.run_local } end |
#queuing_options(previous_job_id = nil) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/cagnut_bwa/functions/samp_one_fastq.rb', line 36 def previous_job_id = nil { previous_job_id: previous_job_id, adjust_memory: ['h_vmem=5G'], parallel_env: ['30'], tools: ['bwa', 'samp'] } end |
#run(previous_job_id = nil) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/cagnut_bwa/functions/samp_one_fastq.rb', line 29 def run previous_job_id = nil puts "Submitting bwaSampOneFastq #{sample_name} RG_STR= #{rg_str}" script_name = generate_script ::Cagnut::JobManage.submit script_name, @job_name, (previous_job_id) [@job_name, @output] end |
#samp_one_fastq_options ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cagnut_bwa/functions/samp_one_fastq.rb', line 51 def array = samp_params.dup array.insert 1, 'sampe' array << "-r \"#{rg_str}\"" array << "#{ref_fasta}" array << "#{@sai}" array << "#{@sai2}" array << "#{@seq}" array << "#{@seq2} | gzip > #{@output}" array.uniq.compact end |
#samse_one_fastq_options ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/cagnut_bwa/functions/samp_one_fastq.rb', line 63 def array = samp_params.dup array.insert 1, 'sampe' array << "-r \"#{rg_str}\"" array << "#{ref_fasta}" array << "#{@sai}" array << "#{@seq} | gzip > #{@output}" array.uniq.compact end |