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_caseoutput 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 underoutputswith its tidy columns - name the schema table after the file, outputs after their content
-
columnsmay be omitted when the file has its ownparse_<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()fortable3);Toolerrors on construction otherwise. - A table with
outputsneeds atidy_<table>()returning one tibble per output vianemo_enframe(), keyed by output name (seeTool1$tidy_table7()).Toolchecks the columns and types of each against the schema on every tidy.
