Base R6 class for all nemo tools. Subclasses implement parsers for specific
bioinformatic tool outputs by optionally overriding parse_{table_name}() and
tidy_{table_name}() methods for custom parse or tidy logic per table.
A Tool object:
has a name (
name);has a path to a directory with its outputs (
path);has a schema configuration
Configobject (config);exposes matched files via
list_files();exposes parsed and tidied tables via
get_tbls();
The typical workflow is: optionally filter files with filter_files(), parse
and tidy with tidy(), then write outputs with write(). run() chains
all three steps.
Public fields
name(
character(1))
Name of tool.pkg(
character(1))
Package name tool belongs to (for config lookup).path(
character(1))
Output directory of tool.config(
Config())
Config of tool.written_files(
tibble())
Tibble of files written fromself$write().
Methods
Method new()
Create a new Tool object.
Usage
Tool$new(name, pkg, path = NULL, files_tbl = NULL)Arguments
name(
character(1))
Name of tool.pkg(
character(1))
Package name tool belongs to (for config lookup).path(
character(1))
Output directory of tool. Iffiles_tblis supplied, this is ignored.files_tbl(
tibble(n))
Tibble of files fromlist_files_dir().
Returns
(R6::R6Class())
R6 object.
Method filter_files()
Filter files in given tool directory based on inclusion or
exclusion tool_parser names. The result is reflected in the files field.
Arguments
include(
character(n))
tool_parser names to include (e.g."tool1_table1").exclude(
character(n))
tool_parser names to exclude (e.g."tool1_table3").
Returns
(R6::R6Class())
R6 object invisibly.
Method tidy()
Tidy a list of files. The result is reflected in the tbls field.
Returns
(R6::R6Class())
R6 object invisibly.
Method write()
Write tidy tibbles.
Usage
Tool$write(
output_dir = ".",
format = "tsv",
input_id = NULL,
output_id = NULL,
prefix_include = FALSE,
dbconn = NULL,
write_metadata = TRUE
)Arguments
output_dir(
character(1))
Directory path to output tidy files. Ignored if format is db.format(
character(1))
Format of output.input_id(
character(1))
Input ID to use for the dataset (e.g.run123).output_id(
character(1))
Output ID to use for the dataset (e.g.out1).prefix_include(
logical(1))
IfTRUE, prepend aninput_prefixcolumn to each tidy table.dbconn(
DBIConnection)
Database connection object (seeDBI::dbConnect).write_metadata(
logical(1))
IfTRUE(default), write ametadata_<tool>.parquetfile alongside the tidy outputs. Set toFALSEwhen aWorkflowis orchestrating the write and will emit its own workflow-level metadata instead.
Returns
(R6::R6Class())
R6 object invisibly. Results stored in self$written_files
(NULL if no files were found).
Method get_metadata()
Get metadata for the tool run.
Method run()
Filter, tidy, and write files in one step.
Usage
Tool$run(
output_dir = ".",
format = "tsv",
input_id = NULL,
output_id = NULL,
prefix_include = FALSE,
dbconn = NULL,
write_metadata = TRUE,
include = NULL,
exclude = NULL
)Arguments
output_dir(
character(1))
Directory path to output tidy files.format(
character(1))
Format of output.input_id(
character(1))
Input ID to use for the dataset (e.g.run123).output_id(
character(1))
Output ID to use for the dataset (e.g.out1).prefix_include(
logical(1))
IfTRUE, prepend aninput_prefixcolumn to each tidy table.dbconn(
DBIConnection)
Database connection object (seeDBI::dbConnect).write_metadata(
logical(1))
IfTRUE(default), write ametadata_<tool>.parquetfile alongside the tidy outputs. Set toFALSEto suppress.include(
character(n))
tool_parser names to include (e.g."tool1_table1").exclude(
character(n))
tool_parser names to exclude (e.g."tool1_table5").
Returns
(R6::R6Class())
R6 object invisibly. Results stored in self$written_files.
Examples
fs::path(tempdir(), letters[1:5]) |>
fs::file_temp_push() |>
fs::dir_create()
name <- "tool1"; pkg <- "nemo";
path <- system.file("extdata/tool1", package = "nemo")
toolA <- Tool$new(name = name, pkg = pkg, path = path)
toolA$list_files()
#> # A tibble: 12 × 9
#> tool_parser parser bname size lastmodified path pattern prefix
#> <chr> <chr> <chr> <fs:> <dttm> <chr> <chr> <chr>
#> 1 tool1_table1 table1 sampleA.t… 133 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 2 tool1_table1 table1 sampleA.t… 113 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 3 tool1_table1 table1 sampleA.t… 93 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 4 tool1_table2 table2 sampleA.t… 70 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 5 tool1_table2 table2 sampleA.t… 47 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 6 tool1_table3 table3 sampleA.t… 83 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 7 tool1_table3 table3 sampleA.t… 48 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 8 tool1_table4 table4 sampleA.t… 52 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 9 tool1_table4 table4 sampleA.t… 34 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 10 tool1_table6 table6 sampleA.t… 100 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 11 tool1_table6 table6 sampleA.t… 78 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 12 tool1_table5 table5 sampleA.t… 994 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> # ℹ 1 more variable: prefix_suffix <chr>
toolA$filter_files(exclude = "tool1_table3"); toolA$list_files() # note the exclusion this time
#> # A tibble: 10 × 9
#> tool_parser parser bname size lastmodified path pattern prefix
#> <chr> <chr> <chr> <fs:> <dttm> <chr> <chr> <chr>
#> 1 tool1_table1 table1 sampleA.t… 133 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 2 tool1_table1 table1 sampleA.t… 113 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 3 tool1_table1 table1 sampleA.t… 93 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 4 tool1_table2 table2 sampleA.t… 70 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 5 tool1_table2 table2 sampleA.t… 47 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 6 tool1_table4 table4 sampleA.t… 52 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 7 tool1_table4 table4 sampleA.t… 34 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 8 tool1_table6 table6 sampleA.t… 100 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 9 tool1_table6 table6 sampleA.t… 78 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 10 tool1_table5 table5 sampleA.t… 994 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> # ℹ 1 more variable: prefix_suffix <chr>
toolB <- Tool$new(name = name, pkg = pkg, path = path)$
filter_files(include = "tool1_table1")
toolB$list_files()
#> # A tibble: 3 × 9
#> tool_parser parser bname size lastmodified path pattern prefix
#> <chr> <chr> <chr> <fs:> <dttm> <chr> <chr> <chr>
#> 1 tool1_table1 table1 sampleA.to… 133 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 2 tool1_table1 table1 sampleA.to… 113 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 3 tool1_table1 table1 sampleA.to… 93 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> # ℹ 1 more variable: prefix_suffix <chr>
# tidy + write
toolC <- Tool$new(name = name, pkg = pkg, path = path)$
filter_files(exclude = "tool1_table5")$
tidy()
toolC$list_files()
#> # A tibble: 11 × 9
#> tool_parser parser bname size lastmodified path pattern prefix
#> <chr> <chr> <chr> <fs:> <dttm> <chr> <chr> <chr>
#> 1 tool1_table1 table1 sampleA.t… 133 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 2 tool1_table1 table1 sampleA.t… 113 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 3 tool1_table1 table1 sampleA.t… 93 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 4 tool1_table2 table2 sampleA.t… 70 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 5 tool1_table2 table2 sampleA.t… 47 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 6 tool1_table3 table3 sampleA.t… 83 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 7 tool1_table3 table3 sampleA.t… 48 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 8 tool1_table4 table4 sampleA.t… 52 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 9 tool1_table4 table4 sampleA.t… 34 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 10 tool1_table6 table6 sampleA.t… 100 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 11 tool1_table6 table6 sampleA.t… 78 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> # ℹ 1 more variable: prefix_suffix <chr>
toolC$get_tbls() # note the tidy column
#> # A tibble: 11 × 10
#> tool_parser parser bname size lastmodified path pattern prefix
#> <chr> <chr> <chr> <fs:> <dttm> <chr> <chr> <chr>
#> 1 tool1_table1 table1 sampleA.t… 133 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 2 tool1_table1 table1 sampleA.t… 113 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 3 tool1_table1 table1 sampleA.t… 93 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 4 tool1_table2 table2 sampleA.t… 70 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 5 tool1_table2 table2 sampleA.t… 47 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 6 tool1_table3 table3 sampleA.t… 83 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 7 tool1_table3 table3 sampleA.t… 48 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 8 tool1_table4 table4 sampleA.t… 52 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 9 tool1_table4 table4 sampleA.t… 34 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 10 tool1_table6 table6 sampleA.t… 100 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> 11 tool1_table6 table6 sampleA.t… 78 2026-07-28 09:30:14 /hom… "\\.to… sampl…
#> # ℹ 2 more variables: prefix_suffix <chr>, tidy <list>
dir1 <- fs::file_temp(); dir2 <- fs::file_temp()
toolC$write(output_dir = dir1, format = "parquet", input_id = "run1")
(lfC <- list.files(dir1, full.names = TRUE))
#> [1] "/tmp/RtmpLFaYvY/a/metadata_tool1.parquet"
#> [2] "/tmp/RtmpLFaYvY/a/sampleA_2_tool1_table1.parquet"
#> [3] "/tmp/RtmpLFaYvY/a/sampleA_2_tool1_table2.parquet"
#> [4] "/tmp/RtmpLFaYvY/a/sampleA_2_tool1_table3.parquet"
#> [5] "/tmp/RtmpLFaYvY/a/sampleA_2_tool1_table4.parquet"
#> [6] "/tmp/RtmpLFaYvY/a/sampleA_2_tool1_table6.parquet"
#> [7] "/tmp/RtmpLFaYvY/a/sampleA_3_tool1_table1.parquet"
#> [8] "/tmp/RtmpLFaYvY/a/sampleA_tool1_table1.parquet"
#> [9] "/tmp/RtmpLFaYvY/a/sampleA_tool1_table2.parquet"
#> [10] "/tmp/RtmpLFaYvY/a/sampleA_tool1_table3.parquet"
#> [11] "/tmp/RtmpLFaYvY/a/sampleA_tool1_table4.parquet"
#> [12] "/tmp/RtmpLFaYvY/a/sampleA_tool1_table6.parquet"
# run
toolD <- Tool$new(name = name, pkg = pkg, path = path)$
filter_files(exclude = "tool1_table5")$
run(output_dir = dir2, format = "parquet", input_id = "run2")
(lfD <- list.files(dir2, full.names = TRUE))
#> [1] "/tmp/RtmpLFaYvY/b/metadata_tool1.parquet"
#> [2] "/tmp/RtmpLFaYvY/b/sampleA_2_tool1_table1.parquet"
#> [3] "/tmp/RtmpLFaYvY/b/sampleA_2_tool1_table2.parquet"
#> [4] "/tmp/RtmpLFaYvY/b/sampleA_2_tool1_table3.parquet"
#> [5] "/tmp/RtmpLFaYvY/b/sampleA_2_tool1_table4.parquet"
#> [6] "/tmp/RtmpLFaYvY/b/sampleA_2_tool1_table6.parquet"
#> [7] "/tmp/RtmpLFaYvY/b/sampleA_3_tool1_table1.parquet"
#> [8] "/tmp/RtmpLFaYvY/b/sampleA_tool1_table1.parquet"
#> [9] "/tmp/RtmpLFaYvY/b/sampleA_tool1_table2.parquet"
#> [10] "/tmp/RtmpLFaYvY/b/sampleA_tool1_table3.parquet"
#> [11] "/tmp/RtmpLFaYvY/b/sampleA_tool1_table4.parquet"
#> [12] "/tmp/RtmpLFaYvY/b/sampleA_tool1_table6.parquet"
