nugen_barcode_splitter 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require "rubygems"
3
2
  require "yaml"
4
3
  require "optparse"
4
+ require "nugen_barcode_splitter"
5
+ require "fileutils"
5
6
 
6
7
  usage =<<EOF
7
8
  #{$0} [options] -p project_dir -o out_dir -c sample_sheet_nugen
@@ -112,21 +113,21 @@ sample_sheet.create_barcode_txt("#{options[:out_dir]}/barcode")
112
113
  multx_opts = "#{options[:keep_barcode]} #{options[:eol_only]} #{options[:bol_only]} #{options[:mismatches]}"
113
114
  nugen_temp = NugenTemplate.new(options[:fastq_multx],multx_opts)
114
115
 
115
- Dir.glob(options[:project_dir]).each do |p|
116
+ Dir.glob(options[:project_dir]+"/*").each do |p|
116
117
  next unless File.directory? p
117
118
  next unless p =~ /Sample_Lane/
118
119
  outdir = ""
119
-
120
- Dir.glob(p).each do |fwd|
121
- next if File.directory fwd
120
+ lane = ""
121
+ Dir.glob(p+"/*").each do |fwd|
122
+ next if File.directory? fwd
122
123
  next unless fwd =~ /Lane[1-8]_NoIndex_L[0-9]{3}_R1_[0-9]{3}.fastq.gz/
123
124
  rev = fwd.gsub(/_R1_/, "_R2_")
124
125
  tmp = fwd.split("/")
125
126
  tmp = tmp[-1].split("_")
126
- lane = tmp[0].qsub(/\D/,"")
127
- number = tmp[4].qsub(/\D/,"")
127
+ lane = tmp[0].gsub(/\D/,"")
128
+ number = tmp[4].gsub(/\D/,"")
128
129
  barcodes = "#{options[:out_dir]}/barcode_#{lane}.txt"
129
- outdir = options[:outdir] + "/Lane#{lane}"
130
+ outdir = options[:out_dir] + "Lane#{lane}"
130
131
  begin
131
132
  FileUtils.mkdir_p outdir unless File.directory? outdir
132
133
  rescue Exception => e
@@ -134,7 +135,7 @@ Dir.glob(options[:project_dir]).each do |p|
134
135
  end
135
136
  cmd = nugen_temp.fill(lane,number,outdir, barcodes, fwd, rev)
136
137
  if options[:debug]
137
- puts cmd if options[:debug]
138
+ STDERR.puts cmd if options[:debug]
138
139
  else
139
140
  status = system(cmd)
140
141
  raise "Calling the template did not succeed!" if !status
@@ -142,14 +143,21 @@ Dir.glob(options[:project_dir]).each do |p|
142
143
  end
143
144
 
144
145
  # Add the trimmed bases
145
- Dir.glob(outdir).each do |fwd|
146
+ Dir.glob(outdir+"/*").each do |fwd|
147
+ if fwd =~ /nugen_demultiplexing.log/
148
+ sample_sheet.lanes
149
+ statistics = Statistics.new(fwd, )
150
+ end
146
151
  next unless fwd =~ /R1_[0-9]{3}./
147
- cmd = `base_adder #{fwd} 4 #{fwd}_added`
152
+ cmd = "base_adder #{fwd} 4 #{fwd}_added"
148
153
  if options[:debug]
149
- puts cmd if options[:debug]
154
+ STDERR.puts cmd if options[:debug]
150
155
  else
151
156
  status = system(cmd)
152
157
  raise "Calling the template did not succeed!" if !status
158
+ cmd = "mv #{fwd}_added #{fwd}"
159
+ status = system(cmd)
160
+ raise "Was not ablde to rename file #{fwd}!" if status!=true
153
161
  end
154
162
  end
155
163
 
@@ -14,7 +14,8 @@ class NugenTemplate
14
14
 
15
15
  #{fastq_multx} #{options} -B <%= @barcodes %> \\
16
16
  <(gunzip -c <%= @fwd %>) <(gunzip -c <%= @rev %>) \\
17
- -o <%= @lane_dir %>/<%= @r1 %>.%.fq <%= @lane_dir %>/<%= @r2 %>.%.fq
17
+ -o <%= @lane_dir %>/<%= @r1 %>.%.fq <%= @lane_dir %>/<%= @r2 %>.%.fq \\
18
+ >> <%= @lane_dir %>/nugen_demultiplexing.log
18
19
  EOF
19
20
  end
20
21
 
@@ -21,7 +21,7 @@ class SampleSheet
21
21
  end
22
22
  end
23
23
 
24
- attr_accessor :lanes, :sample_id, :barcodes
24
+ attr_accessor :lanes, :sample_id, :barcodes, :barcode_lengths
25
25
 
26
26
  def create_barcode_txt(prefix)
27
27
  current_lane = "dummy"
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: