Skip to contents

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 print()

Print details about the Config.

Usage

Config$print(...)

Arguments

...

(ignored).

Returns

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


Method get_patterns()

Return all output file patterns.

Usage

Config$get_patterns()

Returns

(tibble())
Table name and its pattern.


Method get_ftypes()

Return all output file types.

Usage

Config$get_ftypes()

Returns

(tibble())
Table name and its ftype.


Method get_descriptions()

Return all table descriptions.

Usage

Config$get_descriptions()

Returns

(tibble())
Table name and its description.


Method get_pattern()

Return pattern for a specific table.

Usage

Config$get_pattern(x)

Arguments

x

(character(1))
Table name.

Returns

(character())
File pattern(s).


Method get_ftype()

Return ftype for a specific table.

Usage

Config$get_ftype(x)

Arguments

x

(character(1))
Table name.

Returns

(character(1))
File type.


Method get_description()

Return description for a specific table.

Usage

Config$get_description(x)

Arguments

x

(character(1))
Table name.

Returns

(character(1))
Table description.


Method get_tables()

Return the parsed tables list.

Usage

Config$get_tables()

Returns

(list())
Named list of table definitions from schema.yaml.


Method get_schemas_raw()

Return raw schemas for all tables.

Usage

Config$get_schemas_raw()

Returns

(tibble())
Table name, tbl_description, version, and schema (list-col of tibble(field, type)).


Method get_schemas_tidy()

Return tidy schemas for all tables.

Usage

Config$get_schemas_tidy()

Returns

(tibble())
Table name, tbl_description, version, and schema (list-col of tibble(field, type)).


Method get_schemas_both()

Return both raw and tidy schemas for all tables.

Usage

Config$get_schemas_both()

Returns

(tibble())
Table name, tbl_description, version, and schema (list-col of tibble(raw, tidy, type)).


Method get_schema_raw()

Get raw schema for a specific table and optional version.

Usage

Config$get_schema_raw(x, version = NULL)

Arguments

x

(character(1))
Table name.

version

(character(1))
Version string. If NULL, all versions are returned (one row per version). This differs from get_col_map(version = NULL), which resolves to a single version.

Returns

(tibble())
Table version, field and type.


Method get_schema_tidy()

Get tidy schema for a specific table and optional version.

Usage

Config$get_schema_tidy(x, version = NULL)

Arguments

x

(character(1))
Table name.

version

(character(1))
Version string. If NULL, all versions are returned (one row per version). This differs from get_col_map(version = NULL), which resolves to a single version.

Returns

(tibble())
Table version, field and type.


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.

Usage

Config$get_col_map(x, version = NULL)

Arguments

x

(character(1))
Table name.

version

(character(1))
Version string. If NULL, resolves to the highest semver version present, or "latest" if defined.

Returns

(tibble())
Tibble with columns raw, tidy, type, description.

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