Skip to content
Snippets Groups Projects
Commit c03e821d authored by Todor Kondić's avatar Todor Kondić
Browse files

api, resources, tests, ... : Add MetFrag related arguments to `app'.

* DESCRIPTION: New version and doc engine.

* NAMESPACE: Adapted.

* man: Updated.
parent e70a3875
No related branches found
No related tags found
No related merge requests found
Package: shinyscreen
Title: Pre-screening of Mass Spectrometry Data
Version: 1.2.9000
Version: 1.2.9001
Author: Todor Kondić
Maintainer: Todor Kondić <todor.kondic@uni.lu>
Authors@R:
......@@ -41,7 +41,7 @@ Description: Pre-screening of Mass Spectrometry Data.
License: Apache License (>= 2.0)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
Collate:
'base.R'
......
......@@ -52,4 +52,3 @@ importFrom(MSnbase,readMSData)
importFrom(promises,"%...>%")
importFrom(promises,future_promise)
importFrom(shiny,validate)
importFrom(ggplot2,aes)
......@@ -673,41 +673,72 @@ create_plots <- function(m) {
m
}
prepare_app <- function(dir_before,
projects,
top_data_dir,
metfrag_db_dir,
metfrag_runtime) {
init <- list()
init$dir_before <- dir_before
init$top_data_dir <- norm_path(top_data_dir)
init$projects <- norm_path(projects)
init$metfrag_db_dir <- if (nchar(norm_path(metfrag_db_dir))>0L) norm_path(metfrag_db_dir) else ""
init$metfrag_runtime <- if (nchar(norm_path(metfrag_runtime))>0L) norm_path(metfrag_runtime) else ""
if (!dir.exists(init$top_data_dir)) stop(errorCondition(paste0("Data directory (top_data_dir), currently `",
init$top_data_dir,
"` does not exist. Abort."),
class = "top-data-dir-absent"))
if (!dir.exists(init$projects)) stop(errorCondition(paste0("User root directory (projects), currently `",
init$projects,"` does not exist.. Abort."),
class= "projects-absent"))
if (nchar(init$metfrag_db_dir)>0L && !dir.exists(init$metfrag_db_dir)) stop(errorCondition("MetFrag DB directory specified, but cannot be found.", class = "mf-db-dir-absent"))
if (nchar(init$metfrag_runtime)>0L && !file.exists(init$metfrag_runtime)) stop(errorCondition("MetFrag jar file specified, but cannot be found.", class = "mf-jar-absent"))
dir_start <- tempfile("shinyscreen")
dir.create(dir_start, recursive = T)
dir.create(file.path(dir_start,'www'), showWarnings=F)
saveRDS(object = init,file=file.path(dir_start,"init.rds"))
file.copy(system.file(file.path("rmd","app.Rmd"),package = "shinyscreen"),file.path(dir_start,"app_run.Rmd"))
file.copy(system.file(file.path("www","custom.css"),package = "shinyscreen"),file.path(dir_start,"www","custom.css"))
dir_start
}
#' @export
#' @title app
#' @param shiny_args `list`, optional list of arguments conveyed to
#' `rmarkdown::run` `shiny_args` argument.
#' @param render_args `list`, optional list of arguments conveyed to
#' `rmarkdown::run` `render_args` argument.
#' @param projects `character(1)`, a location on the server side
#' containing project directories.
#' @param top_data_dir `character(1)`, a location on the server side
#' containing data directories.
#' @param metfrag_db_dir `character(1)`, a location on the server side
#' containing MetFrag databases.
#' @param projects `character(1)`, a location on the server side
#' containing project directories.
#' @param metfrag_runtime `character(1)`, a location on the server side
#' of the MetFrag jar file.
#' @param shiny_args `list`, optional list of arguments conveyed to
#' `rmarkdown::run` `shiny_args` argument.
#' @param render_args `list`, optional list of arguments conveyed to
#' `rmarkdown::run` `render_args` argument.
#' @return Nada.
#' @author Todor Kondić
app <- function(shiny_args=list(launch.browser=F),render_args=NULL,top_data_dir=getwd(),projects=getwd(),metfrag_db_dir="") {
dir_before <- getwd()
init <- list()
init$dir_before <- dir_before
init$top_data_dir <- norm_path(top_data_dir)
init$metfrag_db_dir <- metfrag_db_dir
init$projects <- norm_path(projects)
if (!dir.exists(init$top_data_dir)) stop("Data directory (top_data_dir), currently `",
init$top_data_dir,
"` does not exist. Abort.")
if (!dir.exists(init$projects)) stop("User root directory (projects), currently `",
init$projects,"` does not exist.. Abort.")
app <- function(projects=getwd(),
top_data_dir=getwd(),
metfrag_db_dir="",
metfrag_runtime="",
shiny_args=list(launch.browser=F),
render_args=NULL) {
dir_before = getwd()
message("dir_before: ", dir_before)
message("top_data_dir: ", top_data_dir)
message("projects: ", projects)
dir_start = prepare_app(dir_before=dir_before,
projects=projects,
top_data_dir=top_data_dir,
metfrag_db_dir=metfrag_db_dir,
metfrag_runtime=metfrag_runtime)
on.exit(expr=setwd(dir_before))
dir_start <- tempfile("shinyscreen")
dir.create(dir_start, recursive = T)
setwd(dir_start)
dir.create('www', showWarnings=F)
saveRDS(object = init,file="init.rds")
file.copy(system.file(file.path("rmd","app.Rmd"),package = "shinyscreen"),"app_run.Rmd")
file.copy(system.file(file.path("www","custom.css"),package = "shinyscreen"),file.path("www","custom.css"))
rmarkdown::run(file = "app_run.Rmd", shiny_args = shiny_args, render_args = render_args)
}
......
......@@ -323,4 +323,11 @@ METFRAG_PREPFLT_CHOICES = c("UnconnectedCompoundFilter","IsotopeFilter")
METFRAG_PREPFLT_DEFAULT = c("UnconnectedCompoundFilter","IsotopeFilter")
METFRAG_POSTPFLT_CHOICES = c("InChIKeyFilter")
METFRAG_POSTPFLT_DEFAULT = c("InChIKeyFilter")
METFRAG_STANDARD_SCORES = "FragmenterScore,OfflineIndividualMoNAScore" # AutomatedPeakFingerprintAnnotationScore,
# AutomatedLossFingerprintAnnotationScore
# supposedly
# do
# not
# work
# well.
METFRAG_STANDARD_WEIGHTS = "1,1"
......@@ -5,23 +5,32 @@
\title{app}
\usage{
app(
projects = getwd(),
top_data_dir = getwd(),
metfrag_db_dir = "",
metfrag_runtime = "",
shiny_args = list(launch.browser = F),
render_args = NULL,
indir = getwd(),
userdir = getwd()
render_args = NULL
)
}
\arguments{
\item{projects}{\code{character(1)}, a location on the server side
containing project directories.}
\item{top_data_dir}{\code{character(1)}, a location on the server side
containing data directories.}
\item{metfrag_db_dir}{\code{character(1)}, a location on the server side
containing MetFrag databases.}
\item{metfrag_runtime}{\code{character(1)}, a location on the server side
of the MetFrag jar file.}
\item{shiny_args}{\code{list}, optional list of arguments conveyed to
\code{rmarkdown::run} \code{shiny_args} argument.}
\item{render_args}{\code{list}, optional list of arguments conveyed to
\code{rmarkdown::run} \code{render_args} argument.}
\item{indir}{\code{character(1)}, a location on the server side
containing data directories.}
\item{userdir}{\code{character(1)}, a location on the server side containing project directories.}
}
\value{
Nada.
......
......@@ -4,16 +4,16 @@
\alias{serve}
\title{serve}
\usage{
serve(indir, topuserdir, user, host = "0.0.0.0", port = 7777)
serve(top_data_dir, usersdir, user, host = "0.0.0.0", port = 7777)
}
\arguments{
\item{indir}{\code{character(1)}, a location on the server side
\item{top_data_dir}{\code{character(1)}, a location on the server side
containing data directories.}
\item{topuserdir}{\code{character(1)}, a location on the server side
\item{usersdir}{\code{character(1)}, a location on the server side
containing individual user directories.}
\item{user}{\code{character(1)}, subdir of topuserdir.}
\item{user}{\code{character(1)}, subdir of usersdir.}
\item{host}{\code{character(1)}, optional, address where the page is
served.}
......
test_that("Preparation for app start",{
dbef = "bef"
dir.create("bef")
ddata = "topdata"
dir.create(ddata)
dproj = "proj"
dir.create(dproj)
ddbdir = "dbdir"
dir.create(ddbdir)
mrt = "mrt.fake.jar"
saveRDS("",file=mrt)
expect_error(prepare_app(dir_before=dbef,
projects=dproj,
top_data_dir=ddata,
metfrag_db_dir=ddbdir,
metfrag_runtime="absent.jar"),
class="mf-jar-absent")
expect_error(prepare_app(dir_before=dbef,
projects="absent",
top_data_dir=ddata,
metfrag_db_dir=ddbdir,
metfrag_runtime=mrt),
class="projects-absent")
expect_error(prepare_app(dir_before=dbef,
projects=dproj,
top_data_dir="absent",
metfrag_db_dir=ddbdir,
metfrag_runtime=mrt),
class="top-data-dir-absent")
expect_error(prepare_app(dir_before=dbef,
projects=dproj,
top_data_dir=ddata,
metfrag_db_dir="absent",
metfrag_runtime=mrt),
class="mf-db-dir-absent")
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment