just_dna_format.spelling¶
just_dna_format.spelling ¶
One comparison rule per kind of value (RM363, @one-normalizer-two-spellings).
A gene symbol, a drug name, a DOI and a chromosome are each written more than one way by the people and
sources that fill a module, and each is compared or keyed in more than one place. The defect this module
exists to prevent is the second place comparing by a different rule than the first: the 0.8 audit found
Apoe matched as APOE by the PGx duplicate checks and missed by the meta-table's expansion, chr12
folded to 12 on variants.csv and kept on studies.csv, and a DOI ending in . read as one citation
by the literature pass and as two by the duplicate-citation check.
Two shapes, and which one a kind takes is decided by what it already did:
- Folded on input —
chrom.VariantRowhas stored the member (12,MT) since 0.5, and every coordinate key is built from the stored cell, so every model declaringchromdeclares it asChromCelland stores the member too. Only a spelling of a primary-assembly contig is folded; any other value is kept as written, so a model that never refused a scaffold still does not (Principle 3) andVariantRow's refusal still quotes what the author wrote. - Compared through a key, stored verbatim —
gene,drug,doi. What a cell says is the author's (@verbatim-except-order); what two cells are compared by iscomparison_key, looked up by column name inCOMPARISON_KEYS. A test walks every model and asserts the set of fields of these kinds equals the registry, and an AST walk asserts no site compares one raw.
trait_efo_id (EFO_0004340 / EFO:0004340), haplotype and allele names, sex (a closed vocabulary,
stored as its member) and rsIDs (^rs\d+$, one spelling) are compared verbatim everywhere: one rule each,
not two, so none is an instance of the class.
Format tier: imports only vrs, so every model module can import it.
fold_chrom ¶
A chrom cell as stored: a spelling of a primary-assembly contig becomes its member (chr12 →
12, chrM → MT); anything else is returned as written, refused or kept by the model's own rule.
Source code in schema/src/just_dna_format/spelling.py
gene_key ¶
A gene symbol as two cells compare it: case and surrounding space do not make two genes (RM351,
RM356). Cyp2c19 and CYP2C19 are one gene to every check, key and selector.
Source code in schema/src/just_dna_format/spelling.py
drug_key ¶
A drug name as two cells compare it: Azathioprine and azathioprine are one drug, one key and
one (sex, drug) scope. A separate function from gene_key although the body is the same, because
the two are different claims about different vocabularies and either may need to move alone.
Source code in schema/src/just_dna_format/spelling.py
doi_token ¶
The DOI a free-form cell names, as two cells compare it, or None when it names none.
The token is lower-cased (DOIs are case-insensitive) and loses a trailing ., ,, ; or quote and an
unbalanced closing bracket, which a DOI pasted from prose carries and a registered DOI does not end in. The None arm is for text that is not
a validated doi cell — a registry's answer, a free-text field.
Source code in schema/src/just_dna_format/spelling.py
doi_key ¶
A doi cell's key: doi_token when it carries one, else the stripped cell lower-cased.
A validated doi cell always carries a token (validate_doi_cell), so the fallback is reached only by
a caller keying text the model did not validate.
Source code in schema/src/just_dna_format/spelling.py
comparison_key ¶
value of column as any two cells of it are compared: through COMPARISON_KEYS, else as is.
None stays None — an unstated cell is never equal to a stated one by normalization.
Source code in schema/src/just_dna_format/spelling.py
distinct_spellings ¶
The distinct values of column by its comparison, each in its first spelling, sorted.
For a published list (manifest.stats.genes): APOE and Apoe are one gene, named as it was first
written, and the list is sorted so its order cannot drift.