about summary refs log tree commit diff
path: root/test/python/test_mapping_methods.py
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-11-10 21:09:21 +0000
committerPjotr <wrk@bosa.lan>2026-11-10 21:09:21 +0000
commit0d3874f12587a771b774712bfa182926bfe37592 (patch)
treee1a89e9fd29eb2383223c365a77be75c6c20bc2b /test/python/test_mapping_methods.py
parent65a56cb93e905e5901ae61eca750991042721be5 (diff)
downloadgenenetwork4-0d3874f12587a771b774712bfa182926bfe37592.tar.gz
matrices: upload new traits and covariates as one named table
The other half of changing data: bringing new columns in. A matrix is a
delimited table -- a header row, then one row per individual, the first
column naming them -- stored in the uploader's own SQLite file and checked
against an existing genotype version's panel before it is accepted.

  * POST /matrices {name, genotype_version, contents, kinds?}: parse the
    table (tab, comma or semicolon, guessed from the header), then check
    it against that version's individuals. The count must match and every
    name must be in the panel; 92 of 93, or a name the panel does not
    have, is a 422 that says which. A mapping that silently drops
    individuals is worse than an error.
  * kinds marks columns that are covariates; everything else is a trait.
  * Each column becomes a basket named <matrix>.<column> -- a dot, not a
    slash, because a basket name has to survive a URL path segment -- so
    a column maps on any engine with {"basket": "my-traits.bw"} and
    inherits the revision history and digest without a line of new
    mapping code.
  * GET /matrices lists them, GET /matrices/{name} their columns and
    basket names, GET /matrices/{name}/values the table back (parsed
    values, null where missing), DELETE removes the matrix and its
    columns.

Two bugs this found in the basket store, both real:

  * SQLite has foreign keys OFF by default, so the ON DELETE CASCADE
    never fired: deleting a basket left its rows behind, rowids were
    reused, and the next create hit "UNIQUE constraint failed:
    basket_version.basket_id, revision". The pragma is now set, and
    deletion removes the dependants explicitly, because files written
    before it have orphans.
  * The first attempt named a column's basket "<matrix>/<column>", which
    the basket-name rule (rightly) refuses. The dot keeps both rules.

scripts/example-matrix.py writes a table from a genotype file's own header
with deterministic values, so the fixture passes the panel check by
construction -- tests/matrices.rs builds its own for the same reason and
walks the loop: upload, read back, map a column with R/qtl2, delete, plus
the three refusals (too few individuals, a name not in the panel, an
unknown version).
Diffstat (limited to 'test/python/test_mapping_methods.py')
0 files changed, 0 insertions, 0 deletions