R/app.R

source("R/parameters.R")

setClass(
    "App",
    slots = list(
      parameters = "Parameters",
      dir = "character",
      manifest = "list",
      type = "character",
      input = "list",
      output = "list")
)

setMethod("show", "App",
          function(object){
              cat(stringr::str_interp("FASTGenomics ${object@type} app located in ${object@dir}\n"))
              cat("Parameters:\n\n")
              show(object@parameters)
          })

#' Create an app representation based on the contents of the manifest located under the
#' given path.
#'
#' @param dir The directory under which manifest.json is located
App <- function(dir){
    dir = normalizePath(dir)
    manifest_path <- file.path(dir, "manifest.json")
    assertthat::is.readable(manifest_path)

    ## deleted due to the problems with jsonvalidate as a dependency (needs V8)

    ## validate_manifest(manifest_path)

    manifest <- jsonlite::read_json(manifest_path)

    application <- manifest$application
    parameters = Parameters(application$parameters)
    new("App",
        manifest = manifest,
        parameters = parameters,
        dir = dir,
        type = application$type,
        input = application$input,
        output = application$output)
}
FASTGenomics/fastgenomicsR documentation built on June 26, 2019, 12:38 p.m.