From 90fbe8b3ef3fa05aa308e6650e11d690bb89b200 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 24 Mar 2016 13:43:27 +0100 Subject: local R package installation --- ext/lazar/extconf.rb | 19 ++++++++++++++++--- ext/lazar/rinstall.R | 16 +++++++++------- lib/lazar.rb | 18 ++++++------------ 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/ext/lazar/extconf.rb b/ext/lazar/extconf.rb index a76f0f4..006e24c 100644 --- a/ext/lazar/extconf.rb +++ b/ext/lazar/extconf.rb @@ -1,8 +1,24 @@ require 'fileutils' require 'rbconfig' +require 'mkmf' main_dir = File.expand_path(File.join(File.dirname(__FILE__),"..","..")) +# check for required programs +programs = ["R","Rscript","mongod","java","getconf"] +programs.each do |program| + abort "Please install #{program} on your system." unless find_executable program +end + +abort "Please install Rserve on your system. Execute 'install.packages('Rserve')' in a R console running as root ('sudo R')." unless `R CMD Rserve --version`.match(/^Rserve/) + +# install R packages +r_dir = File.join main_dir, "R" +FileUtils.mkdir_p r_dir +FileUtils.mkdir_p File.join(main_dir,"bin") # for Rserve binary +rinstall = File.expand_path(File.join(File.dirname(__FILE__),"rinstall.R")) +puts `Rscript --vanilla #{rinstall} #{r_dir}` + # install OpenBabel openbabel_version = "2.3.2" @@ -48,7 +64,4 @@ Dir.chdir build_dir do ENV["PKG_CONFIG_PATH"] = File.dirname(File.expand_path(Dir["#{install_dir}/**/openbabel*pc"].first)) end -ob_include= File.expand_path File.join(File.dirname(__FILE__),"../../openbabel/include/openbabel-2.0") -ob_lib= File.expand_path File.join(File.dirname(__FILE__),"../../openbabel/lib") - $makefile_created = true diff --git a/ext/lazar/rinstall.R b/ext/lazar/rinstall.R index 7c1510d..38e7377 100644 --- a/ext/lazar/rinstall.R +++ b/ext/lazar/rinstall.R @@ -1,7 +1,9 @@ -chooseCRANmirror(ind=19); -install.packages("Rserve"); -install.packages("gridExtra"); -install.packages("ggplot2"); -install.packages("pls"); -install.packages("caret"); -install.packages("doMC"); +libdir = commandArgs(trailingOnly=TRUE)[1] +# chooseCRANmirror(ind=19); does not have any impact on selected server +#args=paste0("--prefix=",libdir,"/..") +#install.packages("Rserve",lib=libdir,configure.args=args) +install.packages("gridExtra",lib=libdir); +install.packages("ggplot2",lib=libdir); +install.packages("pls",lib=libdir); +install.packages("caret",lib=libdir); +install.packages("doMC",lib=libdir); diff --git a/lib/lazar.rb b/lib/lazar.rb index b4293e9..22dfd2b 100644 --- a/lib/lazar.rb +++ b/lib/lazar.rb @@ -40,17 +40,18 @@ when "development" end # R setup +rlib = File.expand_path(File.join(File.dirname(__FILE__),"..","R")) # should work on POSIX including os x # http://stackoverflow.com/questions/19619582/number-of-processors-cores-in-command-line NR_CORES = `getconf _NPROCESSORS_ONLN`.to_i R = Rserve::Connection.new R.eval " suppressPackageStartupMessages({ - library(ggplot2) - library(grid) - library(gridExtra) - library(caret) - library(doMC) + library(ggplot2,lib=\"#{rlib}\") + library(grid,lib=\"#{rlib}\") + library(gridExtra,lib=\"#{rlib}\") + library(caret,lib=\"#{rlib}\") + library(doMC,lib=\"#{rlib}\") registerDoMC(#{NR_CORES}) }) " @@ -58,13 +59,6 @@ suppressPackageStartupMessages({ # Require sub-Repositories require_relative '../openbabel/lib/openbabel' -# Fminer environment variables -ENV['FMINER_SMARTS'] = 'true' -ENV['FMINER_NO_AROMATIC'] = 'true' -ENV['FMINER_PVALUES'] = 'true' -ENV['FMINER_SILENT'] = 'true' -ENV['FMINER_NR_HITS'] = 'true' - # OpenTox classes and includes CLASSES = ["Feature","Compound","Dataset","Validation","CrossValidation","LeaveOneOutValidation","RepeatedCrossValidation","Experiment"]# Algorithm and Models are modules -- cgit v1.2.3