|
| 1 | +# Configuration |
| 2 | + |
| 3 | +`MetaPanG` uses a cascading configuration system so that stable defaults can be kept |
| 4 | +in a file while individual runs, environments, or invocations override them without |
| 5 | +editing that file. A parameter may be set at several levels. Each level overrides the |
| 6 | +previous one. From lowest to highest precedence: |
| 7 | + |
| 8 | +1. **system** (`~/.config/metapang-config.*`): user-wide defaults shared by every run, |
| 9 | + for example the cache directory or the `PanGBank` endpoint. |
| 10 | +2. **local** (`.metapang-config.*` in the current working directory): settings specific |
| 11 | + to an analysis directory, kept alongside its data. |
| 12 | +3. **cli** (a file passed with `metapang --config <path>`): a configuration selected |
| 13 | + explicitly for a given run. |
| 14 | +4. **environment** (variables of the form `METAPANG_<CMD>_<SUBCMD>_<PARAM>`): transient |
| 15 | + overrides, convenient in scripts, containers, or job schedulers. |
| 16 | +5. **option** (a command-line option, `--param <value>`): a one-off override for a |
| 17 | + single invocation. |
| 18 | + |
| 19 | +Configuration files may be written in TOML, JSON, or YAML. A template, or the |
| 20 | +configuration schema, can be produced with: |
| 21 | + |
| 22 | +``` |
| 23 | +metapang configure template # commented template |
| 24 | +metapang configure template --schema # JSON schema |
| 25 | +``` |
| 26 | + |
| 27 | +The resolved configuration, and the origin of each value, can be inspected with: |
| 28 | + |
| 29 | +``` |
| 30 | +metapang configure show # the effective configuration |
| 31 | +metapang configure show -s # the same, annotated with the source of each value |
| 32 | +``` |
| 33 | + |
| 34 | +## File structure |
| 35 | + |
| 36 | +A configuration file has two top-level sections: |
| 37 | + |
| 38 | +`pangbank` |
| 39 | +: global settings such as the cache directory and the `PanGBank` endpoint. |
| 40 | + |
| 41 | +`commands` |
| 42 | +: per-command defaults, keyed by command then option. A top-level command like |
| 43 | + `profile` is `commands.profile.<option>`. A nested one like `search bank` is |
| 44 | + `commands.search.bank.<option>`. |
| 45 | + |
| 46 | +You only need to set the values you want to change. Everything else keeps its |
| 47 | +default. The following file sets the cache directory and a few `profile` defaults, |
| 48 | +shown in each supported format. |
| 49 | + |
| 50 | +### YAML |
| 51 | + |
| 52 | +```yaml |
| 53 | +pangbank: |
| 54 | + cache_directory: /shared/metapang-cache |
| 55 | + api_endpoint: https://pangbank-api.genoscope.cns.fr |
| 56 | + |
| 57 | +commands: |
| 58 | + profile: |
| 59 | + threads: 8 |
| 60 | + stop_rule: cv_paired |
| 61 | + k_max: 12 |
| 62 | + search: |
| 63 | + bank: |
| 64 | + threshold_genome: 0.5 |
| 65 | +``` |
| 66 | +
|
| 67 | +### TOML |
| 68 | +
|
| 69 | +```toml |
| 70 | +[pangbank] |
| 71 | +cache_directory = "/shared/metapang-cache" |
| 72 | +api_endpoint = "https://pangbank-api.genoscope.cns.fr" |
| 73 | + |
| 74 | +[commands.profile] |
| 75 | +threads = 8 |
| 76 | +stop_rule = "cv_paired" |
| 77 | +k_max = 12 |
| 78 | + |
| 79 | +[commands.search.bank] |
| 80 | +threshold_genome = 0.5 |
| 81 | +``` |
| 82 | + |
| 83 | +### JSON |
| 84 | + |
| 85 | +```json |
| 86 | +{ |
| 87 | + "pangbank": { |
| 88 | + "cache_directory": "/shared/metapang-cache", |
| 89 | + "api_endpoint": "https://pangbank-api.genoscope.cns.fr" |
| 90 | + }, |
| 91 | + "commands": { |
| 92 | + "profile": { |
| 93 | + "threads": 8, |
| 94 | + "stop_rule": "cv_paired", |
| 95 | + "k_max": 12 |
| 96 | + }, |
| 97 | + "search": { |
| 98 | + "bank": { |
| 99 | + "threshold_genome": 0.5 |
| 100 | + } |
| 101 | + } |
| 102 | + } |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +The format is chosen by the file extension (`.yaml`/`.yml`, `.toml`, or `.json`). A |
| 107 | +full commented template listing every option is produced with |
| 108 | +`metapang configure template`. |
| 109 | + |
| 110 | +## Cache location |
| 111 | + |
| 112 | +Downloaded pangenomes and indices are cached under `.metapang-cache` in the current |
| 113 | +directory by default. The location is set by the `pangbank.cache_directory` parameter, |
| 114 | +for example in a system configuration file: |
| 115 | + |
| 116 | +```toml |
| 117 | +[pangbank] |
| 118 | +cache_directory = "/shared/metapang-cache" |
| 119 | +``` |
| 120 | + |
| 121 | +or through the corresponding environment variable: |
| 122 | + |
| 123 | +``` |
| 124 | +export METAPANG_PANGBANK_CACHE_DIRECTORY=/shared/metapang-cache |
| 125 | +``` |
| 126 | + |
| 127 | +On a shared system, pointing several users at the same directory lets them share a |
| 128 | +single cache. Downloads are file-locked, so concurrent runs may safely populate it. |
0 commit comments