Skip to contents

Adding a New Tool

1. Data

Sample files under inst/extdata/<tool>/ (~10 rows + header is enough). Track with DVC (see vignette("devnotes")).

2. Schema

Generate a skeleton schema.yaml from the sample files:

use("nemo")
use("here", "here")
use("glue", "glue")
use("tibble", "tribble")

tool <- "mytool"
d1 <- here(glue("inst/extdata/{tool}/latest"))

x <- tribble(
  ~name    , ~descr                , ~pat                        , ~type , ~path                                      ,
  "table1" , "table1 description." , "\\.mytool\\.table1\\.tsv$" , "tsv" , file.path(d1, "sampleA.mytool.table1.tsv") ,
  "table2" , "table2 description." , "\\.mytool\\.table2\\.csv$" , "csv" , file.path(d1, "sampleA.mytool.table2.csv") ,
)

out <- here(glue("inst/config/tools/{tool}/schema.yaml"))
config_prep_write(config_prep_multi(x), out)

Raw names and types are auto-detected. Fill in by hand:

  • tidy: snake_case output name
  • description: from the tool’s docs
  • versions: tool versions the column appears in, e.g. ['v1.2.3', 'latest']

One file, several tables (stats header + histogram, multi-section JSON):

  • keep the file’s raw columns; declare each table under outputs with its tidy columns
  • name the schema table after the file, outputs after their content
  • columns may be omitted when the file has its own parse_<table>() (JSON, multi-section, configurable columns)
  • shape: 'subset' on an output whose columns depend on the data (wide pivot)

Schema format: see Structure.

3. Parsers

Copy R/Tool1.R to R/<Tool>.R: initialize(), per-table parse_*() / tidy_*(), roxygen with @testexamples.

  • Method names must match a schema table (tidy_table3() for table3); Tool errors on construction otherwise.
  • A table with outputs needs a tidy_<table>() returning one tibble per output via nemo_enframe(), keyed by output name (see Tool1$tidy_table7()). Tool checks the columns and types of each against the schema on every tidy.