Reads and parses a tool's schema.yaml from inst/config/tools/<tool>/ in
the package. The schema defines each output table: its file pattern, file
type, description, and versioned columns (raw name, tidy name, type, versions).
Exposes raw and tidy schemas and column mappings used by Tool for
file discovery and column renaming.
A Config object:
belongs to a package (
pkg)has a tool name (
tool)has a parsed tables list (accessible via
get_tables())caches all raw schemas as a flat tibble (
schemas_raw)caches all tidy schemas as a flat tibble (
schemas_tidy)
Public fields
tool(
character(1))
Tool name.pkg(
character(1))
Package name tool belongs to (for config lookup).
Methods
Method new()
Create a new Config object.
Usage
Config$new(tool, pkg)Arguments
tool(
character(1))
Tool name.pkg(
character(1))
Package name tool belongs to (for config lookup).
Returns
(R6::R6Class())
R6 object.
Method get_tables()
Return the parsed tables list.
Returns
(list())
Named list of table definitions from schema.yaml.
Method get_schema_raw()
Get raw schema for a specific table and optional version.
Method get_schema_tidy()
Get tidy schema for a specific table and optional version.
Method get_col_map()
Get column mapping (raw -> tidy) for a table. Used for tables with custom parse logic (e.g. csv-nohead-long).
version = NULL resolves to a single version here, unlike
get_schema_raw()/get_schema_tidy() which return all versions when
version = NULL. Use an explicit version string if you need a specific version
from either family of methods.
Examples
tool <- "tool1"
pkg <- "nemo"
conf <- Config$new(tool, pkg)
(patterns <- conf$get_patterns())
#> # A tibble: 6 × 2
#> name pattern
#> <chr> <chr>
#> 1 table1 "\\.tool1\\.table1\\.tsv$"
#> 2 table2 "\\.tool1\\.table2\\.tsv$"
#> 3 table3 "\\.tool1\\.table3\\.tsv$"
#> 4 table4 "\\.tool1\\.table4\\.tsv$"
#> 5 table6 "\\.tool1\\.table6\\.csv$"
#> 6 table5 "\\.tool1\\.table5\\.csv$"
(ftypes <- conf$get_ftypes())
#> # A tibble: 6 × 2
#> name ftype
#> <chr> <chr>
#> 1 table1 tsv
#> 2 table2 tsv
#> 3 table3 tsv-keyvalue
#> 4 table4 tsv-nohead
#> 5 table6 csv
#> 6 table5 csv-nohead-long
(pat1 <- conf$get_pattern("table1"))
#> [1] "\\.tool1\\.table1\\.tsv$"
(ftype1 <- conf$get_ftype("table1"))
#> [1] "tsv"
(descr1 <- conf$get_description("table1"))
#> [1] "Table1 for tool1 (txt: header present, tab-delimited)."
(descr <- conf$get_descriptions())
#> # A tibble: 6 × 2
#> name description
#> <chr> <chr>
#> 1 table1 Table1 for tool1 (txt: header present, tab-delimited).
#> 2 table2 Table2 for tool1 (txt: header present, tab-delimited).
#> 3 table3 Table3 for tool1 (txt-keyvalue: no header, 2 cols, col1=key col2=value…
#> 4 table4 Table4 for tool1 (txt-nohead: no header, positional cols X1..XN).
#> 5 table6 Table6 for tool1 (csv: header present, comma-delimited).
#> 6 table5 Table5 for tool1 (csv-nohead-long: no header, long format with metric …
(rs <- conf$get_schemas_raw())
#> # A tibble: 12 × 4
#> name tbl_description version schema
#> <chr> <chr> <chr> <list>
#> 1 table1 Table1 for tool1 (txt: header present, tab-delimited… v1.2.3 <tibble>
#> 2 table1 Table1 for tool1 (txt: header present, tab-delimited… v4.5.6 <tibble>
#> 3 table1 Table1 for tool1 (txt: header present, tab-delimited… latest <tibble>
#> 4 table2 Table2 for tool1 (txt: header present, tab-delimited… v1.0.0 <tibble>
#> 5 table2 Table2 for tool1 (txt: header present, tab-delimited… latest <tibble>
#> 6 table3 Table3 for tool1 (txt-keyvalue: no header, 2 cols, c… v1.0.0 <tibble>
#> 7 table3 Table3 for tool1 (txt-keyvalue: no header, 2 cols, c… latest <tibble>
#> 8 table4 Table4 for tool1 (txt-nohead: no header, positional … v1.0.0 <tibble>
#> 9 table4 Table4 for tool1 (txt-nohead: no header, positional … latest <tibble>
#> 10 table6 Table6 for tool1 (csv: header present, comma-delimit… v1.0.0 <tibble>
#> 11 table6 Table6 for tool1 (csv: header present, comma-delimit… latest <tibble>
#> 12 table5 Table5 for tool1 (csv-nohead-long: no header, long f… latest <tibble>
(ts <- conf$get_schemas_tidy())
#> # A tibble: 12 × 4
#> name tbl_description version schema
#> <chr> <chr> <chr> <list>
#> 1 table1 Table1 for tool1 (txt: header present, tab-delimited… v1.2.3 <tibble>
#> 2 table1 Table1 for tool1 (txt: header present, tab-delimited… v4.5.6 <tibble>
#> 3 table1 Table1 for tool1 (txt: header present, tab-delimited… latest <tibble>
#> 4 table2 Table2 for tool1 (txt: header present, tab-delimited… v1.0.0 <tibble>
#> 5 table2 Table2 for tool1 (txt: header present, tab-delimited… latest <tibble>
#> 6 table3 Table3 for tool1 (txt-keyvalue: no header, 2 cols, c… v1.0.0 <tibble>
#> 7 table3 Table3 for tool1 (txt-keyvalue: no header, 2 cols, c… latest <tibble>
#> 8 table4 Table4 for tool1 (txt-nohead: no header, positional … v1.0.0 <tibble>
#> 9 table4 Table4 for tool1 (txt-nohead: no header, positional … latest <tibble>
#> 10 table6 Table6 for tool1 (csv: header present, comma-delimit… v1.0.0 <tibble>
#> 11 table6 Table6 for tool1 (csv: header present, comma-delimit… latest <tibble>
#> 12 table5 Table5 for tool1 (csv-nohead-long: no header, long f… latest <tibble>
(s1 <- conf$get_schema_raw("table1"))
#> # A tibble: 15 × 3
#> version field type
#> <chr> <chr> <chr>
#> 1 v1.2.3 SampleID c
#> 2 v1.2.3 Chromosome c
#> 3 v1.2.3 Start i
#> 4 v1.2.3 End i
#> 5 v1.2.3 metricX d
#> 6 v4.5.6 SampleID c
#> 7 v4.5.6 Chromosome c
#> 8 v4.5.6 Start i
#> 9 v4.5.6 End i
#> 10 latest SampleID c
#> 11 latest Chromosome c
#> 12 latest Start i
#> 13 latest End i
#> 14 latest metricY d
#> 15 latest metricZ d
conf$get_schema_raw("table1", version = "v1.2.3")
#> # A tibble: 5 × 3
#> version field type
#> <chr> <chr> <chr>
#> 1 v1.2.3 SampleID c
#> 2 v1.2.3 Chromosome c
#> 3 v1.2.3 Start i
#> 4 v1.2.3 End i
#> 5 v1.2.3 metricX d
conf$get_schema_tidy("table1")
#> # A tibble: 15 × 3
#> version field type
#> <chr> <chr> <chr>
#> 1 v1.2.3 sample_id c
#> 2 v1.2.3 chromosome c
#> 3 v1.2.3 start i
#> 4 v1.2.3 end i
#> 5 v1.2.3 metric_x d
#> 6 v4.5.6 sample_id c
#> 7 v4.5.6 chromosome c
#> 8 v4.5.6 start i
#> 9 v4.5.6 end i
#> 10 latest sample_id c
#> 11 latest chromosome c
#> 12 latest start i
#> 13 latest end i
#> 14 latest metric_y d
#> 15 latest metric_z d
(cm <- conf$get_col_map("table5"))
#> # A tibble: 4 × 4
#> raw tidy type description
#> <chr> <chr> <chr> <chr>
#> 1 Total reads reads_total d total reads
#> 2 Mapped reads reads_map d mapped reads
#> 3 Unmapped reads reads_unmap d unmapped reads
#> 4 Total bases bases_total d total bases
