class Cagnut::Configuration::Checks::Tools

Attributes

check_completed[RW]
config[RW]
java[RW]

Public Class Methods

new(config) click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 7
def initialize config
  @config = config
end

Public Instance Methods

check() click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 11
def check
  @check_completed = true
  check_each_tool
  result = @check_completed ? 'Completed!' : 'Failed!'
  puts "Check Tools: #{result}"
  exit unless @check_completed
end
check_each_tool() click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 19
def check_each_tool
  tools = @config['tools']
  refs = @config['refs']
  puts 'Start Checking...'
  check_execute_system
  check_ref_fasta refs['ref_fasta']
  check_java tools['java']
  check_r tools['R']
  check_tool tools, refs
end
check_execute_system() click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 30
def check_execute_system
  puts "Using Local System"
end
check_java(path) click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 44
def check_java path
  failed = check_tool_ver 'Java' do
    `#{path} -version 2>&1| grep version | cut -f3 -d ' '` if path
  end
  @java = path unless failed
end
check_r(path) click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 51
def check_r path
  check_tool_ver 'R' do
    `#{path} --version 2>&1 |grep ' version '| cut -f3 -d ' '` if path
  end
  check_r_libs path if path
end
check_r_libs(r_path) click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 58
def check_r_libs r_path
  %w(gplots ggplot2 reshape gsalib).each do |lib|
    check_tool_ver "R library: #{lib}" do
      `#{r_path}script -e 'packageVersion("#{lib}")' | cut -f2 -d ' '`
    end
  end
end
check_ref_fasta(ref_path) click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 66
def check_ref_fasta ref_path
  puts 'Checking Reference Files...'
  return if File.exist?(ref_path)
  puts "\tReference not founded in #{ref_path}"
  @check_completed = false
end
check_tool(tools_path, refs=nil) click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 34
def check_tool tools_path, refs=nil
end
check_tool_ver(tool) { || ... } click to toggle source
# File lib/cagnut/configuration/checks/tools.rb, line 37
def check_tool_ver tool
  ver = yield if block_given?
  @check_completed = false if ver.blank?
  ver = ver.blank? ? 'Not Found' : ver.chomp!
  puts "Using #{tool} (#{ver})"
end