just_dna_format.derive¶
just_dna_format.derive ¶
Legacy → 0.3 column derivations (the "upgrade" back-population) and the read-time aliases that let
a consumer see the orthogonal 0.3 axes even on a 0.1/0.2 module that only set state.
Kept as a leaf module (it imports nothing from spec) so both spec — for its effective_*
accessors and upgraded() — and external consumers (the marketplace revalidate/needs_upgrade
flow) can import these pure functions without an import cycle.
state and the ClinVar booleans stay required/authoritative for 0.2 backward-compat
(CONSTITUTION Principle 3 forbids making a required field optional inside a major); the new axes are
optional, with these derivations as their fallback. Every function here is total and idempotent:
applying it to an already-derived value is a no-op (CONSTITUTION Principle 7). See the
"Upgrade derivation" section of docs/COMPILER.md.
direction_from_state ¶
Derive direction from the legacy state (plus the weight sign when informative).
significant carries no direction on its own, so it is refined from the weight sign when present
(positive → protective, negative → risk); otherwise it, and the retired alt/ref descriptors,
map to the honest unknown the old enum lacked.
Source code in schema/src/just_dna_format/derive.py
stat_significance_from_state ¶
Derive stat_significance from the legacy state (only significant is informative).
trimmed_state ¶
Project a direction back into the trimmed legacy state set {protective, risk, neutral}.
unknown and contested both collapse to neutral — the legacy set has no member for either.
This is the derived, deprecated state an upgraded module emits. See _DIRECTION_TO_STATE for
why every vocabulary member needs an explicit entry there rather than relying on the default.
Source code in schema/src/just_dna_format/derive.py
clin_sig_from_booleans ¶
clin_sig_from_booleans(
pathogenic: bool | None,
benign: bool | None,
clinvar: bool | None,
) -> str | None
Derive a clin_sig tier from the lossy legacy ClinVar booleans.
pathogenic → pathogenic; benign → benign; in-ClinVar with neither flag →
uncertain_significance; otherwise None (nothing to say). Lossy by construction — legacy cannot
recover likely_pathogenic/likely_benign.
Source code in schema/src/just_dna_format/derive.py
pathogenic_from_clin_sig ¶
The pathogenic boolean implied by a clin_sig tier: True for the pathogenic tiers, else
None (the tier is silent on the boolean — we never fabricate a False a curator did not state).
Source code in schema/src/just_dna_format/derive.py
benign_from_clin_sig ¶
The benign boolean implied by a clin_sig tier: True for the benign tiers, else None.