Skip to contents

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 Config object (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 from self$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. If files_tbl is supplied, this is ignored.

files_tbl

(tibble(n))
Tibble of files from list_files_dir().

Returns

(R6::R6Class())
R6 object.


Method print()

Print details about the Tool.

Usage

Tool$print(...)

Arguments

...

(ignored).

Returns

(R6::R6Class())
R6 object invisibly.


Method list_files()

List files matching this tool's patterns.

Usage

Tool$list_files()

Returns

(tibble())
The files tibble of matched files. Always a tibble (possibly zero-row), never NULL.


Method get_tbls()

Get tidy tibbles after parsing and tidying.

Usage

Tool$get_tbls()

Returns

(tibble() or NULL)
The tbls tibble, or NULL if tidy() has not been called or if tidy() found no matching files. When tidy(keep_raw = TRUE) was used, the tibble also contains a raw list-column of the unparsed tibbles.


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.

Usage

Tool$filter_files(include = NULL, exclude = NULL)

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.

Usage

Tool$tidy(keep_raw = FALSE)

Arguments

keep_raw

(logical(1))
Should the raw parsed tibbles be kept in the final output?

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))
If TRUE, prepend an input_prefix column to each tidy table.

dbconn

(DBIConnection)
Database connection object (see DBI::dbConnect).

write_metadata

(logical(1))
If TRUE (default), write a metadata_<tool>.parquet file alongside the tidy outputs. Set to FALSE when a Workflow is 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.

Usage

Tool$get_metadata(input_id, output_id, output_dir, pkgs = NULL)

Arguments

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).

output_dir

(character(1))
Output directory.

pkgs

(character(n))
Which R packages to extract versions for.

Returns

(tibble())
Single-row tibble with columns input_id, output_id, input_dirs, output_dir, pkg_versions, and files.


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))
If TRUE, prepend an input_prefix column to each tidy table.

dbconn

(DBIConnection)
Database connection object (see DBI::dbConnect).

write_metadata

(logical(1))
If TRUE (default), write a metadata_<tool>.parquet file alongside the tidy outputs. Set to FALSE to 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"