Class: Experiment
- Inherits:
-
Object
- Object
- Experiment
- Defined in:
- lib/experiment.rb
Instance Method Summary collapse
- #dirname(a) ⇒ Object
- #expand_with_updates(opts, updates_are_full_alignments = true) ⇒ Object
-
#initialize(name, basedir) ⇒ Experiment
constructor
A new instance of Experiment.
- #last_bunch_dir ⇒ Object
- #setup_dirs ⇒ Object
Constructor Details
#initialize(name, basedir) ⇒ Experiment
Returns a new instance of Experiment.
7 8 9 10 |
# File 'lib/experiment.rb', line 7 def initialize(name, basedir) @name = name @base_dir = basedir end |
Instance Method Details
#dirname(a) ⇒ Object
11 12 13 |
# File 'lib/experiment.rb', line 11 def dirname(a) File.join @base_dir, 'experiments', @name, a end |
#expand_with_updates(opts, updates_are_full_alignments = true) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/experiment.rb', line 30 def (opts, updates_are_full_alignments = true) ali = self.dirname("alignment") phy = opts[:phylip] raise "phylip file not available" if phy.nil? or not File.exist?(phy) FileUtils.copy phy, ali p = Phylip.new(File.join ali, File.basename(phy)) p.subdivide_random opts end |
#last_bunch_dir ⇒ Object
14 15 16 17 |
# File 'lib/experiment.rb', line 14 def last_bunch_dir dirs = Dir.entries(dirname("output")).select{|f| f =~ /^bunch/} dirs.sort_by{|s| s.split("_").last.to_i}.last end |
#setup_dirs ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/experiment.rb', line 18 def setup_dirs setup_ready = true %w(alignment output).map{|n| self.dirname n}.each do |dir| if File.exist?(dir) puts "Exists #{dir}" setup_ready = false # to avoid overwrite else FileUtils.mkdir_p dir end end setup_ready end |