Skip to content

Commit

Permalink
Johannification;
Browse files Browse the repository at this point in the history
  • Loading branch information
Joh committed Feb 7, 2019
1 parent eb84168 commit c02a672
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 201 deletions.
72 changes: 37 additions & 35 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
Package: MARMoSET
Type: Package
Title: Get metadata out of raw files
Version: 0.1.0
Author: Who wrote it
Maintainer: The package maintainer <yourself@somewhere.net>
Description: This packages uses a c# command line tool to extract the meta data of a raw file into a json file.
It contains methods to collect data requred for publication by journal and to write them into a tab delimited text file.
License: What license is it under?
Encoding: UTF-8
LazyData: true
Imports:
assertive.base,
assertive.files,
assertive.numbers,
assertive.properties,
assertive.reflection,
assertive.sets,
assertive.strings,
assertive.types,
dplyr,
jsonlite,
pathological,
rlist,
stringi,
tidyr,
magrittr
Depends:
R (>= 2.10)
Suggests:
readODS,
knitr,
rmarkdown
RoxygenNote: 6.1.1
VignetteBuilder: knitr
Package: MARMoSET
Type: Package
Title: Get metadata out of raw files
Version: 0.1.0
Author: Who wrote it
Maintainer: The package maintainer <yourself@somewhere.net>
Description: Extraction of meta data from Thermo Fisher Scientific mass spectrometric raw data files into a json file via a
c# command line tool.
Also provided are methods to assemble data requred for publication by journals and to write them into a tab delimited text file.
License: GPL (>= 3)
Encoding: UTF-8
LazyData: true
Imports:
assertive.base,
assertive.files,
assertive.numbers,
assertive.properties,
assertive.reflection,
assertive.sets,
assertive.strings,
assertive.types,
dplyr,
jsonlite,
magrittr,
pathological,
rlist,
stringi,
tidyr,
utils
Depends:
R (>= 2.10)
Suggests:
readODS,
knitr,
rmarkdown
RoxygenNote: 6.1.1
VignetteBuilder: knitr
39 changes: 20 additions & 19 deletions MARMoSET.Rproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageInstallArgs: --no-multiarch --with-keep.source
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran
162 changes: 82 additions & 80 deletions R/additional_functions.R
Original file line number Diff line number Diff line change
@@ -1,80 +1,82 @@
#' Number of groups in the json file
#'
#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.
#'
#' @return Count of groups in the JSON file.
#'
#' @examples
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- generate_json(data)
#'
#' group_count(json)
#'
#' @export

group_count <- function(json)
{
assertive.types::assert_is_list(json)

return(json[["Group"]] %>% length())
}


#' Filenames of one group
#'
#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.
#' @param group_number An index that determines the group.
#'
#' @return A list of filenames belonging to the choosen group.
#'
#' @examples
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- generate_json(data)
#'
#' files_in_group(json, 1)
#'
#' @export

files_in_group <- function(json, group_number)
{
assertive.types::assert_is_list(json)
assertive.types::assert_is_a_number(group_number)
assertive.numbers::assert_all_are_less_than_or_equal_to(group_number, group_count(json))

return(json[["Group"]][[group_number]][["Names"]])
}


#' Get instrument names
#'
#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.
#' @param group_number An index that determines the group.
#'
#' @return A list of instruments used in the choosen group.
#'
#' @examples
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- generate_json(data)
#'
#' instrument_names(json, 1)
#'
#' @export

instrument_names <- function(json, group_number)
{
assertive.types::assert_is_list(json)
assertive.types::assert_is_a_number(group_number)
assertive.numbers::assert_all_are_less_than_or_equal_to(group_number, group_count(json))

instruments <- json[["Group"]][[group_number]][["Instruments"]] %>%
summary() %>%
rownames()

return(instruments)
}
#' Number of groups in the json file
#'
#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.
#'
#' @return Count of groups in the JSON file.
#'
#' @examples
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- generate_json(data)
#'
#' group_count(json)
#'
#' @export

group_count <- function(json)
{
assertive.types::assert_is_list(json)

return(json[["Group"]] %>% length())
}


#' Filenames of one group
#'
#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.
#' @param group_number An index that determines the group.
#'
#' @return A list of filenames belonging to the choosen group.
#'
#' @examples
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#'
#' # Real-time JSON-generation: `json <- generate_json(data)`
#' json <- MARMoSET::testfile_json
#'
#' files_in_group(json, 1)
#'
#' @export

files_in_group <- function(json, group_number)
{
assertive.types::assert_is_list(json)
assertive.types::assert_is_a_number(group_number)
assertive.numbers::assert_all_are_less_than_or_equal_to(group_number, group_count(json))

return(json[["Group"]][[group_number]][["Names"]])
}


#' Get instrument names
#'
#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.
#' @param group_number An index that determines the group.
#'
#' @return A list of instruments used in the choosen group.
#'
#' @examples
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- generate_json(data)
#'
#' instrument_names(json, 1)
#'
#' @export

instrument_names <- function(json, group_number)
{
assertive.types::assert_is_list(json)
assertive.types::assert_is_a_number(group_number)
assertive.numbers::assert_all_are_less_than_or_equal_to(group_number, group_count(json))

instruments <- json[["Group"]][[group_number]][["Instruments"]] %>%
summary() %>%
rownames()

return(instruments)
}
Loading

0 comments on commit c02a672

Please sign in to comment.