Class: Raxml

Inherits:
Object
  • Object
show all
Defined in:
lib/rraxml.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Raxml

Returns a new instance of Raxml.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rraxml.rb', line 14

def initialize(opts)
  raise "No alignment in #{opts[:phylip]}" if opts[:phylip].nil? or not File.exist?(opts[:phylip])
  @phylip = opts[:phylip]
  @name = opts[:name] || "RUN_NAME"
  @seed = opts[:seed] || "12345"
  @outdir = opts[:outdir] || "test/outdir/#{@name}"
  @stderr = opts[:stderr] || File.join(@outdir, 'stderr')
  @stdout = opts[:stdout] || File.join(@outdir, 'stdout')
  @binary = ""
  @flags = opts[:flags] || ""
  @ops = "-s #{@phylip} -n #{@name} #{@flags}"
end

Instance Attribute Details

#binaryObject (readonly)

Returns the value of attribute binary.



13
14
15
# File 'lib/rraxml.rb', line 13

def binary
  @binary
end

#infofileObject (readonly)

Returns the value of attribute infofile.



13
14
15
# File 'lib/rraxml.rb', line 13

def infofile
  @infofile
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/rraxml.rb', line 13

def name
  @name
end

#opsObject (readonly)

Returns the value of attribute ops.



13
14
15
# File 'lib/rraxml.rb', line 13

def ops
  @ops
end

#outdirObject (readonly)

Returns the value of attribute outdir.



13
14
15
# File 'lib/rraxml.rb', line 13

def outdir
  @outdir
end

#phylipObject (readonly)

Returns the value of attribute phylip.



13
14
15
# File 'lib/rraxml.rb', line 13

def phylip
  @phylip
end

#stderrObject (readonly)

Returns the value of attribute stderr.



13
14
15
# File 'lib/rraxml.rb', line 13

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



13
14
15
# File 'lib/rraxml.rb', line 13

def stdout
  @stdout
end

Instance Method Details

#after_runObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/rraxml.rb', line 30

def after_run
  @infofile = File.join Dir.pwd, "RAxML_info.#{@name}" 
  @outfiles = [@stdout, @stderr, @infofile]
  self.gather_outfiles
  @outfiles.each do |f| 
    unless f.nil? or not File.exist?(f)
      FileUtils.move(f, @outdir) unless File.join(@outdir, File.basename(f)) == f
    end
  end
end

#before_runObject



26
27
28
29
# File 'lib/rraxml.rb', line 26

def before_run
  FileUtils.mkdir_p @outdir unless File.exist?(@outdir) 
  self.complete_call
end

#runObject



40
41
42
43
44
45
46
# File 'lib/rraxml.rb', line 40

def run
  self.before_run
  raise "#{@binary} not found" unless binary_available(@binary)
  puts "#{@binary} #{@ops} "
  system "(#{@binary} #{@ops} 2> #{@stderr}) > #{@stdout}"
  self.after_run
end

#saluteObject



47
48
49
# File 'lib/rraxml.rb', line 47

def salute
  puts "This is a RAxML instance"
end