Skip to content
Snippets Groups Projects
Commit 69244c57 authored by Steffen Neumann's avatar Steffen Neumann
Browse files

load packages required for validation, recursively discover files for validation

parent 6b889736
No related branches found
No related tags found
No related merge requests found
#' Validate a record against a set of RUnit tests
#'
#' Validates a plaintext-MassBankrecord. The Unit Tests to be used
#' Validates a plaintext-MassBankrecord, or recursively all records
#' below a directory. The Unit Tests to be used
#' are installed in RMassBank/
#'
#' @aliases validate
#' @usage validate(File)
#' @param File The filepath to the plaintext-records
#' @usage validate(path)
#' @param path The filepath to a single record, or a directory to search recursively
#' @examples
#' \dontrun{
#' validate("/tmp/MassBank/OpenData/record/")
#' }
#' @export
validate <- function(File){
validate <- function(path) {
if (!require(ontoCAT)) {
error("Package ontoCAT missing. Validation requires package ontoCAT and RUnit")
}
if (!require(RUnit)) {
error("Package RUnit missing. Validation requires package ontoCAT and RUnit")
}
# Is the argument a directory?
# If yes, list the files
RMassBank.env$Instrument_List <- .getInstruments()
RMassBank.env$testnumber <- 1
if(file.info(File[1])$isdir){
Files <- list.files(path = File, full.names = TRUE)
} else {Files <- File}
if(file.info(path[1])$isdir){
Files <- list.files(path = path,
recursive=TRUE,
full.names = TRUE)
} else {Files <- path}
# Parsing with the help the parseMassBank-function
RMassBank.env$mb <- lapply(Files,parseMassBank)
# Test RMassBank Objects with RUnit
......@@ -124,4 +140,4 @@ smiles2mass <- function(SMILES){
do.isotopes(massfromformula)
mass <- get.exact.mass(massfromformula)
return(mass)
}
\ No newline at end of file
}
......@@ -45,7 +45,7 @@ test.PrecursorType <- function(){
test.smilesvsexactmass <- function(){
Mass_Calculated_Through_Smiles <- smiles2mass(RMassBank.env$mb[[RMassBank.env$testnumber]]@compiled_ok[[1]][['CH$SMILES']])
Exact_Mass <- RMassBank.env$mb[[RMassBank.env$testnumber]]@compiled_ok[[1]][['CH$EXACT_MASS']]
checkEquals(Mass_Calculated_Through_Smiles, Exact_Mass, Exact_Mass/100)
checkEquals(Mass_Calculated_Through_Smiles, Exact_Mass, tolerance = Exact_Mass/100)
}
test.sumintensities <- function(){
......
......@@ -2,13 +2,20 @@
\alias{validate}
\title{Validate a record against a set of RUnit tests}
\usage{
validate(File)
validate(path)
}
\arguments{
\item{File}{The filepath to the plaintext-records}
\item{path}{The filepath to a single record, or a
directory to search recursively}
}
\description{
Validates a plaintext-MassBankrecord. The Unit Tests to
be used are installed in RMassBank/
Validates a plaintext-MassBankrecord, or recursively all
records below a directory. The Unit Tests to be used are
installed in RMassBank/
}
\examples{
\dontrun{
validate("/tmp/MassBank/OpenData/record/")
}
}
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