From 9e0a4763be8a860645069d922048b26720171b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Todor=20Kondi=C4=87?= <todor.kondic@uni.lu> Date: Mon, 27 Apr 2020 07:41:19 +0200 Subject: [PATCH] Add R/api.R DESCRIPTION: New dependencies. NAMESPACE: New imports. R/api.R (read_conf,vrfy_conf): New functions. --- DESCRIPTION | 3 +++ NAMESPACE | 1 + R/api.R | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 R/api.R diff --git a/DESCRIPTION b/DESCRIPTION index 9b8b892..00207dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -49,6 +49,7 @@ Collate: 'mix.R' 'extraction.R' 'run.R' + 'api.R' 'shinyUI.R' Depends: RMassBank, @@ -60,6 +61,8 @@ Imports: yaml, mzR, MSnbase, + data.table, + assertthat, ggplot2, cowplot, RColorBrewer, diff --git a/NAMESPACE b/NAMESPACE index 3dff728..ef97b55 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,3 +1,4 @@ # Generated by roxygen2: do not edit by hand export(launch) +export(read_conf) diff --git a/R/api.R b/R/api.R new file mode 100644 index 0000000..f05a1bb --- /dev/null +++ b/R/api.R @@ -0,0 +1,27 @@ +## Copyright (C) 2020 by University of Luxembourg + +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at + +## http://www.apache.org/licenses/LICENSE-2.0 + +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. + + + + +read_conf <- function(fn_conf) { + conf <- yaml::yaml.load_file(fn_conf) + conf <- vrfy_conf(conf) + conf +} + +vrfy_conf <- function(conf) { + for (fn in unlist(conf,recursive=T)) assertthat::assert_that(file.exists(fn),msg=paste("Data file does not exist:",fn)) + return(conf) +} -- GitLab