nugen_barcode_splitter 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ require "nugen_barcode_splitter"
5
5
  require "fileutils"
6
6
 
7
7
  usage =<<EOF
8
- V E R S I O N - 0 . 0 . 16 - BETA
8
+ V E R S I O N - 0 . 0 . 17 - BETA
9
9
  #{$0} [options] -p project_dir -o out_dir -c sample_sheet_nugen
10
10
  _____________________________________________________________________________
11
11
 
@@ -34,7 +34,8 @@ options = {
34
34
  :mismatches => "",
35
35
  :keep_barcode => "",
36
36
  :fastq_multx => "fastq_multx",
37
- :debug => false
37
+ :debug => false,
38
+ :lane_number => ""
38
39
  }
39
40
 
40
41
  optparse = OptionParser.new do |opts|
@@ -74,6 +75,10 @@ optparse = OptionParser.new do |opts|
74
75
  options[:mismatches] = "-m #{i}" if i
75
76
  end
76
77
 
78
+ opts.on("-n","--laneNumber NUM", String, "Specific lane number (Default:all lanes)") do |i|
79
+ options[:lane_number] = i if i
80
+ end
81
+
77
82
  opts.on("-x", "--fastq_multx DIR", String) do |i|
78
83
  options[:fastq_multx] = i if i
79
84
  end
@@ -114,10 +119,9 @@ sample_sheet.create_barcode_txt("#{options[:out_dir]}/barcode")
114
119
  multx_opts = "#{options[:keep_barcode]} #{options[:eol_only]} #{options[:bol_only]} #{options[:mismatches]}"
115
120
  nugen_temp = NugenTemplate.new(options[:fastq_multx],multx_opts)
116
121
 
117
-
118
122
  Dir.glob(options[:project_dir]+"/*").each do |p|
119
123
  next unless File.directory? p
120
- next unless p =~ /Sample_Lane/
124
+ next unless p =~ /Sample_Lane#{options[:lane_number]}/
121
125
  outdir = ""
122
126
  lane = ""
123
127
  Dir.glob(p+"/*").each do |fwd|
@@ -78,7 +78,7 @@ class Merger
78
78
  if !fwd_splitted_files[i].eof?
79
79
  compare_line_fwd = fwd_splitted_files[i].readline()
80
80
  name_compare_fwd = compare_line_fwd.split(" ")
81
- if fwd_line[0] == name_compare_fwd[0] && marker
81
+ if fwd_name[0] == name_compare_fwd[0] && marker
82
82
  marker = false
83
83
  statistics[i] += 1
84
84
  fwd_out_files[i].write(fwd_line)
@@ -86,9 +86,9 @@ class Merger
86
86
  for k in 1..3
87
87
  fwd_file.readline()
88
88
  compare_line_fwd = fwd_splitted_files[i].readline()
89
- fwd_out_files[i].write("NNNN"+compare_line_fwd) if k == 1
89
+ fwd_out_files[i].write(compare_line_fwd.gsub(/^[A-Z]{4}/,"NNNN")) if k == 1
90
90
  fwd_out_files[i].write(compare_line_fwd) if k == 2
91
- fwd_out_files[i].write("@@@@"+compare_line_fwd) if k == 3
91
+ fwd_out_files[i].write(compare_line_fwd.gsub(/^[\S]{4}/,"@@@@")) if k == 3
92
92
  rev_out_files[i].write(rev_file.readline())
93
93
  end
94
94
  fwd_file.lineno = fwd_file.lineno - 1
@@ -123,9 +123,9 @@ class Merger
123
123
  for k in 1..3
124
124
  rev_file.readline()
125
125
  compare_line_rev = rev_splitted_files[i].readline()
126
- rev_out_files[i].write("NNNN"+compare_line_rev) if k == 1
126
+ rev_out_files[i].write(compare_line_rev.gsub(/[A-Z]{4}$/,"NNNN")) if k == 1
127
127
  rev_out_files[i].write(compare_line_rev) if k == 2
128
- rev_out_files[i].write("@@@@"+compare_line_rev) if k == 3
128
+ rev_out_files[i].write(compare_line_rev.gsub(/[\S]{4}$/,"@@@@")) if k == 3
129
129
  fwd_out_files[i].write(fwd_file.readline())
130
130
  end
131
131
  fwd_file.lineno = fwd_file.lineno - 1
@@ -3,25 +3,27 @@ require "erubis"
3
3
  class NugenTemplate
4
4
 
5
5
  def initialize(fastq_multx, options)
6
- # @template =<<EOF
7
- #gunzip -c <%= @read %> | #{fastq_multx} \\
8
- # --bcfile <%= @barcodes %> #{options} <%= @options %> \\
9
- # --prefix <%= @lane_dir %>/<%= @direction %> \\
10
- # --suffix ".fq"
11
- #EOF
12
6
  @template =<<EOF
13
- #{fastq_multx} #{options} <%= @barcodes %> \\
14
- <(gunzip -c <%= @read %>) \\
15
- -o <%= @lane_dir %>/<%= @direction %>.%.fq \\
16
- >> <%= @lane_dir %>/nugen_demultiplexing_fastq_multx.log
7
+ gunzip -c <%= @read %> | #{fastq_multx} \\
8
+ --bcfile <%= @barcodes %> #{options} <%= @options %> \\
9
+ --prefix <%= @lane_dir %>/<%= @direction %> \\
10
+ --suffix ".fq"
17
11
  EOF
12
+ # @template =<<EOF
13
+ ##{fastq_multx} #{options} <%= @barcodes %> \\
14
+ # <(gunzip -c <%= @read %>) \\
15
+ # -o <%= @lane_dir %>/<%= @direction %>.%.fq \\
16
+ # >> <%= @lane_dir %>/nugen_demultiplexing_fastq_multx.log
17
+ #EOF
18
18
  end
19
19
 
20
20
  def fill(lane, number, lane_dir, barcodes, read, is_fwd)
21
21
  if is_fwd
22
- direction = "R1_#{number}"
22
+ direction = "R1_#{number}."
23
+ options = "--bol"
23
24
  else
24
- direction = "R2_#{number}"
25
+ direction = "R2_#{number}."
26
+ options = "--eol"
25
27
  end
26
28
  context = {
27
29
  :lane => lane,
@@ -30,7 +32,7 @@ EOF
30
32
  :barcodes => barcodes,
31
33
  :read => read,
32
34
  :direction => direction,
33
- #:options => options
35
+ :options => options
34
36
  }
35
37
 
36
38
  eruby = Erubis::Eruby.new(@template)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nugen_barcode_splitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: