Module: ViralSeq::R

Defined in:
lib/viral_seq/R.rb

Class Method Summary collapse

Class Method Details

.check_RObject

check if R is installed. if R is installed, return the version number of R.



6
7
8
9
10
11
12
13
# File 'lib/viral_seq/R.rb', line 6

def self.check_R
  begin
    r_version = `R --version`.split("\n")[0]
  rescue Errno::ENOENT
    abort '"R" is not installed. Install R at https://www.r-project.org/' +
          "\n`tcs_sdrm` pipeline aborted."
  end
end

.check_R_packagesObject

check if required R packages is installed.



16
17
18
19
20
21
22
# File 'lib/viral_seq/R.rb', line 16

def self.check_R_packages
  if system "Rscript #{File.join( ViralSeq.root, "viral_seq", "util", "check_env.r")}"
    return 0
  else
    raise "Non-zero exit code. Error happens when checking required R packages."
  end
end

.get_sdrm_rscriptObject

read sdrm rscript as a string.



26
27
28
# File 'lib/viral_seq/R.rb', line 26

def self.get_sdrm_rscript
  File.read(File.join(ViralSeq.root, "viral_seq", "util", "sdrm_r.r"))
end