Skip to content

Commit

Permalink
.exe umbenannt
Browse files Browse the repository at this point in the history
  • Loading branch information
marinakiweler committed Jan 31, 2019
1 parent de77e27 commit 345ce68
Show file tree
Hide file tree
Showing 29 changed files with 119 additions and 266 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export("%>%")
export(create_term_match_table)
export(files_in_group)
export(flatten_json)
export(generate_json)
export(gradient_tables)
export(group_count)
export(instrument_names)
Expand All @@ -13,6 +14,5 @@ export(one_gradient_table)
export(one_group_match_terms)
export(save_all_groups)
export(save_group_table)
export(use_rawMetaAsJson)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
12 changes: 6 additions & 6 deletions R/additional_functions.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' Number of groups in the json file
#'
#' @param json A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly.
#' @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 <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' group_count(json)
#'
Expand All @@ -24,7 +24,7 @@ group_count <- function(json)

#' Filenames of one group
#'
#' @param json A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly.
#' @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.
Expand All @@ -33,7 +33,7 @@ group_count <- function(json)
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' files_in_group(json, 1)
#'
Expand All @@ -51,7 +51,7 @@ files_in_group <- function(json, group_number)

#' Get instrument names
#'
#' @param json A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly.
#' @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.
Expand All @@ -60,7 +60,7 @@ files_in_group <- function(json, group_number)
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' instrument_names(json, 1)
#'
Expand Down
7 changes: 7 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@
#' ...
#' }
"tmt_list"


