From 37c181c7d7f521fed243bbc0121d3f13ce563389 Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Thu, 19 Dec 2013 13:07:30 +0000 Subject: [PATCH 01/14] fixes to loading config file and a few other little things --- .gitignore | 2 ++ Gemfile.lock | 4 +-- assemblotron.gemspec | 2 +- lib/assemblotron.rb | 4 ++- .../assemblers/soap_denovo_trans.rb | 28 +++++++++++++++---- .../assemblers/soap_denovo_trans.yml | 2 +- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index ec5e31a..b38f55a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ spec/reports test/tmp test/version_tmp tmp +*~ +*fastq # YARD artifacts .yardoc diff --git a/Gemfile.lock b/Gemfile.lock index 0d3c00d..7af27b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,7 +4,7 @@ PATH assemblotron (0.0.1) biopsy (= 0.1.6.alpha) rake (~> 10.1.0) - transrate (= 0.0.9) + transrate (= 0.0.11) trollop (~> 2.0) GEM @@ -83,7 +83,7 @@ GEM thor (0.18.1) threach (0.2.0) tins (0.9.0) - transrate (0.0.9) + transrate (0.0.11) bettersam (~> 0.0.1.alpha) bio rake (~> 10.1.0) diff --git a/assemblotron.gemspec b/assemblotron.gemspec index 7ac14d1..f488768 100644 --- a/assemblotron.gemspec +++ b/assemblotron.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |gem| gem.add_dependency 'rake', '~> 10.1.0' gem.add_dependency 'biopsy', '0.1.6.alpha' gem.add_dependency 'trollop', '~> 2.0' - gem.add_dependency 'transrate', '0.0.9' + gem.add_dependency 'transrate', '0.0.11' gem.add_development_dependency 'turn' gem.add_development_dependency 'simplecov' diff --git a/lib/assemblotron.rb b/lib/assemblotron.rb index 2dd76f3..91a264a 100644 --- a/lib/assemblotron.rb +++ b/lib/assemblotron.rb @@ -151,9 +151,11 @@ def self.class_from_type type def run assembler @assembler_opts[:reference] = Transrate::Assembly.new(@assembler_opts[:reference]) + @assembler_opts[:left] = File.expand_path(@assembler_opts[:left]) + @assembler_opts[:right] = File.expand_path(@assembler_opts[:right]) a = self.get_assembler assembler e = Biopsy::Experiment.new a, @assembler_opts - res = e.run + @res = e.run end # run end # Controller diff --git a/lib/assemblotron/assemblers/soap_denovo_trans.rb b/lib/assemblotron/assemblers/soap_denovo_trans.rb index 634a7fa..2291b4b 100644 --- a/lib/assemblotron/assemblers/soap_denovo_trans.rb +++ b/lib/assemblotron/assemblers/soap_denovo_trans.rb @@ -13,16 +13,32 @@ def initialize def run params # run the assembly + self.setup_soap params self.run_soap params # retrieve output scaffolds = Dir['*.scafSeq'] - return nil if scaffolds.empty? - puts scaffolds + return nil if scaffolds.empty? + # puts scaffolds scaffolds = scaffolds.first # return a Transrater Transrate::Transrater.new(scaffolds, params[:reference], params[:left], params[:right]) end + # soapdt.config file only generated on first run + def setup_soap params + # make config file + File.open("soapdt.config", "w") do |conf| + conf.puts "max_rd_len=20000" + conf.puts "[LIB]" + conf.puts "avg_ins=#{params[:insertsize]}" + conf.puts "reverse_seq=0" + conf.puts "asm_flags=3" + conf.puts "rank=2" + conf.puts "q1=#{params[:left]}" + conf.puts "q2=#{params[:right]}" + end + end + def include_defaults params defaults = { :K => 23, @@ -36,16 +52,16 @@ def include_defaults params :t => 5, :G => 50 } - defaults.merge params + defaults.merge(params) { |key, v1, v2| v2 } end def construct_command(params) params = self.include_defaults params cmd = "#{@path} all" # generic - cmd += " -s #{params[:config]}" # config file + cmd += " -s soapdt.config" # config file cmd += " -a #{params[:memory]}" if params.has_key? :memory # memory assumption - cmd += " -o #{params[:out]}" if params.has_key? :out # output directory + cmd += " -o #{params[:out]}" if params.has_key? :out # output prefix cmd += " -p #{params[:threads]}" # number of threads # specific cmd += " -K #{params[:K]}" # kmer size @@ -61,7 +77,7 @@ def construct_command(params) # runs SOAPdt script def run_soap(params) cmd = self.construct_command(params) - puts cmd + # puts cmd `#{cmd} > #{@count}.log` end diff --git a/lib/assemblotron/assemblers/soap_denovo_trans.yml b/lib/assemblotron/assemblers/soap_denovo_trans.yml index ddf1e5c..726f427 100644 --- a/lib/assemblotron/assemblers/soap_denovo_trans.yml +++ b/lib/assemblotron/assemblers/soap_denovo_trans.yml @@ -16,7 +16,7 @@ parameters: right: type: string opt: false - desc: 'Path to left reads (for assembly quality analysis)' + desc: 'Path to right reads (for assembly quality analysis)' insertsize: type: integer opt: false From 95e2d61bc774b04bcbafc7fc70ad92ef36de2d1d Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Tue, 22 Apr 2014 12:51:14 +0100 Subject: [PATCH 02/14] fixed soap denovo test --- .../assemblers/soap_denovo_trans.rb | 28 ++++--------------- test/test_soap_denovo_trans.rb | 6 ++-- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/lib/assemblotron/assemblers/soap_denovo_trans.rb b/lib/assemblotron/assemblers/soap_denovo_trans.rb index 6883e46..ef93437 100644 --- a/lib/assemblotron/assemblers/soap_denovo_trans.rb +++ b/lib/assemblotron/assemblers/soap_denovo_trans.rb @@ -8,12 +8,11 @@ def initialize @count = 0 @path = which('SOAPdenovo-Trans-127mer') raise "SOAPdenovo-Trans-127mer was not in the PATH" if @path.empty? - @path = @path.first + @path = File.basename(@path.first) end def run params # run the assembly - self.setup_soap params self.run_soap params # retrieve output scaffolds = Dir['*.scafSeq'] @@ -25,26 +24,12 @@ def run params Transrate::ComparativeMetrics.new(assembly, params[:reference]) end - # soapdt.config file only generated on first run - def setup_soap params - # make config file - File.open("soapdt.config", "w") do |conf| - conf.puts "max_rd_len=20000" - conf.puts "[LIB]" - conf.puts "avg_ins=#{params[:insertsize]}" - conf.puts "reverse_seq=0" - conf.puts "asm_flags=3" - conf.puts "rank=2" - conf.puts "q1=#{params[:left]}" - conf.puts "q2=#{params[:right]}" - end - end - def include_defaults params defaults = { :K => 23, :threads => 8, :out => 'sdt', + :config => 'soapdt.config', :d => 0, :e => 2, :M => 1, @@ -53,6 +38,7 @@ def include_defaults params :t => 5, :G => 50 } + # params argument takes precedence over defaults in merge defaults.merge(params) { |key, v1, v2| v2 } end @@ -60,9 +46,9 @@ def construct_command(params) params = self.include_defaults params cmd = "#{@path} all" # generic - cmd += " -s soapdt.config" # config file + cmd += " -s #{params[:config]}" # config file cmd += " -a #{params[:memory]}" if params.has_key? :memory # memory assumption - cmd += " -o #{params[:out]}" if params.has_key? :out # output prefix + cmd += " -o #{params[:out]}" if params.has_key? :out # output directory cmd += " -p #{params[:threads]}" # number of threads # specific cmd += " -K #{params[:K]}" # kmer size @@ -78,10 +64,6 @@ def construct_command(params) # runs SOAPdt script def run_soap(params) cmd = self.construct_command(params) -<<<<<<< HEAD - # puts cmd -======= ->>>>>>> 94df5a6a0ea9a66d408007776166531628eab69d `#{cmd} > #{@count}.log` end diff --git a/test/test_soap_denovo_trans.rb b/test/test_soap_denovo_trans.rb index 4c727dc..88c6ede 100644 --- a/test/test_soap_denovo_trans.rb +++ b/test/test_soap_denovo_trans.rb @@ -15,7 +15,7 @@ class TestSoapDenovoTrans < Test::Unit::TestCase :insertsize => '200', :l => 'l.fq', :r => 'r.fq', - :path => 'SOAPdenovo-Trans', + :path => 'SOAPdenovo-Trans-127mer', :memory => 12, :threads => 8, :out => 1, @@ -34,14 +34,14 @@ class TestSoapDenovoTrans < Test::Unit::TestCase :t => 6 } @params.merge! params - expected = "SOAPdenovo-Trans all -s soapdt.config" + expected = "SOAPdenovo-Trans-127mer all -s soapdt.config" expected += " -a 12 -o 1 -p 8 -K 1 -d 2 -F -M 9 -L 200" expected += " -e 6 -t 6 -G 50" assert_equal expected, @s.construct_command(@params) end should "automatically include defaults" do - expected = "SOAPdenovo-Trans all -s soapdt.config" + expected = "SOAPdenovo-Trans-127mer all -s soapdt.config" expected += " -a 12 -o 1 -p 8 -K 23 -d 0 -F -M 1" expected += " -L 100 -e 2 -t 5 -G 50" assert_equal expected, @s.construct_command(@params) From 2e14db0c6b293c97fef219c0a11548a4fb70b321 Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Fri, 25 Apr 2014 12:55:47 +0100 Subject: [PATCH 03/14] optimiser and verbosity option --- bin/atron | 5 ++++- lib/assemblotron.rb | 34 +++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/bin/atron b/bin/atron index 7fb1daf..e01e509 100755 --- a/bin/atron +++ b/bin/atron @@ -35,10 +35,13 @@ EOS opt :gzip_intermediates, "gzip intermediate files (onlys takes effect if --keep-intermediates is on)" opt :skip_subsample, "skip subsampling step" opt :skip_final, "skip final assembly step" + opt :optimiser, "Which optimiser to use. Possible: 'tabu' or 'sweeper' (default:'tabu')", :type => String, + :default => "tabu" opt :logfile, "write logs to file", :type => String opt :output_parameters, "file to which optimal parameters will be written", :default => "optimal_parameters.json" opt :quiet, "Don't print any logs" - opt :verbose, "Print extra information" + opt :verbosity, "How much extra information is printed [silent|quiet|loud]", + :type => String, :default => "silent" opt :visualise, "Produce visualisations of the run" stop_on SUB_COMMANDS end diff --git a/lib/assemblotron.rb b/lib/assemblotron.rb index 91470d8..3aa8837 100644 --- a/lib/assemblotron.rb +++ b/lib/assemblotron.rb @@ -111,7 +111,7 @@ def list_assemblers def options_for_assembler assembler a = self.get_assembler assembler parser = Trollop::Parser.new do - banner <<-EOS + banner <<-EOS #{Controller.header} Options for assembler #{assembler} @@ -133,8 +133,7 @@ def options_for_assembler assembler def get_assembler assembler ret = @assemblers.find do |a| - a.name == assembler || - a.shortname == assembler + a.name == assembler || a.shortname == assembler end raise "couldn't find assembler #{assembler}" if ret.nil? ret @@ -185,14 +184,30 @@ def run assembler end # load reference and create ublast DB - @assembler_opts[:reference] = Transrate::Assembly.new(@assembler_opts[:reference]) - - ra = Transrate::ReciprocalAnnotation.new(@assembler_opts[:reference], @assembler_opts[:reference]) + @assembler_opts[:reference] = + Transrate::Assembly.new(@assembler_opts[:reference]) + ra = Transrate::ReciprocalAnnotation.new(@assembler_opts[:reference], + @assembler_opts[:reference]) ra.make_reference_db # run the assemblotron a = self.get_assembler assembler - e = Biopsy::Experiment.new a, @assembler_opts, @global_opts[:threads] + start = nil + algorithm = nil + if @global_opts[:optimiser] == 'tabu' + algorithm = Biopsy::TabuSearch.new(a.parameters) + elsif @global_opts[:optimiser] == 'sweeper' + algorithm = Biopsy::ParameterSweeper.new(a.parameters) + else + raise NotImplementedError, "please select either tabu or\ + sweeper as the optimiser" + end + + e = Biopsy::Experiment.new(a, @assembler_opts, + @global_opts[:threads], + start, + algorithm, + @global_opts[:verbosity].to_sym) res = e.run # write out the result @@ -201,10 +216,7 @@ def run assembler end # run the final assembly - unless @global_opts[:skip_final] - final_assembly a, res - end - + final_assembly a, res unless @global_opts[:skip_final] end # run end # Controller From f4af09514c9381ba47b43ed7301a1f728bfa0b1c Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Fri, 25 Apr 2014 14:29:19 +0100 Subject: [PATCH 04/14] enable writing when creating config file --- lib/assemblotron/assemblers/soap_denovo_trans.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/assemblotron/assemblers/soap_denovo_trans.rb b/lib/assemblotron/assemblers/soap_denovo_trans.rb index 1942558..01697e2 100644 --- a/lib/assemblotron/assemblers/soap_denovo_trans.rb +++ b/lib/assemblotron/assemblers/soap_denovo_trans.rb @@ -98,7 +98,7 @@ def setup_full(global_opts, assembler_opts) def create_config left, right, assembler_opts # create the config file filename = "#{Time.now}.full.config" - File.open(filename) do |f| + File.open(filename,'w') do |f| f << 'max_rd_len=5000' f << '[LIB]' f << "avg_ins=#{assembler_opts[:insertsize]}" From 517347c293838f26d11e29123632999d9d7d9b21 Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Fri, 25 Apr 2014 14:31:56 +0100 Subject: [PATCH 05/14] changed spaces to underscores in the config file filename --- lib/assemblotron/assemblers/soap_denovo_trans.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/assemblotron/assemblers/soap_denovo_trans.rb b/lib/assemblotron/assemblers/soap_denovo_trans.rb index 01697e2..2c88d52 100644 --- a/lib/assemblotron/assemblers/soap_denovo_trans.rb +++ b/lib/assemblotron/assemblers/soap_denovo_trans.rb @@ -97,7 +97,7 @@ def setup_full(global_opts, assembler_opts) # @return [String] full path to the generated config gile def create_config left, right, assembler_opts # create the config file - filename = "#{Time.now}.full.config" + filename = "#{Time.now}.full.config".tr(" ","_") File.open(filename,'w') do |f| f << 'max_rd_len=5000' f << '[LIB]' From 8ce456bca6851817a1be0b6096b11748f09f118e Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Fri, 25 Apr 2014 14:59:19 +0100 Subject: [PATCH 06/14] bump --- 2014-04-25_14:31:11_+0100.full.config | 1 + Gemfile.lock | 15 ++++++++++----- assemblotron.gemspec | 4 ++-- bin/atron | 10 +++++----- lib/assemblotron.rb | 2 ++ lib/assemblotron/assemblers/soap_denovo_trans.yml | 5 ----- 6 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 2014-04-25_14:31:11_+0100.full.config diff --git a/2014-04-25_14:31:11_+0100.full.config b/2014-04-25_14:31:11_+0100.full.config new file mode 100644 index 0000000..71df0b0 --- /dev/null +++ b/2014-04-25_14:31:11_+0100.full.config @@ -0,0 +1 @@ +max_rd_len=5000[LIB]avg_ins=reverse_seq=0asm_flags=3q1=/home/chris/documents/subset.Cd.keep.1q2=/home/chris/documents/subset.Cd.keep.2 \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 952c075..410c04b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,8 +3,8 @@ PATH specs: assemblotron (0.0.2) RubyInline (~> 3.12) - biopsy (= 0.1.8) - rake (~> 10.1) + biopsy (= 0.1.9) + rake (~> 10.3) transrate (= 0.0.12) trollop (~> 2.0) @@ -15,10 +15,15 @@ GEM ZenTest (~> 4.3) ZenTest (4.9.5) ansi (1.4.3) - bettersam (0.0.1.alpha) + bettersam (0.0.2) + coveralls + rake + shoulda-context + simplecov + turn bio (1.4.3.0001) - biopsy (0.1.8) - rake (~> 10.3) + biopsy (0.1.9) + rake (~> 10.1) rubystats statsample threach diff --git a/assemblotron.gemspec b/assemblotron.gemspec index 0dabe94..2b057ea 100644 --- a/assemblotron.gemspec +++ b/assemblotron.gemspec @@ -13,8 +13,8 @@ Gem::Specification.new do |gem| gem.files = Dir['Rakefile', '{lib,test}/**/*', 'README*', 'LICENSE*'] gem.require_paths = %w[ lib ] - gem.add_dependency 'rake', '~> 10.1' - gem.add_dependency 'biopsy', '0.1.8' + gem.add_dependency 'rake', '~> 10.3' + gem.add_dependency 'biopsy', '0.1.9' gem.add_dependency 'trollop', '~> 2.0' gem.add_dependency 'transrate', '0.0.12' gem.add_dependency 'RubyInline', '~> 3.12' diff --git a/bin/atron b/bin/atron index b0c8f93..fecf2d4 100755 --- a/bin/atron +++ b/bin/atron @@ -61,17 +61,17 @@ if cmd.nil? elsif cmd == "list" puts controller.list_assemblers exit -elsif cmd == "run" - assembler = ARGV.shift +# elsif cmd == "run" +# assembler = ARGV.shift elsif controller.assemblers.include?(cmd) assembler = cmd assembler_parser = controller.parser_for_assembler cmd - assembler_opts = Trollop::with_standard_exception_handling parser do + assembler_opts = Trollop::with_standard_exception_handling assembler_parser do raise Trollop::HelpNeeded if ARGV.empty? # show help screen - parser.parse ARGV + assembler_parser.parse ARGV end else - Trollop::die "unknown subcommand #{cmd.inspect}" + abort "unknown subcommand #{cmd.inspect}" end # run command diff --git a/lib/assemblotron.rb b/lib/assemblotron.rb index bd8d3f8..1bbb096 100644 --- a/lib/assemblotron.rb +++ b/lib/assemblotron.rb @@ -246,6 +246,8 @@ def run assembler if @global_opts[:optimiser] == 'tabu' algorithm = Biopsy::TabuSearch.new(a.parameters) elsif @global_opts[:optimiser] == 'sweeper' + p a.parameters + exit algorithm = Biopsy::ParameterSweeper.new(a.parameters) else raise NotImplementedError, "please select either tabu or\ diff --git a/lib/assemblotron/assemblers/soap_denovo_trans.yml b/lib/assemblotron/assemblers/soap_denovo_trans.yml index 6d6598e..407623b 100644 --- a/lib/assemblotron/assemblers/soap_denovo_trans.yml +++ b/lib/assemblotron/assemblers/soap_denovo_trans.yml @@ -3,11 +3,6 @@ name: SoapDenovoTrans shortname: sdt output: {} parameters: - config: - type: string - opt: false - desc: 'Path to SoapDenovoTrans config file' - required: true left: type: string opt: false From 0bdcc42c65c69bab6e84d206443aa062eb242436 Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Fri, 25 Apr 2014 16:19:41 +0100 Subject: [PATCH 07/14] removed colons from config filename --- lib/assemblotron.rb | 1 - lib/assemblotron/assemblers/soap_denovo_trans.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/assemblotron.rb b/lib/assemblotron.rb index 8fdd512..4740c15 100644 --- a/lib/assemblotron.rb +++ b/lib/assemblotron.rb @@ -248,7 +248,6 @@ def run assembler algorithm = Biopsy::TabuSearch.new(a.parameters) elsif @global_opts[:optimiser] == 'sweeper' p a.parameters - exit algorithm = Biopsy::ParameterSweeper.new(a.parameters) else raise NotImplementedError, "please select either tabu or\ diff --git a/lib/assemblotron/assemblers/soap_denovo_trans.rb b/lib/assemblotron/assemblers/soap_denovo_trans.rb index 70ec548..7403169 100644 --- a/lib/assemblotron/assemblers/soap_denovo_trans.rb +++ b/lib/assemblotron/assemblers/soap_denovo_trans.rb @@ -98,7 +98,7 @@ def setup_full(global_opts, assembler_opts) # @return [String] full path to the generated config gile def create_config left, right, assembler_opts # create the config file - filename = "#{Time.now}.full.config".tr(" ","_") + filename = "#{Time.now}.full.config".tr(" ","_").tr(":",".") File.open(filename, 'w') do |f| f.puts 'max_rd_len=5000' f.puts '[LIB]' From aa7875d89459b2d4ae5f2b7c0b1ef5fd6403aba6 Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Tue, 29 Apr 2014 17:00:07 +0100 Subject: [PATCH 08/14] gemfile.lock changed again --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e792742..b47f66b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,9 +3,9 @@ PATH specs: assemblotron (0.0.2) RubyInline (~> 3.12) - biopsy (= 0.1.9) + biopsy (= 0.2.0) rake (~> 10.3) - transrate (= 0.0.12) + transrate (= 0.0.14) trollop (~> 2.0) GEM From 6d14d2348584e192691e838442cfac9547b186c6 Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Tue, 29 Apr 2014 17:05:29 +0100 Subject: [PATCH 09/14] actually doing stuff with the optimiser global option --- lib/assemblotron.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/assemblotron.rb b/lib/assemblotron.rb index c326783..6f06e93 100644 --- a/lib/assemblotron.rb +++ b/lib/assemblotron.rb @@ -256,10 +256,24 @@ def run assembler # run the optimisation a.setup_optim(@global_opts, @assembler_opts) + start = nil + algorithm = nil + if @global_opts[:optimiser] == 'tabu' + algorithm = Biopsy::TabuSearch.new(a.parameters) + elsif @global_opts[:optimiser] == 'sweeper' + algorithm = Biopsy::ParameterSweeper.new(a.parameters) + elsif @global_opts[:optimiser].nil? + # this is fine + else + raise NotImplementedError, "please select either tabu or "+ + "sweeper as the optimiser" + end e = Biopsy::Experiment.new(a, options: @assembler_opts, threads: @global_opts[:threads], - verbosity: :loud) + start: start, + algorithm: algorithm, + verbosity: @global_opts[:verbosity].to_sym) res = e.run # write out the result From 944d9ede51483a90864f38a9d44243e506790edc Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Wed, 30 Apr 2014 12:01:22 +0100 Subject: [PATCH 10/14] fixed file path bug --- lib/assemblotron/assemblers/soap_denovo_trans.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/assemblotron/assemblers/soap_denovo_trans.rb b/lib/assemblotron/assemblers/soap_denovo_trans.rb index 7403169..ea9c648 100644 --- a/lib/assemblotron/assemblers/soap_denovo_trans.rb +++ b/lib/assemblotron/assemblers/soap_denovo_trans.rb @@ -55,8 +55,8 @@ def run params def setup_optim(global_opts, assembler_opts) # setup config file for subsetted reads puts 'peforming setup for SoapDenovotrans optimisation' - left = assembler_opts[:left_subset] - right = assembler_opts[:right_subset] + left = File.expand_path(assembler_opts[:left_subset]) + right = File.expand_path(assembler_opts[:right_subset]) f = create_config(left, right, assembler_opts) assembler_opts[:config] = f end @@ -80,8 +80,8 @@ def setup_optim(global_opts, assembler_opts) # @return undefined def setup_full(global_opts, assembler_opts) # set config file for full read set - left = assembler_opts[:left] - right = assembler_opts[:right] + left = File.expand_path(assembler_opts[:left]) + right = File.expand_path(assembler_opts[:right]) f = create_config(left, right, assembler_opts) assembler_opts[:config] = f end @@ -167,7 +167,7 @@ def construct_command params cmd += " -e #{params[:e]}" # delete contigs with coverage no greater than cmd += " -t #{params[:t]}" # maximum number of transcripts from one locus cmd += " -G #{params[:G]}" # allowed length difference between estimated and filled gap - puts cmd + # puts cmd cmd end From f38aaab30ada9c07ff3f678f6c44930246f52b37 Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Thu, 29 May 2014 16:08:30 +0100 Subject: [PATCH 11/14] ignore config files --- .gitignore | 1 + 2014-04-25_14:31:11_+0100.full.config | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 2014-04-25_14:31:11_+0100.full.config diff --git a/.gitignore b/.gitignore index ebb2906..ca53aae 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ test/version_tmp tmp *~ *fastq +*config # YARD artifacts .yardoc diff --git a/2014-04-25_14:31:11_+0100.full.config b/2014-04-25_14:31:11_+0100.full.config deleted file mode 100644 index 71df0b0..0000000 --- a/2014-04-25_14:31:11_+0100.full.config +++ /dev/null @@ -1 +0,0 @@ -max_rd_len=5000[LIB]avg_ins=reverse_seq=0asm_flags=3q1=/home/chris/documents/subset.Cd.keep.1q2=/home/chris/documents/subset.Cd.keep.2 \ No newline at end of file From 602121e9dcbcbb022028f88d85a81835051814ba Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Thu, 29 May 2014 16:10:45 +0100 Subject: [PATCH 12/14] added option to only do assembly and no scoring --- bin/atron | 4 +++- lib/assemblotron.rb | 15 ++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bin/atron b/bin/atron index feb6e3c..ceb70aa 100755 --- a/bin/atron +++ b/bin/atron @@ -50,9 +50,11 @@ EOS opt :subsample_size, "number of reads to use for optimisation", :default => 100_000 opt :optimiser, - "Which optimiser to use. Possible: 'tabu' or 'sweeper' (default:'tabu')", + "Which optimiser to use. Possible: 'tabu' or 'sweeper'", :type => String, :default => "tabu" + opt :only_assemble, + "If using parameter sweeper don't do any scoring, just run the assembler" opt :logfile, "write logs to file", :type => String opt :output_parameters, "file to which optimal parameters will be written", diff --git a/lib/assemblotron.rb b/lib/assemblotron.rb index 6f06e93..92d07c0 100644 --- a/lib/assemblotron.rb +++ b/lib/assemblotron.rb @@ -228,11 +228,13 @@ def final_assembly assembler, result def run assembler res = nil # load reference and create ublast DB - @assembler_opts[:reference] = - Transrate::Assembly.new(@assembler_opts[:reference]) - ra = Transrate::ReciprocalAnnotation.new(@assembler_opts[:reference], - @assembler_opts[:reference]) - ra.make_reference_db + if !@global_opts[:only_assemble] + @assembler_opts[:reference] = + Transrate::Assembly.new(@assembler_opts[:reference]) + ra = Transrate::ReciprocalAnnotation.new(@assembler_opts[:reference], + @assembler_opts[:reference]) + ra.make_reference_db + end # setup the assembler a = self.get_assembler assembler @@ -258,10 +260,13 @@ def run assembler a.setup_optim(@global_opts, @assembler_opts) start = nil algorithm = nil + + @settings.objectives_subset = ['assembly_score'] if @global_opts[:optimiser] == 'tabu' algorithm = Biopsy::TabuSearch.new(a.parameters) elsif @global_opts[:optimiser] == 'sweeper' algorithm = Biopsy::ParameterSweeper.new(a.parameters) + @settings.objectives_subset = ['no_score'] if @global_opts[:only_assemble] elsif @global_opts[:optimiser].nil? # this is fine else From 082f7ce123c0ba991feb8ea3e937b21b832d9e37 Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Thu, 29 May 2014 16:11:36 +0100 Subject: [PATCH 13/14] the biopsy settings object now gets passed global options from atron --- lib/assemblotron.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/assemblotron.rb b/lib/assemblotron.rb index 92d07c0..96c1692 100644 --- a/lib/assemblotron.rb +++ b/lib/assemblotron.rb @@ -25,7 +25,7 @@ module Assemblotron # @return [Hash] the assembler-specific options class Controller - attr_accessor :global_opts + attr_reader :global_opts attr_accessor :assembler_opts # Creates a new Controller @@ -53,14 +53,20 @@ def self.header # setting target and objectiv directories to those # provided with Assemblotron def init_settings - s = Biopsy::Settings.instance - s.set_defaults + @settings = Biopsy::Settings.instance + @settings.set_defaults libdir = File.dirname(__FILE__) - s.target_dir = [File.join(libdir, 'assemblotron/assemblers/')] - s.objectives_dir = [File.join(libdir, 'assemblotron/objectives/')] + @settings.target_dir = [File.join(libdir, 'assemblotron/assemblers/')] + @settings.objectives_dir = [File.join(libdir, 'assemblotron/objectives/')] @log.debug "initialised Biopsy settings" end # init_settings + def global_opts=(options) + @global_opts = options + @settings.keep_intermediates = true if @global_opts[:keep_intermediates] + @settings.gzip_intermediates = true if @global_opts[:gzip_intermediates] + end + # Load global configuration from the config file at # +~/.assemblotron+, if it exists. def load_config @@ -87,7 +93,7 @@ def load_config # one +.yml+ definition and one +.rb+ constructor per # assembler (see AssemblerDefinition). def load_assemblers - Biopsy::Settings.instance.target_dir.each do |dir| + @settings.target_dir.each do |dir| Dir.chdir dir do Dir['*.yml'].each do |file| name = File.basename(file, '.yml') From 9749562ed9825bc074206ccda429a31ce10a0ae7 Mon Sep 17 00:00:00 2001 From: Chris Boursnell Date: Thu, 29 May 2014 16:12:50 +0100 Subject: [PATCH 14/14] objective that doesn't do anything and returns a score of 0 --- lib/assemblotron/objectives/no_score.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/assemblotron/objectives/no_score.rb diff --git a/lib/assemblotron/objectives/no_score.rb b/lib/assemblotron/objectives/no_score.rb new file mode 100644 index 0000000..e6db862 --- /dev/null +++ b/lib/assemblotron/objectives/no_score.rb @@ -0,0 +1,12 @@ +# An objective function that returns 0 +# +# This class conforms to the API for a Biopsy::ObjectiveFunction. +class NoScore < Biopsy::ObjectiveFunction + + # Don't do anything just return 0. + # + # @return [Integer] 0, + def run (raw_output, output_files, threads) + return 0 + end +end