Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This endpoint returns:
- The global/initial bounding box for the map
- Metadata pertaining to a specific model release (this is specified by an optional `model_release` parameter, which defaults to latest, as configured via `config.ts`):
- The model release label ('version')
- The corresponding data release for the model release
- The corresponding data release and shapefile source for the model release (under the 'dependencies' property)
- The available genes for the model release, each with their available 'mutations' (encoding position and allele), and the range of dates for which prevalence is modelled for each mutation.

Example:
Expand All @@ -36,7 +36,10 @@ response:
"model_releases": ["v1", "v2"],
"prevalences": {
"version": "v1",
"data_release": "v1.0.0",
"dependencies": {
"data_release": "v1.0.0",
"shapefile_source": "gadm41",
},
"variants": [
{
"gene": "k13",
Expand Down Expand Up @@ -166,7 +169,7 @@ Rscript scripts/create_example_model_outputs.R
3. Fetch admin0 region metadata from Grout

```sh
ts-node --esm scripts/fetch_admin0_region_metadata.ts
npx ts-node --esm scripts/fetch_admin0_region_metadata.ts
```

4. Copy env vars
Expand Down Expand Up @@ -205,7 +208,15 @@ This will create `./data/stave/<version>/survey_data.parquet`.

As mentioned above, early development has used example model outputs generated by a script. We will at some point have access to real model outputs. Once these are provided, we can get rid of the tooling that creates example model outputs. We may then still need to do some amount of transformation to wrangle the data into the preferred format or filetype; this transformation step should take the form of a new script, akin to `./scripts/process_stave.R`.

As things stand now, a file `./data/model/<version>/metadata.json` must be manually created, to document the dependency of the model outputs (example or real) on a particular STAVE release.
As things stand now, a file `./data/model/<version>/metadata.json` must be manually created, to document the dependency of the model outputs (example or real) on a particular STAVE release (and shapefile source since the model outputs, which are per-region, will be in reference to some source of region shapes). Providing the dependency file should eventually be the responsibility of the modelling team.

### Test fixtures

To avoid making tests dependent on potentially changing data, the integration tests use small fixtures (relatively small compared to real data). They shouldn't need frequently updating unless the data schema itself is changing. These are generated by a script, which is configured by [./tests/fixtures/fixture-config.json](./tests/fixtures/fixture-config.json):

```sh
npm run generate-test-fixtures
```

### Test fixtures

Expand Down
3 changes: 2 additions & 1 deletion data/model/2026.05.08/metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "2026.05.08",
"data_release": "2026.03.17"
"data_release": "2026.03.17",
"shapefile_source": "gadm41"
}
5 changes: 4 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export const createApp = (): Express => {
model_releases: modelVersions,
prevalences: {
version: modelVersion,
data_release: dataVersion,
dependencies: {
data_release: dataVersion,
shapefile_source: modelMetadata.shapefile_source,
},
variants: mutationsByGene,
},
bounds: globalBounds.bounds,
Expand Down
Binary file modified tests/fixtures/data/model/2026.05.08/admin0.parquet
Binary file not shown.
Binary file modified tests/fixtures/data/model/2026.05.08/admin1.parquet
Binary file not shown.
Binary file modified tests/fixtures/data/model/2026.05.08/admin2.parquet
Binary file not shown.
3 changes: 2 additions & 1 deletion tests/fixtures/data/model/2026.05.08/metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "2026.05.08",
"data_release": "2026.03.17"
"data_release": "2026.03.17",
"shapefile_source": "gadm41"
}
1 change: 1 addition & 0 deletions tests/fixtures/fixture-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"modelRelease": "2026.05.08",
"dataRelease": "2026.03.17",
"shapefileSource": "gadm41",
"countries": [
"MLI",
"ETH"
Expand Down
10 changes: 8 additions & 2 deletions tests/integration/metadata.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ describe('GET /metadata', () => {
model_releases: [fixtureConfig.modelRelease],
prevalences: {
version: fixtureConfig.modelRelease,
data_release: fixtureConfig.dataRelease,
dependencies: {
data_release: fixtureConfig.dataRelease,
shapefile_source: fixtureConfig.shapefileSource,
},
},
bounds: {
min: { lng: expect.closeTo(-70.0635, 0.1), lat: expect.closeTo(12.4124, 0.1) },
Expand Down Expand Up @@ -49,7 +52,10 @@ describe('GET /metadata', () => {

expect(response.status).toBe(200);
expect(response.body.prevalences.version).toBe(fixtureConfig.modelRelease);
expect(response.body.prevalences.data_release).toBe(fixtureConfig.dataRelease);
expect(response.body.prevalences.dependencies).toEqual({
data_release: fixtureConfig.dataRelease,
shapefile_source: fixtureConfig.shapefileSource,
});
});

it('rejects an unknown model release', async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/surveys.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ describe('GET /surveys', () => {
reference_year: 2025,
numerator: 75,
denominator: 438,
prevalence: expect.closeTo(17.123287671232877),
prevalence_lower: expect.closeTo(13.713367285006745),
prevalence_upper: expect.closeTo(20.984498579443024),
prevalence: expect.closeTo(17.12),
prevalence_lower: expect.closeTo(13.71),
prevalence_upper: expect.closeTo(20.98),
}]);
});

Expand Down
Loading