#' Already generated JSON example file.
#'
#' @format A JSON file, read by jsonlite::fromJSON()
#'
"testfile_json"
4 changes: 2 additions & 2 deletions R/gradient_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ gradient_as_string <- function(flat_json, group_number)
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' flat_json <- flatten_json(json)
#'
Expand Down Expand Up @@ -94,7 +94,7 @@ one_gradient_table <- function(flat_json, group_number, lc_pump = "Thermo EASY-n
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' flat_json <- flatten_json(json)
#'
Expand Down
16 changes: 8 additions & 8 deletions R/load_meta_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' @export

use_rawMetaAsJson <- function(path_data)
generate_json <- function(path_data)
{
new_file <- tempfile()
path_rawMetaAsJson <- system.file(
file.path('bin','rawMetaAsJson.exe'),
path_MARMoSET_exe <- system.file(
file.path('bin','MARMoSET.exe'),
package = 'MARMoSET', mustWork = TRUE)

assertive.files::assert_all_are_executable_files(path_rawMetaAsJson, warn_about_windows = F)
assertive.files::assert_all_are_executable_files(path_MARMoSET_exe, warn_about_windows = F)

path_data_is_ok <- function(x){ assertive.files::is_dir(x) || assertive.files::is_readable_file(x, warn_about_windows = F)}
assertive.base::assert_engine( path_data_is_ok, path_data,
Expand All @@ -32,7 +32,7 @@ use_rawMetaAsJson <- function(path_data)
stop("Function is only working under windows.")
}

system(command = paste(path_rawMetaAsJson, paste0('"',path_data, '"'), new_file),
system(command = paste(path_MARMoSET_exe, paste0('"',path_data, '"'), new_file),
intern = T)

json <- jsonlite::fromJSON(new_file)
Expand All @@ -43,15 +43,15 @@ use_rawMetaAsJson <- function(path_data)

#' flattening JSON
#'
#' @param json A JSON file generated by the function "use_rawMetaAsJson()" or by using rawMetaAsJson.exe externaly.
#' @param json A JSON file generated by the function "generate_json()" or by using MARMoSET.exe externaly.
#'
#' @return A flattened Json for better access.
#'
#' @examples
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' flat_json <- flatten_json(json)
#'
Expand Down
25 changes: 20 additions & 5 deletions R/output_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' flat_json <- flatten_json(json)
#'
Expand All @@ -31,14 +31,29 @@ save_group_table <- function(groups_vector, output_path, group_number)
assertive.files::assert_all_are_dirs(output_path %>% pathological::decompose_path() %>% .$dirname)
assertive.strings::assert_all_are_non_empty_character(output_path %>% pathological::decompose_path() %>% .$filename)

if (output_path %>% pathological::decompose_path() %>% .$extension != "txt")
if (output_path %>% pathological::decompose_path() %>% .$extension %>% stringi::stri_endswith(fixed = "txt"))
{
output_path %<>% pathological::decompose_path() %>%
output_path_txt <- output_path
}else
{
output_path_txt <- pathological::decompose_path(output_path) %>%
magrittr::inset2('extension', value = paste(.$extension,'txt', sep = '')) %>%
pathological::recompose_path()
}

utils::write.table(groups_vector[[group_number]], file = output_path, sep = "\t")
utils::write.table(groups_vector[[group_number]], file = output_path_txt, sep = "\t")

if (output_path %>% pathological::decompose_path() %>% .$extension %>% stringi::stri_endswith(fixed = "csv"))
{
output_path_csv <- output_path
}else
{
output_path_csv <- pathological::decompose_path(output_path) %>%
magrittr::inset2('extension', value = paste(.$extension,'csv', sep = '')) %>%
pathological::recompose_path()
}

utils::write.csv(groups_vector[[group_number]], file = output_path_csv)
}

utils::globalVariables('.')
Expand All @@ -53,7 +68,7 @@ utils::globalVariables('.')
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' flat_json <- flatten_json(json)
#'
Expand Down
4 changes: 2 additions & 2 deletions R/reexports.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' magrittr forward-pipe operator
#'
#' See \code{\link[magrittr]{\\\%>\\\%}}.
#' See \code{\link[magrittr]{\%>\%}}.
#' @name %>%
#' @importFrom magrittr %>%
#' @export %>%
NULL

#' magrittr compound assignment pipe operator
#'
#' See \code{\link[magrittr]{\\\%<>\\\%}}.
#' See \code{\link[magrittr]{\%<>\%}}.
#' @name %<>%
#' @importFrom magrittr %<>%
#' @export %<>%
Expand Down
4 changes: 2 additions & 2 deletions R/term_matching_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' flat_json <- flatten_json(json)
#'
Expand Down Expand Up @@ -46,7 +46,7 @@ match_terms <- function(flat_json, term_matching_table)
#' data <- system.file(
#' file.path('extdata', 'testfile.raw'),
#' package = 'MARMoSET', mustWork = TRUE)
#' json <- use_rawMetaAsJson(data)
#' json <- generate_json(data)
#'
#' flat_json <- flatten_json(json)
#'
Expand Down
8 changes: 4 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ remotes::install_github('loosolab/MARMoSET', host='github.molgen.mpg.de/api/v3')

## Usage:

The c# command line tool can be used in R with `use_rawMetaAsJson()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files.
The c# command line tool can be used in R with `generate_json()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files.

This JSON file can also be created by using the rawMetaAsJson.exe externally.
This JSON file can also be created by using the MARMoSET.exe externally.

Due to the design of the RawFileReader the rawMetaAsJson.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created.
Due to the design of the RawFileReader the MARMoSET.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created. To open a JSON file in R the package `jsonlite` provides the function `fromJSON()`.

```{r}
library(MARMoSET)
Expand All @@ -59,7 +59,7 @@ if(.Platform$OS.type == 'windows')
file.path('extdata', 'testfile.raw'),
package = 'MARMoSET', mustWork = TRUE)
json <- use_rawMetaAsJson(path_data = data)
json <- generate_json(path_data = data)
} else
{
# non windows user need to read in the JSON file here
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ remotes::install_github('loosolab/MARMoSET', host='github.molgen.mpg.de/api/v3')
Usage:
------

The c\# command line tool can be used in R with `use_rawMetaAsJson()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files.
The c\# command line tool can be used in R with `generate_json()` to create a JSON file including only the meta data of grouped raw files. It takes as argument `path_data`, a path to a raw file or a directory containing raw files.

This JSON file can also be created by using the rawMetaAsJson.exe externally.
This JSON file can also be created by using the MARMoSET.exe externally.

Due to the design of the RawFileReader the rawMetaAsJson.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created.
Due to the design of the RawFileReader the MARMoSET.exe and therefore this command is running as 64 bit code on Windows only. To use this package with another operating system, it is necessarry to already have the JSON file created. To open a JSON files in R the package `jsonlite` provides the function `fromJSON()`.

``` r
library(MARMoSET)
Expand All @@ -52,7 +52,7 @@ if(.Platform$OS.type == 'windows')
file.path('extdata', 'testfile.raw'),
package = 'MARMoSET', mustWork = TRUE)

json <- use_rawMetaAsJson(path_data = data)
json <- generate_json(path_data = data)
} else
{
# non windows user need to read in the JSON file here
Expand Down
Binary file renamed inst/bin/rawMetaAsJson.exe → inst/bin/MARMoSET.exe
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
Binary file renamed inst/bin/rawMetaAsJson.pdb → inst/bin/MARMoSET.pdb
Binary file not shown.
4 changes: 2 additions & 2 deletions man/files_in_group.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/flatten_json.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 24 additions & 24 deletions man/use_rawMetaAsJson.Rd → man/generate_json.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gradient_tables.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/grapes-greater-than-grapes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 345ce68

Please sign in to comment.