From c974f02317b85278cca85678c8cc5e5ad2fc1ee0 Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Fri, 20 Nov 2026 22:53:11 +0100 Subject: [PATCH 01/14] fix(pgx): treat a pypgx Indeterminate as no call in steps 27 and 36 pypgx writes Indeterminate for a gene it could not call, and step 32 writes it for CYP2D6 when the depth check fails. Step 27 read it as a diplotype: the comparison listed it as a pypgx call or a mismatch, and a gene PharmCAT could not call got a warning that pypgx called Indeterminate. Step 36 (and the summary, which shares its rule) read a diplotype with one Indeterminate allele as a call that could disagree with Cyrius. Indeterminate in any case, and as any allele, is now no call. Bead: pgx-06 Bead: pgx-30 --- docs/32-pypgx.md | 6 ++++-- rust/crates/og-pgx/src/tables.rs | 29 +++++++++++++++++++++++++-- rust/crates/og-steps/src/pgx_rules.rs | 15 +++++++++++++- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/docs/32-pypgx.md b/docs/32-pypgx.md index 6d187fdb3..12bc25056 100644 --- a/docs/32-pypgx.md +++ b/docs/32-pypgx.md @@ -165,7 +165,7 @@ All output is written to `${GENOME_DIR}/${SAMPLE}/pypgx/`. | Column | Description | |---|---| | Gene | Gene symbol | -| Diplotype | Star allele call (e.g., \*1/\*4); `Indeterminate` for CYP2D6 when the depth check failed (multi-mapped reads, or flanks under 10x); `FAILED` for a gene pypgx wrote no result for; `N/A` for a gene not callable on this reference (see Status) | +| Diplotype | Star allele call (e.g., \*1/\*4); `Indeterminate` for CYP2D6 when the depth check failed (multi-mapped reads, or flanks under 10x), or for a gene pypgx itself could not call; `FAILED` for a gene pypgx wrote no result for; `N/A` for a gene not callable on this reference (see Status) | | Phenotype | Metabolizer status (e.g., Intermediate Metabolizer). `no pypgx phenotype rule` for a gene pypgx has no phenotype rule for (no `PhenotypeMethod` in its own gene table; in 0.26.0 the 17 genes listed under [Weakly supported genes](#weakly-supported-genes)), where pypgx itself writes `Indeterminate` | | CNV_call | The copy-number call pypgx itself made from read depth (its `CNV` field, for example `Normal` or `WholeDel1`). BAM-based genes only; `N/A` for VCF-based genes, and `N/A (CYP2D6 depth check)` for CYP2D6 when the depth check failed. Earlier versions guessed a Yes/No flag from the allele names, which flagged any name containing `*5` and missed the GSTM1/GSTT1/CYP2A6 whole-gene deletions | | Source | BAM (SV genes) or VCF (variant-based genes) | @@ -176,6 +176,8 @@ All output is written to `${GENOME_DIR}/${SAMPLE}/pypgx/`. | Defining_filter | `PASS` when every defining variant is in the VCF with FILTER `PASS`; otherwise the ones that are not PASS (`RefCall`, `LowQual`..., or `no filter` for FILTER `.`) or not in the VCF, and any star allele pypgx's table lacks (`not in pypgx's table: *99`) | | Quality | `low-confidence: check the reads` when a defining variant has a GQ below the floor, `GQ not in the VCF: check the reads` when one has no GQ, `ok` otherwise, `N/A` without defining variants | +A Diplotype of `Indeterminate` is no call, in any case and also as one allele (`*1/Indeterminate`): step 36 counts it neither as agreeing nor as disagreeing with Cyrius, and step 27 gives it no comparison match and no warning. + ### Low-GQ star alleles A star allele can rest on a single heterozygous variant called with a low genotype quality. Such a call prints like any other diplotype, so the summary looks each defining variant up in the VCF, and a call with one below GQ 20 gets `low-confidence: check the reads` in its Quality column and in both reports, with the weakest variant and its AD. Set the floor with `PYPGX_GQ_FLOOR=15 ./scripts/32-pypgx.sh your_name`, or for the Nextflow module with `withName: 'PYPGX' { ext.gq_floor = 15 }` in a config passed with `-c`. Mapping the defining variants back to the VCF uses pypgx's allele table; a variant pypgx names differently from the VCF (a multi-base change written another way) reads as `not in the VCF`, so check such a call by hand. `og pgx pypgx-summary` (`rust/crates/og-steps/src/pypgx_summary.rs`) writes the summary and finds the allele table beside the pypgx on `PATH` (`--pypgx-data` names it). Without the tables, or without an index for the VCF, it still writes the summary and warns on stderr: Defining_variants says `not looked up` and the other four evidence columns say `N/A`, so a Quality of `N/A` there means no check ran. @@ -192,7 +194,7 @@ The pypgx section of both reports also lists the genes not assessable on this re | PharmCAT_diplotype | Diplotype from step 7 | | pypgx_diplotype | Diplotype from this step | | Match | Yes, No, pypgx only, or PharmCAT only. Allele names are compared after one rename: PharmCAT's `rs9923231 reference (C)` and pypgx's `Reference` are the same allele, and so are `rs9923231 variant (T)` and `rs9923231` | -| Called_by | `both` when both tools called the gene (Match is Yes or No), otherwise which tool did. PharmCAT's `Unknown/Unknown` and pypgx's `FAILED` and `N/A` count as no call; a gene neither tool called is left out | +| Called_by | `both` when both tools called the gene (Match is Yes or No), otherwise which tool did. PharmCAT's `Unknown/Unknown` and pypgx's `FAILED`, `N/A` and `Indeterminate` (in any case, or as one allele such as `*1/Indeterminate`) count as no call; a gene neither tool called is left out | | PharmCAT_phenotype | PharmCAT's phenotype for the gene, as step 27's phenotypes table shows it | | pypgx_phenotype | The Phenotype column of the summary above | diff --git a/rust/crates/og-pgx/src/tables.rs b/rust/crates/og-pgx/src/tables.rs index ef8455d7e..3a6bf2d2a 100644 --- a/rust/crates/og-pgx/src/tables.rs +++ b/rust/crates/og-pgx/src/tables.rs @@ -93,9 +93,14 @@ pub fn read_pypgx(path: &str) -> Result, PyErr> { Ok(out) } -/// A diplotype pypgx actually called. +/// A diplotype pypgx actually called. `Indeterminate` is no call, in any +/// case and in any form: pypgx writes it for a gene it could not call, +/// step 32 writes it for CYP2D6 when the depth check fails, and a +/// diplotype with an Indeterminate allele (`*1/Indeterminate`) names no +/// diplotype either. pub fn pypgx_called(diplotype: &str) -> bool { - !matches!(diplotype, "" | "FAILED" | "N/A" | "Not called") + let d = strip(diplotype, None); + !matches!(d, "" | "FAILED" | "N/A" | "Not called") && !lower(d).contains("indeterminate") } // --- step 36 ------------------------------------------------------------- @@ -407,6 +412,26 @@ mod tests { assert_eq!(got, want.map(|(a, b)| (a.to_owned(), b.to_owned()))); } + #[test] + fn indeterminate_is_no_pypgx_call() { + for d in ["*1/*4", " *1/*1 ", "Reference/rs9923231"] { + assert!(pypgx_called(d), "{d}"); + } + for d in [ + "", + "FAILED", + "N/A", + "Not called", + "Indeterminate", + "indeterminate", + " INDETERMINATE ", + "*1/Indeterminate", + "Indeterminate/Indeterminate", + ] { + assert!(!pypgx_called(d), "{d}"); + } + } + #[test] fn the_shipped_tables_read() { let root = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../assets/"); diff --git a/rust/crates/og-steps/src/pgx_rules.rs b/rust/crates/og-steps/src/pgx_rules.rs index a6ad63be2..89d05dcda 100644 --- a/rust/crates/og-steps/src/pgx_rules.rs +++ b/rust/crates/og-steps/src/pgx_rules.rs @@ -684,9 +684,16 @@ pub fn concordance_rows(t1k: &T1k, optitype: &OptiType) -> Vec<[String; 5]> { // --- CYP2D6 ----------------------------------------------------------------- /// A diplotype that is a call: not a no-call text, two alleles, one call. +/// An allele that is a no-call text (`*1/Indeterminate`), or any text that +/// names Indeterminate, is no call either, so it can neither agree nor +/// disagree with the other caller. pub fn is_call(diplotype: &str) -> bool { let d = strip(diplotype); - !no_call(d) && d.contains('/') && !d.contains(';') + !no_call(d) + && d.contains('/') + && !d.contains(';') + && !d.split('/').any(|a| no_call(strip(a))) + && !pycompat::text::lower(d).contains("indeterminate") } /// Equal up to the order of the two alleles. @@ -1191,6 +1198,12 @@ mod tests { fn calls_and_diplotypes() { assert!(is_call(" *1/*2 ")); assert!(!is_call("Indeterminate")); + assert!(!is_call(" indeterminate ")); + assert!(!is_call("*1/Indeterminate")); + assert!(!is_call("Indeterminate/Indeterminate")); + assert!(!is_call("*1/indeterminate")); + assert!(!is_call("Indeterminate (CYP2D6 depth check)")); + assert!(!is_call("*1/")); assert!(!is_call("*1/*2;*1/*3")); assert!(!is_call("*1")); assert!(same_diplotype("*2/*1", "*1/ *2")); From cd92a3f41544b328f7047ea88854e57a2834c65e Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Fri, 20 Nov 2026 22:53:12 +0100 Subject: [PATCH 02/14] fix(pgx): check every drug of a combination product on the medication list The medication list was matched by the first word of each line, so olanzapine/fluoxetine was checked as olanzapine alone, and naltrexone/bupropion was listed as not in the inhibitor table although bupropion is a strong CYP2D6 inhibitor. A line now names every word that is not a dose, a unit, a frequency or "and"; whitespace, commas, semicolons, "/" and "+" split it. Phenoconversion takes the strongest inhibitor among all of them, a line is unchecked only when none of its drugs is in the table, and the contraindication lines see every drug. port_tests_pgx_cpic.rs pinned the old first-word rule for lopinavir/ritonavir; its assertion now expects both drugs. Bead: pgx-16 --- docs/27-cpic-lookup.md | 6 +- rust/crates/og-pgx/src/cli.rs | 2 +- rust/crates/og-pgx/src/sections.rs | 18 ++-- rust/crates/og-pgx/src/tables.rs | 90 ++++++++++++++----- .../og-pgx/tests/port_tests_pgx_cpic.rs | 5 +- 5 files changed, 86 insertions(+), 35 deletions(-) diff --git a/docs/27-cpic-lookup.md b/docs/27-cpic-lookup.md index bd94b0d9e..36e5fd289 100644 --- a/docs/27-cpic-lookup.md +++ b/docs/27-cpic-lookup.md @@ -41,10 +41,10 @@ MEDICATIONS=/path/to/medications.txt ./scripts/27-cpic-lookup.sh your_name 2. Runs `og pgx cpic-report` in the Python image. It reads the gene calls (PharmCAT 3.x flat `genes` map, the 2.x map nested by source, and the older list are all read) and writes the phenotype table. 3. A gene counts as non-normal only when its phenotype names a changed metabolism or function (poor, intermediate, rapid or ultrarapid metabolizer; decreased, increased, poor or no function), a positive HLA test, a G6PD deficiency, malignant hyperthermia susceptibility, an increased MT-RNR1 risk, an ivacaftor-responsive CFTR, or a VKORC1 `-1639` genotype with the A allele (`-1639 GA` or `-1639 AA`, the warfarin dose-reduction case). A called gene whose phenotype is anything else (`n/a`, `no phenotype assigned`, the reference VKORC1 genotype `-1639 GG`, `Uncertain Susceptibility`, `Indeterminate`) is `unclassified`: it is listed in the section "Called Genes Without a Function Phenotype", is not counted, and gets no drug list. One exception: PharmCAT can leave a gene `Indeterminate` at gene level while the annotations of its drugs assign it a phenotype (for example a gene with unphased heterozygous positions plus positions missing from the VCF). When the drug annotations PharmCAT gives that gene (those for any of its possible diplotypes when there are any) all name the same phenotype, other than `Indeterminate`, `No Result` or `n/a`, the gene takes it, with the note `[gene level Indeterminate; phenotype from PharmCAT's drug annotations]` in the phenotype table and the text, and its status follows that phenotype. An annotation with no phenotype for the gene is not counted. Several possible diplotypes must also get the same drug guidance, because the drug list shows the first one's. With no annotation that names a phenotype, with annotations that disagree (one that says `Indeterminate` disagrees too), or with possible diplotypes whose guidance differs, it stays `Indeterminate` and `unclassified`. PharmCAT's own example report has 3 non-normal genes and 7 unclassified ones. For each gene with a non-normal phenotype it lists the drugs from the report's `drugs` section: CPIC's recommendation for the called diplotype per drug first, then the drugs DPWG or the FDA name. PharmCAT lists an annotation for every diplotype the sample may have, so only the ones for the called diplotype (or, without diplotype labels, its phenotype) are shown. When the report names no drug for the gene, it falls back to the gene's `relatedDrugs`, then to a small static table, and finally prints a line saying the gene is not in the drug table, so a gene is never skipped silently. 4. When PharmCAT lists more than one possible diplotype for a gene and their phenotypes differ (positions missing from the VCF leave it unable to choose), the gene is `ambiguous`: it is listed in its own section with the possible phenotypes and no drug guidance, never as its first diplotype. -5. With the pypgx summary it writes the comparison table and, for a gene PharmCAT reports as not called or ambiguous but pypgx called (CYP2D6 is the usual one), a warning in the recommendations naming every drug PharmCAT links to that gene. When pypgx's call is normal the line is a note instead. +5. With the pypgx summary it writes the comparison table and, for a gene PharmCAT reports as not called or ambiguous but pypgx called (CYP2D6 is the usual one; a pypgx `Indeterminate`, in any case or as one allele such as `*1/Indeterminate`, is no call), a warning in the recommendations naming every drug PharmCAT links to that gene. When pypgx's call is normal the line is a note instead. 6. With step 36's consensus table it writes a section "Calls From Other Tools": each gene passed to PharmCAT as an outside call, from which tool, and whether PharmCAT's report shows it as one (`callSource` `OUTSIDE`); and each gene held back, with the reason and what each caller said. For a held-back CYP2D6 it names the drugs CYP2D6 affects and says no guidance is given for them, and the pypgx-only warning of point 5 is not printed for it: one caller's call is what the consensus refused. Genes PharmCAT reports as outside calls carry `[outside call]` in the gene results. An outside call of CYP2D6, HLA-A or HLA-B in PharmCAT's report that the table does not pass on, with the same diplotype, comes from an earlier step 36 run that step 07 has not replaced: it gets no drug guidance, is listed as not called, and a warning says to rerun step 07. When the table is missing (a caller step ran again since) but PharmCAT's report has outside calls of those genes, the step passes the missing table, so none of them is confirmed. MT-RNR1's outside call comes from step 20's chrM calls through step 07, never from step 36: the table never lists it, so it is not checked against it and keeps its drug guidance. -7. With a medication list, each line is matched by its first word (a space, comma, semicolon, slash or plus ends a word, so `lopinavir/ritonavir` is matched as lopinavir; leading commas, semicolons, slashes and pluses are ignored, and a line of only those is skipped) against `assets/pgx_inhibitors.tsv`: the FDA's strong and moderate inhibitors of CYP2D6 and CYP2C19, its moderate CYP2C9 inhibitors (it lists no strong one) and its strong CYP3A inhibitors, one row each for CYP3A4 and CYP3A5, as the FDA's table of clinical CYP inhibitors classes them, each row with its source. A ritonavir-boosted combination the FDA classes as one (`lopinavir and ritonavir`) has a row under ritonavir and one under its partner. For CYP2D6 the step applies CPIC's rule from its opioid guideline: "for patients on strong CYP2D6 inhibitors, the CYP2D6 activity score is adjusted to 0 and the predicted phenotype is a poor metabolizer", and for a moderate inhibitor "the activity score is multiplied by 0.5 and then converted to the predicted phenotype" (CPIC's bands: 0 poor, under 1.25 intermediate, 1.25 to 2.25 normal, above 2.25 ultrarapid). The activity score is the one PharmCAT gives the called diplotype. With several inhibitors of one gene the strongest counts. The result is written as `Poor Metabolizer (phenoconverted by paroxetine)` beside the genotype phenotype, never in its place, with a `WARNING:` line in the section "Medications and Phenoconversion", so the summary carries it. Nothing is converted for a gene that is not called, ambiguous or unclassified, or for a moderate inhibitor when the report gives no activity score: the line says why. CPIC has no activity score for CYP2C19, and gives no rule that converts the phenotype of CYP2C9, CYP3A4 or CYP3A5, so an inhibitor of one of these genes gets a note and a `not computed: ...` value, with no converted phenotype. For a poor metabolizer of these genes (the most common CYP3A5 result) the note does not say the inhibitor can lower the activity further. A line that names no drug of the table is listed as "Not in the inhibitor table", never dropped. A list that names no drug converts nothing and leaves the phenotype table as it is without a list. An unreadable list or table is reported in that section; the rest of the report is written as usual. The FDA's table lists no strong or moderate CYP2B6 inhibitor, so CYP2B6 has no rows. -8. With step 06's ClinVar hits, each hit classed `Pathogenic` or `Likely_pathogenic` (one part of `CLNSIG`; a conflicting classification or `risk_factor` alone does not count) in a gene of `assets/pgx_contraindications.tsv` adds a line in the section "Drug Contraindications From Disease Variants" for each drug the table names for the gene, with the label's note, the provisional CPIC level and the label; a drug whose name is on your medication list is marked `ON THE MEDICATION LIST`. The table's `Report_if` column says when the line is a `WARNING:`. For POLG, OTC and HPRT1 (`any`) one variant gives it. For the recessive urea cycle genes ASL, ASS1, CPS1 and NAGS (`biallelic`) it needs a genotype with both copies changed (`1/1`, a hemizygous `1`, or `1/.` and `./1`, which step 06 writes for the two alleles of a `1/2` site: the missing copy holds the other allele, not the reference) or two distinct variants in the gene, and the line says which. The hits are not phased, so two variants on the same copy still give the warning. One heterozygous variant in such a gene makes a carrier: it gives a `NOTE:` line instead, which says so, and only `WARNING:` lines reach the summary. The table holds the CPIC gene-drug pairs at level A, B or A/B (CPIC API, queried 2026-11-03) whose gene is a disease gene PharmCAT does not call, whose drug the variant makes risky and whose risk a drug label names: POLG with valproic acid (the valproate label contraindicates it in POLG mitochondrial disorders), ASL, ASS1, CPS1, NAGS and OTC with valproic acid (the label contraindicates it in urea cycle disorders), and HPRT1 with mycophenolic acid (the label says to avoid it in hereditary HGPRT deficiency). Every one of these pairs is provisional in CPIC: no CPIC guideline covers it, and the line says so. SCN1A with carbamazepine and phenytoin is left out: no label or guideline names the gene, and SCN1A also has gain-of-function disease variants, for which a warning against these drugs does not follow. Without the hits table the section lists the table's genes as not checked. +7. With a medication list, every drug a line names is matched (whitespace, commas, semicolons, slashes and pluses split a line; the word `and` is dropped, and so are doses, units and frequencies such as `20`, `mg` and `daily`; so `olanzapine/fluoxetine` is checked for olanzapine and for fluoxetine, and a line of only separators is skipped) against `assets/pgx_inhibitors.tsv`: the FDA's strong and moderate inhibitors of CYP2D6 and CYP2C19, its moderate CYP2C9 inhibitors (it lists no strong one) and its strong CYP3A inhibitors, one row each for CYP3A4 and CYP3A5, as the FDA's table of clinical CYP inhibitors classes them, each row with its source. A ritonavir-boosted combination the FDA classes as one (`lopinavir and ritonavir`) has a row under ritonavir and one under its partner. For CYP2D6 the step applies CPIC's rule from its opioid guideline: "for patients on strong CYP2D6 inhibitors, the CYP2D6 activity score is adjusted to 0 and the predicted phenotype is a poor metabolizer", and for a moderate inhibitor "the activity score is multiplied by 0.5 and then converted to the predicted phenotype" (CPIC's bands: 0 poor, under 1.25 intermediate, 1.25 to 2.25 normal, above 2.25 ultrarapid). The activity score is the one PharmCAT gives the called diplotype. With several inhibitors of one gene, from several lines or from the drugs of one combination product, the strongest counts. The result is written as `Poor Metabolizer (phenoconverted by paroxetine)` beside the genotype phenotype, never in its place, with a `WARNING:` line in the section "Medications and Phenoconversion", so the summary carries it. Nothing is converted for a gene that is not called, ambiguous or unclassified, or for a moderate inhibitor when the report gives no activity score: the line says why. CPIC has no activity score for CYP2C19, and gives no rule that converts the phenotype of CYP2C9, CYP3A4 or CYP3A5, so an inhibitor of one of these genes gets a note and a `not computed: ...` value, with no converted phenotype. For a poor metabolizer of these genes (the most common CYP3A5 result) the note does not say the inhibitor can lower the activity further. A line none of whose drugs is in the table is listed as "Not in the inhibitor table", never dropped. A list that names no drug converts nothing and leaves the phenotype table as it is without a list. An unreadable list or table is reported in that section; the rest of the report is written as usual. The FDA's table lists no strong or moderate CYP2B6 inhibitor, so CYP2B6 has no rows. +8. With step 06's ClinVar hits, each hit classed `Pathogenic` or `Likely_pathogenic` (one part of `CLNSIG`; a conflicting classification or `risk_factor` alone does not count) in a gene of `assets/pgx_contraindications.tsv` adds a line in the section "Drug Contraindications From Disease Variants" for each drug the table names for the gene, with the label's note, the provisional CPIC level and the label; a drug whose name is on your medication list, as any drug of a line (the second drug of a combination product too), is marked `ON THE MEDICATION LIST`. The table's `Report_if` column says when the line is a `WARNING:`. For POLG, OTC and HPRT1 (`any`) one variant gives it. For the recessive urea cycle genes ASL, ASS1, CPS1 and NAGS (`biallelic`) it needs a genotype with both copies changed (`1/1`, a hemizygous `1`, or `1/.` and `./1`, which step 06 writes for the two alleles of a `1/2` site: the missing copy holds the other allele, not the reference) or two distinct variants in the gene, and the line says which. The hits are not phased, so two variants on the same copy still give the warning. One heterozygous variant in such a gene makes a carrier: it gives a `NOTE:` line instead, which says so, and only `WARNING:` lines reach the summary. The table holds the CPIC gene-drug pairs at level A, B or A/B (CPIC API, queried 2026-11-03) whose gene is a disease gene PharmCAT does not call, whose drug the variant makes risky and whose risk a drug label names: POLG with valproic acid (the valproate label contraindicates it in POLG mitochondrial disorders), ASL, ASS1, CPS1, NAGS and OTC with valproic acid (the label contraindicates it in urea cycle disorders), and HPRT1 with mycophenolic acid (the label says to avoid it in hereditary HGPRT deficiency). Every one of these pairs is provisional in CPIC: no CPIC guideline covers it, and the line says so. SCN1A with carbamazepine and phenytoin is left out: no label or guideline names the gene, and SCN1A also has gain-of-function disease variants, for which a warning against these drugs does not follow. Without the hits table the section lists the table's genes as not checked. 9. A report that cannot be read, or that yields no gene, writes a "PARSING FAILED" report and the step exits 1. It never writes an all-clear report from a format it could not read. A field of the report with an unexpected type (a number where a name belongs, say) reads as missing. 10. The `Date:` line of the recommendations is today's date in UTC. The output files are written under a temporary name and renamed into place, so a step that stops half way leaves no half-written table. diff --git a/rust/crates/og-pgx/src/cli.rs b/rust/crates/og-pgx/src/cli.rs index fa82d7a0b..eb729f57e 100644 --- a/rust/crates/og-pgx/src/cli.rs +++ b/rust/crates/og-pgx/src/cli.rs @@ -361,7 +361,7 @@ fn contraindication_section(a: &CpicArgs, table_path: &str) -> Vec { .medications .as_deref() .and_then(|m| read_medications(m).ok()) - .map(|m| m.into_iter().map(|m| m.name).collect()) + .map(|m| m.into_iter().flat_map(|m| m.names).collect()) .unwrap_or_default(); let found = contraindication_lines(&hits, &table, &med_names); if found.is_empty() { diff --git a/rust/crates/og-pgx/src/sections.rs b/rust/crates/og-pgx/src/sections.rs index 8bd5cd0b3..c7bc192a6 100644 --- a/rust/crates/og-pgx/src/sections.rs +++ b/rust/crates/og-pgx/src/sections.rs @@ -444,8 +444,9 @@ pub struct Phenoconversion { pub lines: Vec, } -/// Phenoconversion by an opt-in medication list. A line naming no drug of -/// the inhibitor table is listed as not checked. The genotype phenotype is +/// Phenoconversion by an opt-in medication list. Every drug of a line +/// counts, so a combination product converts by each of its drugs; a line +/// none of whose drugs is in the inhibitor table is listed as not checked. The genotype phenotype is /// never changed: the converted one sits beside it. With several inhibitors /// of one gene the strongest counts (CPIC gives no rule for combining them). /// @@ -465,11 +466,18 @@ pub fn phenoconversion( let mut unknown: Vec<&str> = Vec::new(); let mut names: Vec<&str> = Vec::new(); for m in meds { - if !inhibitors.keys().any(|(d, _)| *d == m.name) && !unknown.contains(&m.text.as_str()) { + // A line is unchecked only when none of its drugs is in the table. + let known = m + .names + .iter() + .any(|n| inhibitors.keys().any(|(d, _)| d == n)); + if !known && !unknown.contains(&m.text.as_str()) { unknown.push(&m.text); } - if !names.contains(&m.name.as_str()) { - names.push(&m.name); + for n in &m.names { + if !names.contains(&n.as_str()) { + names.push(n); + } } } for gene in PHENOCONVERSION_GENES { diff --git a/rust/crates/og-pgx/src/tables.rs b/rust/crates/og-pgx/src/tables.rs index 3a6bf2d2a..114b4e563 100644 --- a/rust/crates/og-pgx/src/tables.rs +++ b/rust/crates/og-pgx/src/tables.rs @@ -203,20 +203,37 @@ pub fn read_inhibitors(path: &str) -> Result { Ok(out) } -/// One line of a medication list: as written, and the drug it names. +/// One line of a medication list: as written, and every drug name in it. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Medication { pub text: String, - pub name: String, + /// The words of the line that can name a drug, lower case, in order, + /// each once. Never empty. + pub names: Vec, } -const DRUG_SEPARATORS: &str = " \t,;/+"; +/// Words of a medication line that name no drug: units, dose forms and how +/// often it is taken. +const DOSE_WORDS: &[&str] = &[ + "mg", "mcg", "µg", "ug", "g", "kg", "ml", "l", "iu", "unit", "units", "%", "tablet", "tablets", + "tab", "tabs", "capsule", "capsules", "cap", "caps", "er", "xr", "sr", "xl", "daily", "once", + "twice", "a", "day", "per", "weekly", "morning", "evening", "night", +]; + +/// A word that is a dose, a unit or a frequency, not a drug: it starts with +/// a digit or a point (`20`, `400mg`, `.5`), or it is one of the dose words. +fn dose_word(w: &str) -> bool { + w.starts_with(|c: char| c.is_ascii_digit() || c == '.') || DOSE_WORDS.contains(&w) +} -/// The lines of a medication list, one drug per line; `#` starts a comment -/// and blank lines are skipped. The name is the first word, lower case, so -/// a dose after it (`20 mg`) does not hide the drug. A slash or a plus also -/// ends a word, so `lopinavir/ritonavir` names lopinavir: the first drug of -/// a combination is the one checked. +/// The lines of a medication list, one product per line; `#` starts a +/// comment and blank lines are skipped. Every word of a line can name a +/// drug, so each drug of a combination product is checked: whitespace, +/// commas, semicolons, `/` and `+` split the line, and the word `and` is +/// dropped (`olanzapine/fluoxetine`, `naltrexone/bupropion 8/90 mg` and +/// `lopinavir and ritonavir` each name two drugs). Doses, units and +/// frequencies (`20`, `mg`, `daily`) are dropped too. A line of nothing +/// but those keeps its first word, so it is still listed as not checked. pub fn read_medications(path: &str) -> Result, PyErr> { let text = read_text(path)?; let mut out = Vec::new(); @@ -225,15 +242,26 @@ pub fn read_medications(path: &str) -> Result, PyErr> { if t.is_empty() { continue; } - let first = strip(t, Some(DRUG_SEPARATORS)) + let words: Vec = t .split(|c: char| pycompat::text::is_space(c) || ",;/+".contains(c)) - .next() - .unwrap_or(""); - let name = norm_drug(first); - if !name.is_empty() { + .filter(|w| !w.is_empty()) + .map(lower) + .collect(); + let mut names: Vec = Vec::new(); + for w in &words { + if w != "and" && !dose_word(w) && !names.contains(w) { + names.push(w.clone()); + } + } + if names.is_empty() + && let Some(first) = words.first() + { + names.push(first.clone()); + } + if !names.is_empty() { out.push(Medication { text: t.to_owned(), - name, + names, }); } } @@ -393,23 +421,37 @@ mod tests { } #[test] - fn medication_lines_name_their_first_drug() { + fn medication_lines_name_every_drug() { let p = tmp( "meds.txt", - "Paroxetine 20 mg daily\n, paroxetine\n;\n# a comment\n\nlopinavir/ritonavir 400/100 mg\r\nValproate # evening\n", + "Paroxetine 20 mg daily\n, paroxetine\n;\n# a comment\n\nlopinavir/ritonavir 400/100 mg\r\nValproate # evening\nnaltrexone/bupropion 8/90 mg\nOlanzapine + fluoxetine; olanzapine\nlopinavir and ritonavir\n20 mg\n", ); - let got: Vec<(String, String)> = read_medications(&p) + let got: Vec<(String, Vec)> = read_medications(&p) .unwrap() .into_iter() - .map(|m| (m.text, m.name)) + .map(|m| (m.text, m.names)) .collect(); - let want = [ - ("Paroxetine 20 mg daily", "paroxetine"), - (", paroxetine", "paroxetine"), - ("lopinavir/ritonavir 400/100 mg", "lopinavir"), - ("Valproate", "valproate"), + let want: [(&str, &[&str]); 8] = [ + ("Paroxetine 20 mg daily", &["paroxetine"]), + (", paroxetine", &["paroxetine"]), + ( + "lopinavir/ritonavir 400/100 mg", + &["lopinavir", "ritonavir"], + ), + ("Valproate", &["valproate"]), + ("naltrexone/bupropion 8/90 mg", &["naltrexone", "bupropion"]), + ( + "Olanzapine + fluoxetine; olanzapine", + &["olanzapine", "fluoxetine"], + ), + ("lopinavir and ritonavir", &["lopinavir", "ritonavir"]), + ("20 mg", &["20"]), ]; - assert_eq!(got, want.map(|(a, b)| (a.to_owned(), b.to_owned()))); + let want: Vec<(String, Vec)> = want + .iter() + .map(|(t, n)| ((*t).to_owned(), n.iter().map(|s| (*s).to_owned()).collect())) + .collect(); + assert_eq!(got, want); } #[test] diff --git a/rust/crates/og-pgx/tests/port_tests_pgx_cpic.rs b/rust/crates/og-pgx/tests/port_tests_pgx_cpic.rs index 08684f735..3472f13d8 100644 --- a/rust/crates/og-pgx/tests/port_tests_pgx_cpic.rs +++ b/rust/crates/og-pgx/tests/port_tests_pgx_cpic.rs @@ -2015,9 +2015,10 @@ fn cyp2c9_and_cyp3a5_inhibitors_give_a_note() { &meds("lopinavir/ritonavir 400/100 mg\n"), ); assert!( - cell(&r.rows, "CYP3A5", 4).starts_with("not computed: lopinavir inhibits CYP3A5") + cell(&r.rows, "CYP3A5", 4) + .starts_with("not computed: lopinavir, ritonavir inhibits CYP3A5") && !section(&r.rec).contains("Not in the inhibitor table"), - "a boosted combination written 'lopinavir/ritonavir' is matched as lopinavir" + "a boosted combination written 'lopinavir/ritonavir' is matched as both drugs" ); let r = run_report(&work, "PHENO2C9NONE", &rep, &meds("paroxetine\n")); assert!( From 5ce7535b87e2b41cfa3030e572de9843416412f8 Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Fri, 20 Nov 2026 22:55:07 +0100 Subject: [PATCH 03/14] test(pgx): pin Indeterminate as no call and every drug of a combination i411_pypgx_nocall.rs runs og pgx cpic-report: an Indeterminate pypgx CYP2D6 (any case, or as one allele) gives no comparison row and no warning, and an Indeterminate CYP2C9 is "PharmCAT only", never a mismatch; olanzapine/fluoxetine converts CYP2D6 by fluoxetine, naltrexone/bupropion 8/90 mg by bupropion and is not listed as unchecked, and the second drug of lamotrigine/valproate is marked on the medication list. Each case has a control that must not change. The pgx-parse pheno-boosted case now names both lopinavir and ritonavir as CYP3A4 and CYP3A5 inhibitors: its two outputs get goldens. Bead: pgx-06 Bead: pgx-30 Bead: pgx-16 --- rust/crates/og-pgx/tests/i411_pypgx_nocall.rs | 291 ++++++++++++++++++ .../PHENO_BOOSTED_cpic_recommendations.txt | 46 +++ .../out/PHENO_BOOSTED_phenotypes.tsv | 5 + 3 files changed, 342 insertions(+) create mode 100644 rust/crates/og-pgx/tests/i411_pypgx_nocall.rs create mode 100644 tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_cpic_recommendations.txt create mode 100644 tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_phenotypes.tsv diff --git a/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs b/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs new file mode 100644 index 000000000..ebd0968b4 --- /dev/null +++ b/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs @@ -0,0 +1,291 @@ +//! `og pgx cpic-report` with pypgx's `Indeterminate` and with combination +//! products on the medication list (issue #411, pgx-06, pgx-30, pgx-16): +//! +//! - pypgx writes `Indeterminate` for a gene it could not call, and step 32 +//! writes it for CYP2D6 when the depth check fails. In any case, and as +//! one allele (`*1/Indeterminate`), it is no call: a gene PharmCAT could +//! not call gets no comparison row and no warning, and a gene PharmCAT +//! did call is `PharmCAT only`, never a mismatch; +//! - every drug of a combination product is checked: `olanzapine/fluoxetine` +//! converts CYP2D6 by fluoxetine, `naltrexone/bupropion 8/90 mg` by +//! bupropion and is not listed as unchecked, and the second drug of a +//! combination is marked as on the medication list in the drug +//! contraindications. +//! +//! Each case has its control: a real pypgx call still warns, and a list +//! without the inhibitor converts nothing. + +use std::fs; +use std::path::PathBuf; + +const ASSETS: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../assets/"); + +struct Scratch(PathBuf); + +impl Scratch { + fn new(name: &str) -> Scratch { + let d = + std::env::temp_dir().join(format!("og-pgx-i411-nocall-{name}-{}", std::process::id())); + let _ = fs::remove_dir_all(&d); + fs::create_dir_all(&d).unwrap(); + Scratch(d) + } + + fn put(&self, name: &str, body: &str) -> String { + let p = self.0.join(name); + fs::write(&p, body).unwrap(); + p.to_string_lossy().into_owned() + } + + fn read(&self, name: &str) -> String { + fs::read_to_string(self.0.join(name)).unwrap_or_default() + } +} + +impl Drop for Scratch { + fn drop(&mut self) { + let _ = fs::remove_dir_all(&self.0); + } +} + +/// One gene of a PharmCAT 3.x report with a single diplotype. +fn gene(name: &str, a1: &str, a2: &str, phenotype: &str, score: Option<&str>) -> String { + let score = score.map_or_else(String::new, |s| format!(r#", "activityScore": "{s}""#)); + format!( + r#""{name}": {{"sourceDiplotypes": [{{"allele1": {{"name": "{a1}"}}, "allele2": {{"name": "{a2}"}}, "label": "{a1}/{a2}", "phenotypes": ["{phenotype}"]{score}}}], "relatedDrugs": [{{"name": "codeine"}}]}}"# + ) +} + +fn report(genes: &[String]) -> String { + format!( + r#"{{"pharmcatVersion": "3.4.0", "genes": {{{}}}}}"#, + genes.join(", ") + ) +} + +/// `og pgx cpic-report` on `report` with the extra options: (exit code, +/// recommendations text, phenotype rows, comparison rows). +fn run( + s: &Scratch, + report: &str, + extra: &[&str], +) -> (u8, String, Vec>, Vec>) { + let rep = s.put("report.json", report); + let out = s.0.join("out").to_string_lossy().into_owned(); + let mut args: Vec = [ + "cpic-report", + "--sample", + "S", + "--report", + &rep, + "--outdir", + &out, + "--date", + "2026-01-01", + ] + .map(str::to_owned) + .to_vec(); + args.extend(extra.iter().map(|a| (*a).to_owned())); + let rc = og_pgx::main(&args); + let rows = |text: String| -> Vec> { + text.lines() + .skip(1) + .map(|l| l.split('\t').map(str::to_owned).collect()) + .collect() + }; + ( + rc, + s.read("out/S_cpic_recommendations.txt"), + rows(s.read("out/S_phenotypes.tsv")), + rows(s.read("comparison.tsv")), + ) +} + +fn row<'a>(rows: &'a [Vec], gene: &str) -> Option<&'a Vec> { + rows.iter().find(|r| r.first().is_some_and(|g| g == gene)) +} + +/// CYP2D6 not called by PharmCAT, CYP2C9 called; pypgx's CYP2D6 and CYP2C9 +/// diplotypes as given. +fn pypgx_run(name: &str, cyp2d6: &str, cyp2c9: &str) -> (String, Vec>) { + let s = Scratch::new(name); + let rep = report(&[ + gene("CYP2D6", "Unknown", "Unknown", "No Result", None), + gene("CYP2C9", "*1", "*1", "Normal Metabolizer", None), + ]); + let pg = s.put( + "pypgx.tsv", + &format!( + "Gene\tDiplotype\tPhenotype\tCNV_call\tSource\nCYP2D6\t{cyp2d6}\tPoor Metabolizer\t.\tbam\nCYP2C9\t{cyp2c9}\tIndeterminate\t.\tvcf\n" + ), + ); + let comp = s.0.join("comparison.tsv").to_string_lossy().into_owned(); + let (rc, rec, _, comp) = run(&s, &rep, &["--pypgx", &pg, "--comparison", &comp]); + assert_eq!(rc, 0, "{rec}"); + (rec, comp) +} + +#[test] +fn indeterminate_pypgx_row_is_no_call() { + for indeterminate in [ + "Indeterminate", + "indeterminate", + "*1/Indeterminate", + "Indeterminate/Indeterminate", + ] { + let (rec, comp) = pypgx_run("indet", indeterminate, indeterminate); + assert!( + row(&comp, "CYP2D6").is_none(), + "{indeterminate}: no caller called CYP2D6, so no comparison row: {comp:?}" + ); + let c9 = row(&comp, "CYP2C9").expect("PharmCAT called CYP2C9"); + assert_eq!( + (c9[3].as_str(), c9[4].as_str()), + ("PharmCAT only", "PharmCAT only"), + "{indeterminate}: never a mismatch" + ); + assert!( + !rec.contains("pypgx (step 32) called") && !rec.contains("Drugs affected by CYP2D6"), + "{indeterminate}: no warning reads it as a pypgx call: {rec}" + ); + assert!( + rec.contains("No gene that PharmCAT could not call has a pypgx call."), + "{indeterminate}: {rec}" + ); + } +} + +#[test] +fn a_real_pypgx_call_still_warns() { + let (rec, comp) = pypgx_run("control", "*4/*4", "*1/*2"); + assert!( + rec.contains( + "WARNING: PharmCAT has no result for CYP2D6, but pypgx (step 32) called *4/*4 (Poor Metabolizer)." + ), + "{rec}" + ); + assert_eq!( + row(&comp, "CYP2D6").map(|r| r[3].as_str()), + Some("pypgx only") + ); + assert_eq!(row(&comp, "CYP2C9").map(|r| r[3].as_str()), Some("No")); +} + +/// The phenoconversion column of CYP2D6 and the recommendations text for a +/// CYP2D6 call and a medication list. +fn convert(name: &str, cyp2d6: &[&str; 4], meds: &str) -> (String, String) { + let s = Scratch::new(name); + let rep = report(&[gene( + "CYP2D6", + cyp2d6[0], + cyp2d6[1], + cyp2d6[2], + Some(cyp2d6[3]), + )]); + let list = s.put("meds.txt", meds); + let inh = format!("{ASSETS}pgx_inhibitors.tsv"); + let (rc, rec, rows, _) = run(&s, &rep, &["--medications", &list, "--inhibitors", &inh]); + assert_eq!(rc, 0, "{rec}"); + let col = row(&rows, "CYP2D6") + .and_then(|r| r.get(4).cloned()) + .unwrap_or_default(); + (col, rec) +} + +const POOR: [&str; 4] = ["*4", "*4", "Poor Metabolizer", "0.0"]; +const NORMAL: [&str; 4] = ["*1", "*1", "Normal Metabolizer", "2.0"]; + +#[test] +fn olanzapine_fluoxetine_is_checked_for_fluoxetine() { + let (col, rec) = convert("olafluo", &POOR, "olanzapine/fluoxetine 6/25 mg\n"); + assert_eq!( + col, "Poor Metabolizer (phenoconverted by fluoxetine)", + "{rec}" + ); + assert!(!rec.contains("Not in the inhibitor table"), "{rec}"); + // Control: the first drug alone inhibits nothing in the table. + let (col, rec) = convert("ola", &POOR, "olanzapine 5 mg\n"); + assert_eq!(col, "-", "{rec}"); + assert!( + rec.contains("Not in the inhibitor table: olanzapine 5 mg."), + "{rec}" + ); +} + +#[test] +fn naltrexone_bupropion_converts_by_bupropion() { + let (col, rec) = convert("nalbup", &NORMAL, "naltrexone/bupropion 8/90 mg\n"); + assert_eq!( + col, "Poor Metabolizer (phenoconverted by bupropion)", + "{rec}" + ); + assert!( + rec.contains( + "WARNING: CYP2D6 genotype phenotype Normal Metabolizer; phenoconverted phenotype Poor Metabolizer (phenoconverted by bupropion), activity score adjusted to 0." + ), + "{rec}" + ); + assert!(!rec.contains("Not in the inhibitor table"), "{rec}"); + // `and`, `+` and `;` split a line too. + for line in [ + "naltrexone and bupropion", + "naltrexone + bupropion", + "naltrexone; bupropion", + ] { + let (col, rec) = convert("nalbup2", &NORMAL, &format!("{line}\n")); + assert_eq!( + col, "Poor Metabolizer (phenoconverted by bupropion)", + "{line}: {rec}" + ); + } +} + +/// The contraindication section for one pathogenic POLG hit and a list. +fn contra(name: &str, meds: &str) -> String { + let s = Scratch::new(name); + let rep = report(&[gene( + "CYP2D6", + "*1", + "*1", + "Normal Metabolizer", + Some("2.0"), + )]); + let list = s.put("meds.txt", meds); + let hits = s.put( + "hits.tsv", + "chrom\tpos\tref\talt\tgenotype\tclinvar_id\tgeneinfo\tclnsig\tclnrevstat\nchr15\t89300000\tC\tT\t0/1\t1\tPOLG:1\tLikely_pathogenic\tx\n", + ); + let (inh, table) = ( + format!("{ASSETS}pgx_inhibitors.tsv"), + format!("{ASSETS}pgx_contraindications.tsv"), + ); + let (rc, rec, _, _) = run( + &s, + &rep, + &[ + "--medications", + &list, + "--inhibitors", + &inh, + "--contraindications", + &table, + "--clinvar-hits", + &hits, + ], + ); + assert_eq!(rc, 0, "{rec}"); + rec +} + +#[test] +fn a_combinations_second_drug_is_on_the_list() { + let want = " WARNING: valproic acid -- POLG chr15:89300000 C>T, genotype 0/1, ClinVar Likely_pathogenic; ON THE MEDICATION LIST."; + let rec = contra("contra", "lamotrigine/valproate 100/500 mg\n"); + assert!(rec.lines().any(|l| l == want), "{rec}"); + // Control: without valproate the same hit warns, not as on the list. + let rec = contra("contra-control", "lamotrigine 100 mg\n"); + assert!( + rec.contains("WARNING: valproic acid -- POLG") && !rec.contains("ON THE MEDICATION LIST"), + "{rec}" + ); +} diff --git a/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_cpic_recommendations.txt b/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_cpic_recommendations.txt new file mode 100644 index 000000000..3a4a5b002 --- /dev/null +++ b/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_cpic_recommendations.txt @@ -0,0 +1,46 @@ +Pharmacogenomic Drug Recommendations +===================================== +Sample: PHENO_BOOSTED +Date: 2026-11-20 +Source: PharmCAT 3.4.0 report (pheno-boosted.json) + +Gene Results: +------------------------------------------------------------------------ +Gene Diplotype Phenotype +CYP2D6 *1/*2 Normal Metabolizer +CYP2C19 *1/*1 Normal Metabolizer +CYP2C9 *1/*1 Normal Metabolizer +CYP3A5 *3/*3 Poor Metabolizer + +Medications and Phenoconversion (CYP2D6, CYP2C19, CYP2C9, CYP3A4, CYP3A5): +------------------------------------------------------------------------ + + Medication list: pheno-boosted.txt (1 line). + CYP3A4 -- on lopinavir (strong CYP3A4 inhibitor), ritonavir (strong CYP3A4 inhibitor): not converted, the report has no result for the gene, so there is no genotype phenotype to convert. + WARNING: CYP3A5 genotype phenotype Poor Metabolizer; on lopinavir (strong CYP3A5 inhibitor), ritonavir (strong CYP3A5 inhibitor). CPIC gives no rule that converts the CYP3A5 phenotype, so no converted phenotype is computed. + Drugs affected by CYP3A5: tacrolimus. + The genotype phenotype in the table above is unchanged. A phenoconverted phenotype + holds while the inhibitor is taken. This is an aid for your clinician, not advice. + +Affected Medications: +------------------------------------------------------------------------ + + CYP3A5 -- Poor Metabolizer: + Diplotype: *3/*3 + Drugs (pipeline fallback table; the report names none): tacrolimus + Action: Consult CPIC guidelines at https://cpicpgx.org/guidelines/ + +Uncallable Genes: +------------------------------------------------------------------------ + + None -- all genes were successfully called. + +NOTE: Uncallable genes may lack coverage, have complex structural +variants, or require data not present in your VCF. Their absence +from the recommendations section does NOT mean normal function. + +------------------------------------------------------------------------ +DISCLAIMER: These recommendations are based on CPIC clinical +guidelines. Always consult your healthcare provider before +making any medication changes. This is NOT medical advice. +------------------------------------------------------------------------ diff --git a/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_phenotypes.tsv b/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_phenotypes.tsv new file mode 100644 index 000000000..8ddf20614 --- /dev/null +++ b/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_phenotypes.tsv @@ -0,0 +1,5 @@ +Gene Diplotype Phenotype Status Phenoconverted_phenotype +CYP2D6 *1/*2 Normal Metabolizer normal - +CYP2C19 *1/*1 Normal Metabolizer normal - +CYP2C9 *1/*1 Normal Metabolizer normal - +CYP3A5 *3/*3 Poor Metabolizer non-normal not computed: lopinavir, ritonavir inhibits CYP3A5; CPIC gives no rule that converts the CYP3A5 phenotype From ba53e731f1d74f596680e7caccedceea902767dd Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Fri, 20 Nov 2026 22:55:07 +0100 Subject: [PATCH 04/14] docs(changelog): Indeterminate pypgx calls and combination products Bead: pgx-06 Bead: pgx-30 Bead: pgx-16 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 893fff178..7f5d4d600 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Each release's notes. From 1.0.0 on, a major or minor release has hand-written n ## Unreleased +- A pypgx `Indeterminate` call no longer counts as a call. Step 27 (`og pgx cpic-report`) read the word as a diplotype, so a gene PharmCAT could not call got a warning that pypgx "called Indeterminate", and the comparison table listed it as a pypgx call or a mismatch. Step 36 (`og pgx outside-calls`) and the summary read a diplotype with one `Indeterminate` allele, such as `*1/Indeterminate`, as a call that could disagree with Cyrius. Now `Indeterminate`, in any case and as any allele, is no call in all of them. The comparison table's Match and Called_by columns change for such a gene. +- Every drug of a combination product on the medication list is now checked. Step 27 read only the first word of a line, so `olanzapine/fluoxetine` was checked as olanzapine alone, and `naltrexone/bupropion 8/90 mg` was listed as not in the inhibitor table although bupropion is a strong CYP2D6 inhibitor. Now each word of a line counts: whitespace, commas, semicolons, `/` and `+` split it, and the word `and`, doses, units and frequencies are dropped. The phenoconversion takes the strongest inhibitor among all of them, a line is "Not in the inhibitor table" only when none of its drugs is, and a combination's second drug is marked `ON THE MEDICATION LIST` in the drug contraindications too. + - The live site's family page and its pedigree drawing are now built by `og live family`, in Rust. `bin/owngenome_live_family.py` asks `og` for a family's state, its `family.json`, the list of files it serves and `pedigree.svg`, and no longer reads the family's tables itself; `bin/pedigree_svg.py` and `bin/family_report.py` are gone. The page shows the same thing: `family.json` and the drawing were compared with the old code on the demo family and the test families, field by field and number by number, and matched. The live site therefore needs `og` (`scripts/setup.sh --og` installs it); without it a family's `family.json` answers 500, its `pedigree.svg` answers 503, and the run list marks each family unreadable. A family file that cannot be read still gives no page and an unreadable family. - The local genome viewer runs on `og` and no longer needs `python3` on the host. `scripts/owngenome-view.sh` starts `og view serve` (through `bin/og`, or `OG`), which serves the same page, config and byte ranges on 127.0.0.1 as `assets/viewer/serve.py` did. Two requests it answered before are now refused. A locus whose end comes before its start (`chr1:13000-12000`) stops the script with exit 2 and the reason, instead of opening a view igv.js cannot show. A request with a `Forwarded`, `X-Forwarded-*` or `X-Real-IP` header gets 403: the viewer has no password, so a reverse proxy in front of it would hand the sample to anyone who reaches the proxy; an ssh port forward still works. The default SV track is now Manta's diploid SVs (step 4), else step 22's consensus, which keeps only the calls two callers agree on. `docs/viewer.md` says that every account on the machine can reach 127.0.0.1. No option of the script, file or output name changes; `og view serve` takes the flags `serve.py` took, plus `--assets`, the page's folder. The live site's viewer also opens Manta's diploid SVs first; the rest of it is unchanged until its server moves to `og`. Part of #411 (plat-11, plat-12). - Step 22's SV consensus no longer counts a record a caller did not call as a second caller. Before, every PASS record went to SURVIVOR, so a PASS Delly record genotyped `0/0`, a Delly call whose sample filter (`FT`) says `LowQual`, or a CNVpytor segment no quality rule had read sat beside a Manta-only call and made it read "2 callers". A new verb, `og sv survivor-prep --caller NAME IN OUT`, now writes each caller's input for both the script and the Nextflow `SURVIVOR_PREP`, in place of the bcftools and awk they each carried. A record votes when its FILTER and its sample `FT` are `PASS` or `.` and its genotype is not reference only (`0/0`, `0|0`, haploid `0`, `0/.`); a no-call (`./.`) and a sites-only record still vote. A CNVpytor call votes when its e-value is below 0.01 and its share of MAPQ 0 reads below 0.5, the rule step 05 already applies when it adds CNVpytor's calls; the VCF step 22 makes from CNVpytor's table now carries the table's e-value, `q0` and `pN` as `pytorP1`, `pytorQ0` and `pytorPN`, so the rule reads both inputs. A header without `GT` or without these tags no longer matters. Step 18's closing hint and `docs/18-cnvpytor.md` gave e-value below 0.05 and size over 1 kb; they now give the same rule. What changes in the output: `sv_merged/inputs/.vcf` holds only the records that vote, and the consensus can hold fewer records. No file, column or option is renamed or removed. Part of #411 (sv-05, sv-06, sv-09, sv-10, sv-11, sv-40). From 6e071c50968be61380492fe57beab67949f8de37 Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:18:37 +0100 Subject: [PATCH 05/14] fix(pgx): match a drug written in brackets or before a stop A medication line split only on whitespace, commas, semicolons, / and +, so "Contrave (naltrexone/bupropion)" named "(naltrexone" and "bupropion)", "Epilim (sodium valproate)" named "valproate)" and "paroxetine." kept its stop: none matched the inhibitor or contraindication tables. Brackets now split a line and punctuation at either end of a word is dropped. Bead: pgx-16 --- CHANGELOG.md | 4 +-- docs/27-cpic-lookup.md | 2 +- rust/crates/og-pgx/src/tables.rs | 36 ++++++++++++++----- rust/crates/og-pgx/tests/i411_pypgx_nocall.rs | 13 ++++++- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5d4d600..f1b0b2591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ Each release's notes. From 1.0.0 on, a major or minor release has hand-written n ## Unreleased -- A pypgx `Indeterminate` call no longer counts as a call. Step 27 (`og pgx cpic-report`) read the word as a diplotype, so a gene PharmCAT could not call got a warning that pypgx "called Indeterminate", and the comparison table listed it as a pypgx call or a mismatch. Step 36 (`og pgx outside-calls`) and the summary read a diplotype with one `Indeterminate` allele, such as `*1/Indeterminate`, as a call that could disagree with Cyrius. Now `Indeterminate`, in any case and as any allele, is no call in all of them. The comparison table's Match and Called_by columns change for such a gene. -- Every drug of a combination product on the medication list is now checked. Step 27 read only the first word of a line, so `olanzapine/fluoxetine` was checked as olanzapine alone, and `naltrexone/bupropion 8/90 mg` was listed as not in the inhibitor table although bupropion is a strong CYP2D6 inhibitor. Now each word of a line counts: whitespace, commas, semicolons, `/` and `+` split it, and the word `and`, doses, units and frequencies are dropped. The phenoconversion takes the strongest inhibitor among all of them, a line is "Not in the inhibitor table" only when none of its drugs is, and a combination's second drug is marked `ON THE MEDICATION LIST` in the drug contraindications too. +- A pypgx `Indeterminate` call no longer counts as a call. Step 27 (`og pgx cpic-report`) read the word as a diplotype, so a gene PharmCAT could not call got a warning that pypgx "called Indeterminate", and the comparison table listed it as a pypgx call or a mismatch. Step 36 (`og pgx outside-calls`) and the summary's CYP2D6 block read a diplotype with one `Indeterminate` allele, such as `*1/Indeterminate`, as a call that could disagree with Cyrius. Now `Indeterminate`, in any case and as any allele, is no call in step 27, in step 36 and in the summary's CYP2D6 block. The comparison table's Match and Called_by columns change for such a gene. +- Every drug of a combination product on the medication list is now checked. Step 27 read only the first word of a line, so `olanzapine/fluoxetine` was checked as olanzapine alone, and `naltrexone/bupropion 8/90 mg` was listed as not in the inhibitor table although bupropion is a strong CYP2D6 inhibitor. Now each word of a line counts: whitespace, commas, semicolons, `/`, `+` and brackets split it, punctuation at either end of a word is dropped, and the word `and`, doses, units and frequencies are dropped, so `Contrave (naltrexone/bupropion) 8/90 mg` is checked for bupropion and `Epilim (sodium valproate)` for valproate. The phenoconversion takes the strongest inhibitor among all of them, a line is "Not in the inhibitor table" only when none of its drugs is, and a combination's second drug is marked `ON THE MEDICATION LIST` in the drug contraindications too. - The live site's family page and its pedigree drawing are now built by `og live family`, in Rust. `bin/owngenome_live_family.py` asks `og` for a family's state, its `family.json`, the list of files it serves and `pedigree.svg`, and no longer reads the family's tables itself; `bin/pedigree_svg.py` and `bin/family_report.py` are gone. The page shows the same thing: `family.json` and the drawing were compared with the old code on the demo family and the test families, field by field and number by number, and matched. The live site therefore needs `og` (`scripts/setup.sh --og` installs it); without it a family's `family.json` answers 500, its `pedigree.svg` answers 503, and the run list marks each family unreadable. A family file that cannot be read still gives no page and an unreadable family. - The local genome viewer runs on `og` and no longer needs `python3` on the host. `scripts/owngenome-view.sh` starts `og view serve` (through `bin/og`, or `OG`), which serves the same page, config and byte ranges on 127.0.0.1 as `assets/viewer/serve.py` did. Two requests it answered before are now refused. A locus whose end comes before its start (`chr1:13000-12000`) stops the script with exit 2 and the reason, instead of opening a view igv.js cannot show. A request with a `Forwarded`, `X-Forwarded-*` or `X-Real-IP` header gets 403: the viewer has no password, so a reverse proxy in front of it would hand the sample to anyone who reaches the proxy; an ssh port forward still works. The default SV track is now Manta's diploid SVs (step 4), else step 22's consensus, which keeps only the calls two callers agree on. `docs/viewer.md` says that every account on the machine can reach 127.0.0.1. No option of the script, file or output name changes; `og view serve` takes the flags `serve.py` took, plus `--assets`, the page's folder. The live site's viewer also opens Manta's diploid SVs first; the rest of it is unchanged until its server moves to `og`. Part of #411 (plat-11, plat-12). diff --git a/docs/27-cpic-lookup.md b/docs/27-cpic-lookup.md index 36e5fd289..68386bfdc 100644 --- a/docs/27-cpic-lookup.md +++ b/docs/27-cpic-lookup.md @@ -43,7 +43,7 @@ MEDICATIONS=/path/to/medications.txt ./scripts/27-cpic-lookup.sh your_name 4. When PharmCAT lists more than one possible diplotype for a gene and their phenotypes differ (positions missing from the VCF leave it unable to choose), the gene is `ambiguous`: it is listed in its own section with the possible phenotypes and no drug guidance, never as its first diplotype. 5. With the pypgx summary it writes the comparison table and, for a gene PharmCAT reports as not called or ambiguous but pypgx called (CYP2D6 is the usual one; a pypgx `Indeterminate`, in any case or as one allele such as `*1/Indeterminate`, is no call), a warning in the recommendations naming every drug PharmCAT links to that gene. When pypgx's call is normal the line is a note instead. 6. With step 36's consensus table it writes a section "Calls From Other Tools": each gene passed to PharmCAT as an outside call, from which tool, and whether PharmCAT's report shows it as one (`callSource` `OUTSIDE`); and each gene held back, with the reason and what each caller said. For a held-back CYP2D6 it names the drugs CYP2D6 affects and says no guidance is given for them, and the pypgx-only warning of point 5 is not printed for it: one caller's call is what the consensus refused. Genes PharmCAT reports as outside calls carry `[outside call]` in the gene results. An outside call of CYP2D6, HLA-A or HLA-B in PharmCAT's report that the table does not pass on, with the same diplotype, comes from an earlier step 36 run that step 07 has not replaced: it gets no drug guidance, is listed as not called, and a warning says to rerun step 07. When the table is missing (a caller step ran again since) but PharmCAT's report has outside calls of those genes, the step passes the missing table, so none of them is confirmed. MT-RNR1's outside call comes from step 20's chrM calls through step 07, never from step 36: the table never lists it, so it is not checked against it and keeps its drug guidance. -7. With a medication list, every drug a line names is matched (whitespace, commas, semicolons, slashes and pluses split a line; the word `and` is dropped, and so are doses, units and frequencies such as `20`, `mg` and `daily`; so `olanzapine/fluoxetine` is checked for olanzapine and for fluoxetine, and a line of only separators is skipped) against `assets/pgx_inhibitors.tsv`: the FDA's strong and moderate inhibitors of CYP2D6 and CYP2C19, its moderate CYP2C9 inhibitors (it lists no strong one) and its strong CYP3A inhibitors, one row each for CYP3A4 and CYP3A5, as the FDA's table of clinical CYP inhibitors classes them, each row with its source. A ritonavir-boosted combination the FDA classes as one (`lopinavir and ritonavir`) has a row under ritonavir and one under its partner. For CYP2D6 the step applies CPIC's rule from its opioid guideline: "for patients on strong CYP2D6 inhibitors, the CYP2D6 activity score is adjusted to 0 and the predicted phenotype is a poor metabolizer", and for a moderate inhibitor "the activity score is multiplied by 0.5 and then converted to the predicted phenotype" (CPIC's bands: 0 poor, under 1.25 intermediate, 1.25 to 2.25 normal, above 2.25 ultrarapid). The activity score is the one PharmCAT gives the called diplotype. With several inhibitors of one gene, from several lines or from the drugs of one combination product, the strongest counts. The result is written as `Poor Metabolizer (phenoconverted by paroxetine)` beside the genotype phenotype, never in its place, with a `WARNING:` line in the section "Medications and Phenoconversion", so the summary carries it. Nothing is converted for a gene that is not called, ambiguous or unclassified, or for a moderate inhibitor when the report gives no activity score: the line says why. CPIC has no activity score for CYP2C19, and gives no rule that converts the phenotype of CYP2C9, CYP3A4 or CYP3A5, so an inhibitor of one of these genes gets a note and a `not computed: ...` value, with no converted phenotype. For a poor metabolizer of these genes (the most common CYP3A5 result) the note does not say the inhibitor can lower the activity further. A line none of whose drugs is in the table is listed as "Not in the inhibitor table", never dropped. A list that names no drug converts nothing and leaves the phenotype table as it is without a list. An unreadable list or table is reported in that section; the rest of the report is written as usual. The FDA's table lists no strong or moderate CYP2B6 inhibitor, so CYP2B6 has no rows. +7. With a medication list, every drug a line names is matched (whitespace, commas, semicolons, slashes, pluses and brackets split a line, and punctuation at either end of a word is dropped; the word `and` is dropped, and so are doses, units and frequencies such as `20`, `mg` and `daily`; so `olanzapine/fluoxetine` is checked for olanzapine and for fluoxetine, `Contrave (naltrexone/bupropion) 8/90 mg` for contrave, naltrexone and bupropion, and a line of only separators is skipped) against `assets/pgx_inhibitors.tsv`: the FDA's strong and moderate inhibitors of CYP2D6 and CYP2C19, its moderate CYP2C9 inhibitors (it lists no strong one) and its strong CYP3A inhibitors, one row each for CYP3A4 and CYP3A5, as the FDA's table of clinical CYP inhibitors classes them, each row with its source. A ritonavir-boosted combination the FDA classes as one (`lopinavir and ritonavir`) has a row under ritonavir and one under its partner. For CYP2D6 the step applies CPIC's rule from its opioid guideline: "for patients on strong CYP2D6 inhibitors, the CYP2D6 activity score is adjusted to 0 and the predicted phenotype is a poor metabolizer", and for a moderate inhibitor "the activity score is multiplied by 0.5 and then converted to the predicted phenotype" (CPIC's bands: 0 poor, under 1.25 intermediate, 1.25 to 2.25 normal, above 2.25 ultrarapid). The activity score is the one PharmCAT gives the called diplotype. With several inhibitors of one gene, from several lines or from the drugs of one combination product, the strongest counts. The result is written as `Poor Metabolizer (phenoconverted by paroxetine)` beside the genotype phenotype, never in its place, with a `WARNING:` line in the section "Medications and Phenoconversion", so the summary carries it. Nothing is converted for a gene that is not called, ambiguous or unclassified, or for a moderate inhibitor when the report gives no activity score: the line says why. CPIC has no activity score for CYP2C19, and gives no rule that converts the phenotype of CYP2C9, CYP3A4 or CYP3A5, so an inhibitor of one of these genes gets a note and a `not computed: ...` value, with no converted phenotype. For a poor metabolizer of these genes (the most common CYP3A5 result) the note does not say the inhibitor can lower the activity further. A line none of whose drugs is in the table is listed as "Not in the inhibitor table", never dropped. A list that names no drug converts nothing and leaves the phenotype table as it is without a list. An unreadable list or table is reported in that section; the rest of the report is written as usual. The FDA's table lists no strong or moderate CYP2B6 inhibitor, so CYP2B6 has no rows. 8. With step 06's ClinVar hits, each hit classed `Pathogenic` or `Likely_pathogenic` (one part of `CLNSIG`; a conflicting classification or `risk_factor` alone does not count) in a gene of `assets/pgx_contraindications.tsv` adds a line in the section "Drug Contraindications From Disease Variants" for each drug the table names for the gene, with the label's note, the provisional CPIC level and the label; a drug whose name is on your medication list, as any drug of a line (the second drug of a combination product too), is marked `ON THE MEDICATION LIST`. The table's `Report_if` column says when the line is a `WARNING:`. For POLG, OTC and HPRT1 (`any`) one variant gives it. For the recessive urea cycle genes ASL, ASS1, CPS1 and NAGS (`biallelic`) it needs a genotype with both copies changed (`1/1`, a hemizygous `1`, or `1/.` and `./1`, which step 06 writes for the two alleles of a `1/2` site: the missing copy holds the other allele, not the reference) or two distinct variants in the gene, and the line says which. The hits are not phased, so two variants on the same copy still give the warning. One heterozygous variant in such a gene makes a carrier: it gives a `NOTE:` line instead, which says so, and only `WARNING:` lines reach the summary. The table holds the CPIC gene-drug pairs at level A, B or A/B (CPIC API, queried 2026-11-03) whose gene is a disease gene PharmCAT does not call, whose drug the variant makes risky and whose risk a drug label names: POLG with valproic acid (the valproate label contraindicates it in POLG mitochondrial disorders), ASL, ASS1, CPS1, NAGS and OTC with valproic acid (the label contraindicates it in urea cycle disorders), and HPRT1 with mycophenolic acid (the label says to avoid it in hereditary HGPRT deficiency). Every one of these pairs is provisional in CPIC: no CPIC guideline covers it, and the line says so. SCN1A with carbamazepine and phenytoin is left out: no label or guideline names the gene, and SCN1A also has gain-of-function disease variants, for which a warning against these drugs does not follow. Without the hits table the section lists the table's genes as not checked. 9. A report that cannot be read, or that yields no gene, writes a "PARSING FAILED" report and the step exits 1. It never writes an all-clear report from a format it could not read. A field of the report with an unexpected type (a number where a name belongs, say) reads as missing. 10. The `Date:` line of the recommendations is today's date in UTC. The output files are written under a temporary name and renamed into place, so a step that stops half way leaves no half-written table. diff --git a/rust/crates/og-pgx/src/tables.rs b/rust/crates/og-pgx/src/tables.rs index 114b4e563..710c20322 100644 --- a/rust/crates/og-pgx/src/tables.rs +++ b/rust/crates/og-pgx/src/tables.rs @@ -229,11 +229,14 @@ fn dose_word(w: &str) -> bool { /// The lines of a medication list, one product per line; `#` starts a /// comment and blank lines are skipped. Every word of a line can name a /// drug, so each drug of a combination product is checked: whitespace, -/// commas, semicolons, `/` and `+` split the line, and the word `and` is -/// dropped (`olanzapine/fluoxetine`, `naltrexone/bupropion 8/90 mg` and -/// `lopinavir and ritonavir` each name two drugs). Doses, units and -/// frequencies (`20`, `mg`, `daily`) are dropped too. A line of nothing -/// but those keeps its first word, so it is still listed as not checked. +/// commas, semicolons, `/`, `+` and brackets split the line, punctuation at +/// a word's ends is dropped (`paroxetine.` is paroxetine), and the word +/// `and` is dropped (`olanzapine/fluoxetine`, `naltrexone/bupropion 8/90 mg` +/// and `lopinavir and ritonavir` each name two drugs; `Contrave +/// (naltrexone/bupropion)` names three words). Doses, units and frequencies +/// (`20`, `mg`, `daily`) are dropped too. A line of nothing but those keeps +/// its first word, so it is still listed as not checked; a line of only +/// separators and punctuation is skipped. pub fn read_medications(path: &str) -> Result, PyErr> { let text = read_text(path)?; let mut out = Vec::new(); @@ -243,7 +246,8 @@ pub fn read_medications(path: &str) -> Result, PyErr> { continue; } let words: Vec = t - .split(|c: char| pycompat::text::is_space(c) || ",;/+".contains(c)) + .split(|c: char| pycompat::text::is_space(c) || ",;/+()[]".contains(c)) + .map(|w| w.trim_matches(|c: char| !c.is_alphanumeric())) .filter(|w| !w.is_empty()) .map(lower) .collect(); @@ -424,14 +428,14 @@ mod tests { fn medication_lines_name_every_drug() { let p = tmp( "meds.txt", - "Paroxetine 20 mg daily\n, paroxetine\n;\n# a comment\n\nlopinavir/ritonavir 400/100 mg\r\nValproate # evening\nnaltrexone/bupropion 8/90 mg\nOlanzapine + fluoxetine; olanzapine\nlopinavir and ritonavir\n20 mg\n", + "Paroxetine 20 mg daily\n, paroxetine\n;\n# a comment\n\nlopinavir/ritonavir 400/100 mg\r\nValproate # evening\nnaltrexone/bupropion 8/90 mg\nOlanzapine + fluoxetine; olanzapine\nlopinavir and ritonavir\n20 mg\nContrave (naltrexone/bupropion) 8/90 mg\nEpilim (sodium valproate) 500 mg\nDepakote(divalproex sodium) [delayed-release]\nparoxetine.\n( )\n", ); let got: Vec<(String, Vec)> = read_medications(&p) .unwrap() .into_iter() .map(|m| (m.text, m.names)) .collect(); - let want: [(&str, &[&str]); 8] = [ + let want: [(&str, &[&str]); 12] = [ ("Paroxetine 20 mg daily", &["paroxetine"]), (", paroxetine", &["paroxetine"]), ( @@ -446,6 +450,22 @@ mod tests { ), ("lopinavir and ritonavir", &["lopinavir", "ritonavir"]), ("20 mg", &["20"]), + // Brackets split a line, and punctuation at a word's ends is + // dropped, so a brand name with its generic in brackets names + // both, and a line of only brackets names nothing. + ( + "Contrave (naltrexone/bupropion) 8/90 mg", + &["contrave", "naltrexone", "bupropion"], + ), + ( + "Epilim (sodium valproate) 500 mg", + &["epilim", "sodium", "valproate"], + ), + ( + "Depakote(divalproex sodium) [delayed-release]", + &["depakote", "divalproex", "sodium", "delayed-release"], + ), + ("paroxetine.", &["paroxetine"]), ]; let want: Vec<(String, Vec)> = want .iter() diff --git a/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs b/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs index ebd0968b4..0e591b1a3 100644 --- a/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs +++ b/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs @@ -226,11 +226,14 @@ fn naltrexone_bupropion_converts_by_bupropion() { "{rec}" ); assert!(!rec.contains("Not in the inhibitor table"), "{rec}"); - // `and`, `+` and `;` split a line too. + // `and`, `+`, `;` and brackets split a line too, and a trailing stop + // is not part of the drug's name. for line in [ "naltrexone and bupropion", "naltrexone + bupropion", "naltrexone; bupropion", + "Contrave (naltrexone/bupropion) 8/90 mg", + "naltrexone, bupropion.", ] { let (col, rec) = convert("nalbup2", &NORMAL, &format!("{line}\n")); assert_eq!( @@ -282,6 +285,14 @@ fn a_combinations_second_drug_is_on_the_list() { let want = " WARNING: valproic acid -- POLG chr15:89300000 C>T, genotype 0/1, ClinVar Likely_pathogenic; ON THE MEDICATION LIST."; let rec = contra("contra", "lamotrigine/valproate 100/500 mg\n"); assert!(rec.lines().any(|l| l == want), "{rec}"); + // A brand name with its generic in brackets. + for line in [ + "Epilim (sodium valproate) 500 mg", + "Depakote (divalproex sodium)", + ] { + let rec = contra("contra-brand", &format!("{line}\n")); + assert!(rec.lines().any(|l| l == want), "{line}: {rec}"); + } // Control: without valproate the same hit warns, not as on the list. let rec = contra("contra-control", "lamotrigine 100 mg\n"); assert!( From 05cd1dcb7239c2bb4fa0714de2587021265b7993 Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:18:37 +0100 Subject: [PATCH 06/14] fix(pgx): say "inhibit" when a not-computed note names several drugs Bead: pgx-16 --- rust/crates/og-pgx/src/sections.rs | 7 ++++++- rust/crates/og-pgx/tests/port_tests_pgx_cpic.rs | 2 +- .../pheno-boosted/out/PHENO_BOOSTED_phenotypes.tsv | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/rust/crates/og-pgx/src/sections.rs b/rust/crates/og-pgx/src/sections.rs index c7bc192a6..fb1af5113 100644 --- a/rust/crates/og-pgx/src/sections.rs +++ b/rust/crates/og-pgx/src/sections.rs @@ -584,9 +584,14 @@ pub fn phenoconversion( format!("CPIC gives no rule that converts the {gene} phenotype") }; let inhibiting = hits.iter().map(|h| h.0).collect::>().join(", "); + let verb = if hits.len() > 1 { + "inhibit" + } else { + "inhibits" + }; column.insert( gene, - format!("not computed: {inhibiting} inhibits {gene}; {why}"), + format!("not computed: {inhibiting} {verb} {gene}; {why}"), ); let mut first = why.chars(); let why_cap: String = first diff --git a/rust/crates/og-pgx/tests/port_tests_pgx_cpic.rs b/rust/crates/og-pgx/tests/port_tests_pgx_cpic.rs index 3472f13d8..67aa9ff15 100644 --- a/rust/crates/og-pgx/tests/port_tests_pgx_cpic.rs +++ b/rust/crates/og-pgx/tests/port_tests_pgx_cpic.rs @@ -2016,7 +2016,7 @@ fn cyp2c9_and_cyp3a5_inhibitors_give_a_note() { ); assert!( cell(&r.rows, "CYP3A5", 4) - .starts_with("not computed: lopinavir, ritonavir inhibits CYP3A5") + .starts_with("not computed: lopinavir, ritonavir inhibit CYP3A5;") && !section(&r.rec).contains("Not in the inhibitor table"), "a boosted combination written 'lopinavir/ritonavir' is matched as both drugs" ); diff --git a/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_phenotypes.tsv b/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_phenotypes.tsv index 8ddf20614..e5dfce12a 100644 --- a/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_phenotypes.tsv +++ b/tests/parity/golden/pgx-parse/pheno-boosted/out/PHENO_BOOSTED_phenotypes.tsv @@ -2,4 +2,4 @@ Gene Diplotype Phenotype Status Phenoconverted_phenotype CYP2D6 *1/*2 Normal Metabolizer normal - CYP2C19 *1/*1 Normal Metabolizer normal - CYP2C9 *1/*1 Normal Metabolizer normal - -CYP3A5 *3/*3 Poor Metabolizer non-normal not computed: lopinavir, ritonavir inhibits CYP3A5; CPIC gives no rule that converts the CYP3A5 phenotype +CYP3A5 *3/*3 Poor Metabolizer non-normal not computed: lopinavir, ritonavir inhibit CYP3A5; CPIC gives no rule that converts the CYP3A5 phenotype From 86c2567461bbc35ffa8a5eb28ef502cc6f2e87f8 Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:09:40 +0100 Subject: [PATCH 07/14] test(summary): pin a half-indeterminate pypgx diplotype as not called summary.json's pypgx block counts a gene as called when its whole diplotype is not a no-call word, so *1/Indeterminate, a lone allele and several diplotypes count as called while steps 27 and 36 treat them as no call. These tests fail on the current collector. Bead: pgx-06 --- .../og-summary/tests/i411_pypgx_nocall_2.rs | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 rust/crates/og-summary/tests/i411_pypgx_nocall_2.rs diff --git a/rust/crates/og-summary/tests/i411_pypgx_nocall_2.rs b/rust/crates/og-summary/tests/i411_pypgx_nocall_2.rs new file mode 100644 index 000000000..d5586922a --- /dev/null +++ b/rust/crates/og-summary/tests/i411_pypgx_nocall_2.rs @@ -0,0 +1,95 @@ +//! summary.json's pypgx block counts a gene as called only when its +//! diplotype is a call by the rule steps 27 and 36 use +//! (`og_steps::pgx_rules::is_call`): a diplotype with one `Indeterminate` +//! allele, such as `*1/Indeterminate`, in any case, is no call, and so is +//! one that names no two alleles or several diplotypes. A real call still +//! counts (issue #411, pgx-06). + +use og_summary::collect::pgx::Pypgx; +use pycompat::json::Value; +use std::fs; +use std::path::PathBuf; + +const HEADER: &str = "Gene\tDiplotype\tPhenotype\tCNV_call\tSource\tStatus\tDefining_variants\tMin_GQ\tWeakest_variant\tDefining_filter\tQuality\n"; + +/// The pypgx summary of sample S with one row per (gene, diplotype), read +/// from a folder of its own. +fn read(tag: &str, rows: &[(&str, &str)]) -> Pypgx { + let d: PathBuf = std::env::temp_dir().join(format!( + "og-i411-pypgx-nocall-2-{}-{tag}", + std::process::id() + )); + let _ = fs::remove_dir_all(&d); + fs::create_dir_all(&d).unwrap(); + let mut body = HEADER.to_owned(); + for (gene, dip) in rows { + body.push_str(&format!("{gene}\t{dip}\t\t\tVCF\tok\t\t\t\t\tok\n")); + } + let path = d.join("S_pypgx_summary.tsv"); + fs::write(&path, body).unwrap(); + let got = Pypgx::read(path.to_str().unwrap(), "S").unwrap(); + fs::remove_dir_all(&d).unwrap(); + got +} + +fn called_in_json(p: &Pypgx) -> Value { + let Value::Object(m) = p.to_json() else { + panic!("the pypgx block is not an object") + }; + m["genes_called"].clone() +} + +#[test] +fn a_half_indeterminate_diplotype_is_not_a_called_gene() { + let p = read( + "half", + &[ + ("CYP2D6", "*1/Indeterminate"), + ("CYP2C9", "Indeterminate/*2"), + ("CYP2C19", "*1/indeterminate"), + ("UGT1A1", " *1/INDETERMINATE "), + ("CYP3A5", "Indeterminate/Indeterminate"), + ], + ); + assert_eq!(p.genes_total, 5); + assert_eq!(p.genes_called, 0); + assert_eq!(called_in_json(&p), Value::Int(0)); +} + +#[test] +fn a_real_call_still_counts_beside_the_no_calls() { + let p = read( + "mixed", + &[ + ("CYP2D6", "*1/Indeterminate"), + ("CYP2C19", "*1/*2"), + ("CYP2B6", " *1/*6 "), + ("UGT1A1", "Indeterminate"), + ("CYP2A6", "FAILED"), + ("CYP2E1", "."), + ("NUDT15", ""), + ], + ); + assert_eq!(p.genes_total, 7); + assert_eq!(p.genes_called, 2); + assert_eq!(called_in_json(&p), Value::Int(2)); + // the CYP2D6 diplotype itself is still shown as pypgx wrote it + assert_eq!(p.cyp2d6, "*1/Indeterminate"); +} + +#[test] +fn a_diplotype_the_steps_refuse_is_not_counted() { + // one allele, several diplotypes, and a missing allele are no call in + // steps 27 and 36, so the summary does not count them either + let p = read( + "refused", + &[ + ("CYP2D6", "*1"), + ("CYP2C9", "*1/*2;*1/*3"), + ("CYP2C19", "*1/"), + ("TPMT", "*1/*3A"), + ], + ); + assert_eq!(p.genes_total, 4); + assert_eq!(p.genes_called, 1); +} From f437b7d0ceae5ba80aef63d9e2265764994c557e Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:14:07 +0100 Subject: [PATCH 08/14] fix(summary): count a pypgx gene as called only when its diplotype is a call summary.json's pypgx genes_called now uses og_steps::pgx_rules::is_call, the rule steps 27 and 36 use, so *1/Indeterminate, a lone allele and several diplotypes no longer count as called genes. Bead: pgx-06 --- rust/crates/og-summary/src/collect/pgx.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust/crates/og-summary/src/collect/pgx.rs b/rust/crates/og-summary/src/collect/pgx.rs index c271384a6..5d900fac6 100644 --- a/rust/crates/og-summary/src/collect/pgx.rs +++ b/rust/crates/og-summary/src/collect/pgx.rs @@ -8,7 +8,7 @@ use super::model::{Section, State}; use super::sections::Data; use super::text::{self, cell, stripped}; use indexmap::IndexMap; -use og_steps::pgx_rules::{NO_CALL, is_call, same_diplotype}; +use og_steps::pgx_rules::{is_call, same_diplotype}; use og_steps::pypgx_summary::{LOW_GQ, NOT_CALLABLE}; use pycompat::csv::DictRow; use pycompat::json::Value; @@ -230,9 +230,11 @@ fn key_text(v: Option<&str>) -> String { impl Pypgx { pub fn read(path: &str, s: &str) -> Result { let rows = rows_or_note(path)?; + // A called gene is one whose diplotype steps 27 and 36 take as a + // call: `*1/Indeterminate`, one allele or several diplotypes are not. let called = rows .iter() - .filter(|r| !NO_CALL.contains(&lower(stripped(r, "Diplotype")).as_str())) + .filter(|r| is_call(stripped(r, "Diplotype"))) .count(); let cyp_row = rows.iter().find(|r| cell(r, "Gene") == Some("CYP2D6")); let cyp = cyp_row.and_then(|r| cell(r, "Diplotype")).unwrap_or(""); From aa0a6d2203b89c070686cb0fd0426f66d61833f9 Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:14:07 +0100 Subject: [PATCH 09/14] docs(pgx): say every word of a medication line is matched against Names The header of assets/pgx_contraindications.tsv still said the Names are the first words of a medication line. Comment only, no row changes. Bead: pgx-06 --- assets/pgx_contraindications.tsv | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/pgx_contraindications.tsv b/assets/pgx_contraindications.tsv index 4aee4d508..2de673460 100644 --- a/assets/pgx_contraindications.tsv +++ b/assets/pgx_contraindications.tsv @@ -14,8 +14,9 @@ # drugs does not follow). # Gene: the HGNC symbol, as ClinVar's GENEINFO writes it. # Drug: the drug as CPIC names it. -# Names: the first words a medication list may use for it, comma-separated, -# lower case; a drug on the list is marked in the report. +# Names: the words a medication list may use for it, comma-separated, lower +# case. Every word of a medication line is matched, the second drug of a +# combination product too; a drug on the list is marked in the report. # CPIC_level: the pair's CPIC level, printed as provisional. # Note: what the label says. # Label_source: the FDA label (DailyMed) the note quotes. From 7eee1f67a49c9bd8f2ea0bccd667537b52a57537 Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:14:55 +0100 Subject: [PATCH 10/14] test(pgx): pin a hyphenated combination as checked for each drug olanzapine-fluoxetine and naltrexone-bupropion stay one word, so their inhibitor is missed and the line is listed as not checked. The new tests fail on that. Two controls: a hyphenated name of the table still matches whole, and a prefix, a lone letter or a number never hits. Bead: pgx-06 --- rust/crates/og-pgx/tests/i411_pypgx_nocall.rs | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs b/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs index 0e591b1a3..49c22a2d8 100644 --- a/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs +++ b/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs @@ -300,3 +300,83 @@ fn a_combinations_second_drug_is_on_the_list() { "{rec}" ); } + +// --- a combination written with a hyphen ------------------------------------ + +/// `convert` with an inhibitor table of the given CYP2D6 drugs, each a +/// strong inhibitor; the rows are invented for the test. +fn convert_with(name: &str, drugs: &[&str], meds: &str) -> (String, String) { + let s = Scratch::new(name); + let rep = report(&[gene("CYP2D6", "*1", "*1", "Normal Metabolizer", Some("2.0"))]); + let list = s.put("meds.txt", meds); + let mut table = + "Drug\tGene\tStrength\tActivity_score_factor\tClass_source\tRule_source\n".to_owned(); + for d in drugs { + table.push_str(&format!("{d}\tCYP2D6\tstrong\t0\tx\tx\n")); + } + let inh = s.put("inhibitors.tsv", &table); + let (rc, rec, rows, _) = run(&s, &rep, &["--medications", &list, "--inhibitors", &inh]); + assert_eq!(rc, 0, "{rec}"); + let col = row(&rows, "CYP2D6") + .and_then(|r| r.get(4).cloned()) + .unwrap_or_default(); + (col, rec) +} + +#[test] +fn a_hyphenated_combination_is_checked_for_each_drug() { + let (col, rec) = convert("olafluo-hyphen", &POOR, "olanzapine-fluoxetine 6/25 mg\n"); + assert_eq!( + col, "Poor Metabolizer (phenoconverted by fluoxetine)", + "{rec}" + ); + assert!(!rec.contains("Not in the inhibitor table"), "{rec}"); + let (col, rec) = convert("nalbup-hyphen", &NORMAL, "Naltrexone-Bupropion 8/90 mg\n"); + assert_eq!( + col, "Poor Metabolizer (phenoconverted by bupropion)", + "{rec}" + ); + assert!(!rec.contains("Not in the inhibitor table"), "{rec}"); + // The second drug of a hyphenated combination is on the list for the + // drug contraindications too. + let want = " WARNING: valproic acid -- POLG chr15:89300000 C>T, genotype 0/1, ClinVar Likely_pathogenic; ON THE MEDICATION LIST."; + let rec = contra("contra-hyphen", "lamotrigine-valproate 100/500 mg\n"); + assert!(rec.lines().any(|l| l == want), "{rec}"); +} + +#[test] +fn a_hyphenated_drug_name_of_the_table_still_matches_whole() { + let (col, rec) = convert_with("whole", &["co-trimoxazole"], "Co-trimoxazole 960 mg\n"); + assert_eq!( + col, "Poor Metabolizer (phenoconverted by co-trimoxazole)", + "{rec}" + ); + // A control, green before and after hyphen parts were added: the + // whole name matches, and its parts add nothing. + assert!( + rec.contains( + "WARNING: CYP2D6 genotype phenotype Normal Metabolizer; phenoconverted phenotype Poor Metabolizer (phenoconverted by co-trimoxazole), activity score adjusted to 0." + ) && !rec.contains("Not in the inhibitor table"), + "{rec}" + ); +} + +#[test] +fn a_hyphen_part_gives_no_false_hit() { + // With the shipped table none of these names an inhibitor, whole or by + // its parts, so each line stays unchecked. + for line in ["co-trimoxazole 960 mg", "L-dopa 100 mg", "L 5 mg", "5-HTP 100 mg"] { + let (col, rec) = convert("parts", &NORMAL, &format!("{line}\n")); + assert_eq!(col, "-", "{line}: {rec}"); + assert!( + rec.contains(&format!("Not in the inhibitor table: {line}.")), + "{line}: {rec}" + ); + } + // A prefix, a lone letter and a number are never drugs: a table that + // lists them as names still gives no hit for these lines. + for line in ["co-trimoxazole 960 mg", "L-dopa 100 mg", "5-HTP 100 mg"] { + let (col, rec) = convert_with("short-parts", &["co", "l", "5"], &format!("{line}\n")); + assert_eq!(col, "-", "{line}: {rec}"); + } +} From 21af407b39479870be7244c268e71e660e1f0227 Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:15:55 +0100 Subject: [PATCH 11/14] fix(pgx): check each drug of a hyphenated combination product olanzapine-fluoxetine and naltrexone-bupropion stayed one word, so the inhibitor was missed and the line was listed as not checked. A hyphenated word now names itself first, so a hyphenated table name still matches whole, then each part that starts with a letter, has three or more characters and is no dose word, so co, l and 5 of co-trimoxazole, L-dopa and 5-HTP never count as drugs. A unit test checks that no name of the shipped tables is a part of another one. Bead: pgx-06 --- rust/crates/og-pgx/src/tables.rs | 80 +++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 6 deletions(-) diff --git a/rust/crates/og-pgx/src/tables.rs b/rust/crates/og-pgx/src/tables.rs index 710c20322..f9dcb4f13 100644 --- a/rust/crates/og-pgx/src/tables.rs +++ b/rust/crates/og-pgx/src/tables.rs @@ -226,6 +226,20 @@ fn dose_word(w: &str) -> bool { w.starts_with(|c: char| c.is_ascii_digit() || c == '.') || DOSE_WORDS.contains(&w) } +/// The parts of a hyphenated word that can name a drug, in order: each part +/// that starts with a letter, has three or more characters and is no dose +/// word. `olanzapine-fluoxetine` gives olanzapine and fluoxetine; the `co` +/// of `co-trimoxazole`, the `l` of `l-dopa` and the `5` of `5-htp` are +/// never drugs, so they give nothing. A word without a hyphen has no parts. +fn hyphen_parts(w: &str) -> impl Iterator { + w.split('-').filter(move |p| { + *p != w + && p.chars().count() >= 3 + && p.starts_with(char::is_alphabetic) + && !dose_word(p) + }) +} + /// The lines of a medication list, one product per line; `#` starts a /// comment and blank lines are skipped. Every word of a line can name a /// drug, so each drug of a combination product is checked: whitespace, @@ -234,7 +248,12 @@ fn dose_word(w: &str) -> bool { /// `and` is dropped (`olanzapine/fluoxetine`, `naltrexone/bupropion 8/90 mg` /// and `lopinavir and ritonavir` each name two drugs; `Contrave /// (naltrexone/bupropion)` names three words). Doses, units and frequencies -/// (`20`, `mg`, `daily`) are dropped too. A line of nothing but those keeps +/// (`20`, `mg`, `daily`) are dropped too. A hyphenated word names itself +/// first, so a hyphenated name of a table still matches whole, then its +/// parts (`hyphen_parts`), so `olanzapine-fluoxetine` is checked for +/// fluoxetine. A part is only a name: it hits only when it is itself a name +/// of a table, and no table name is a part of another one (a test checks +/// the shipped tables). A line of nothing but those keeps /// its first word, so it is still listed as not checked; a line of only /// separators and punctuation is skipped. pub fn read_medications(path: &str) -> Result, PyErr> { @@ -253,8 +272,13 @@ pub fn read_medications(path: &str) -> Result, PyErr> { .collect(); let mut names: Vec = Vec::new(); for w in &words { - if w != "and" && !dose_word(w) && !names.contains(w) { - names.push(w.clone()); + if w == "and" || dose_word(w) { + continue; + } + for n in std::iter::once(w.as_str()).chain(hyphen_parts(w)) { + if !names.iter().any(|m| m == n) { + names.push(n.to_owned()); + } } } if names.is_empty() @@ -428,14 +452,14 @@ mod tests { fn medication_lines_name_every_drug() { let p = tmp( "meds.txt", - "Paroxetine 20 mg daily\n, paroxetine\n;\n# a comment\n\nlopinavir/ritonavir 400/100 mg\r\nValproate # evening\nnaltrexone/bupropion 8/90 mg\nOlanzapine + fluoxetine; olanzapine\nlopinavir and ritonavir\n20 mg\nContrave (naltrexone/bupropion) 8/90 mg\nEpilim (sodium valproate) 500 mg\nDepakote(divalproex sodium) [delayed-release]\nparoxetine.\n( )\n", + "Paroxetine 20 mg daily\n, paroxetine\n;\n# a comment\n\nlopinavir/ritonavir 400/100 mg\r\nValproate # evening\nnaltrexone/bupropion 8/90 mg\nOlanzapine + fluoxetine; olanzapine\nlopinavir and ritonavir\n20 mg\nContrave (naltrexone/bupropion) 8/90 mg\nEpilim (sodium valproate) 500 mg\nDepakote(divalproex sodium) [delayed-release]\nparoxetine.\nolanzapine-fluoxetine 6/25 mg\nCo-trimoxazole 960 mg\nL-dopa 100 mg\n5-HTP 100 mg\n( )\n", ); let got: Vec<(String, Vec)> = read_medications(&p) .unwrap() .into_iter() .map(|m| (m.text, m.names)) .collect(); - let want: [(&str, &[&str]); 12] = [ + let want: [(&str, &[&str]); 16] = [ ("Paroxetine 20 mg daily", &["paroxetine"]), (", paroxetine", &["paroxetine"]), ( @@ -463,9 +487,25 @@ mod tests { ), ( "Depakote(divalproex sodium) [delayed-release]", - &["depakote", "divalproex", "sodium", "delayed-release"], + &[ + "depakote", + "divalproex", + "sodium", + "delayed-release", + "delayed", + "release", + ], ), ("paroxetine.", &["paroxetine"]), + // A hyphenated word names itself, then each part that can name + // a drug: never a prefix, a lone letter or a number. + ( + "olanzapine-fluoxetine 6/25 mg", + &["olanzapine-fluoxetine", "olanzapine", "fluoxetine"], + ), + ("Co-trimoxazole 960 mg", &["co-trimoxazole", "trimoxazole"]), + ("L-dopa 100 mg", &["l-dopa", "dopa"]), + ("5-HTP 100 mg", &["5-htp"]), ]; let want: Vec<(String, Vec)> = want .iter() @@ -474,6 +514,34 @@ mod tests { assert_eq!(got, want); } + /// The names of `names` that are a hyphen part of another of them. + fn part_clashes(names: &[String]) -> Vec { + names + .iter() + .flat_map(|n| hyphen_parts(n).filter(|p| names.iter().any(|m| m == p))) + .map(str::to_owned) + .collect() + } + + #[test] + fn no_table_name_is_a_hyphen_part_of_another() { + // A hyphen part of a medication word is checked even when the whole + // word is a table name; that adds no hit only while no name of the + // tables is a part of another one. + let root = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../assets/"); + let inh = read_inhibitors(&format!("{root}pgx_inhibitors.tsv")).unwrap(); + let contra = read_contraindications(&format!("{root}pgx_contraindications.tsv")).unwrap(); + let mut names: Vec = inh.keys().map(|(d, _)| d.clone()).collect(); + for r in &contra { + names.extend(r.names.split(',').map(norm_drug).filter(|n| !n.is_empty())); + } + assert!(names.len() > 40, "{names:?}"); + assert_eq!(part_clashes(&names), Vec::::new()); + // Control: a planted clash is found. + let planted = ["co-trimoxazole".to_owned(), "trimoxazole".to_owned()]; + assert_eq!(part_clashes(&planted), ["trimoxazole"]); + } + #[test] fn indeterminate_is_no_pypgx_call() { for d in ["*1/*4", " *1/*1 ", "Reference/rs9923231"] { From 9927826b8cd07f45bdd6052da11fb344d16b69fd Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 14:15:55 +0100 Subject: [PATCH 12/14] docs(pgx): hyphenated combinations and the pypgx called-gene count Step 27's medication matching now names hyphen parts, and summary.json counts a pypgx gene as called only when its diplotype is a call. Bead: pgx-06 --- CHANGELOG.md | 4 ++-- docs/27-cpic-lookup.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1b0b2591..a4465c8be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ Each release's notes. From 1.0.0 on, a major or minor release has hand-written n ## Unreleased -- A pypgx `Indeterminate` call no longer counts as a call. Step 27 (`og pgx cpic-report`) read the word as a diplotype, so a gene PharmCAT could not call got a warning that pypgx "called Indeterminate", and the comparison table listed it as a pypgx call or a mismatch. Step 36 (`og pgx outside-calls`) and the summary's CYP2D6 block read a diplotype with one `Indeterminate` allele, such as `*1/Indeterminate`, as a call that could disagree with Cyrius. Now `Indeterminate`, in any case and as any allele, is no call in step 27, in step 36 and in the summary's CYP2D6 block. The comparison table's Match and Called_by columns change for such a gene. -- Every drug of a combination product on the medication list is now checked. Step 27 read only the first word of a line, so `olanzapine/fluoxetine` was checked as olanzapine alone, and `naltrexone/bupropion 8/90 mg` was listed as not in the inhibitor table although bupropion is a strong CYP2D6 inhibitor. Now each word of a line counts: whitespace, commas, semicolons, `/`, `+` and brackets split it, punctuation at either end of a word is dropped, and the word `and`, doses, units and frequencies are dropped, so `Contrave (naltrexone/bupropion) 8/90 mg` is checked for bupropion and `Epilim (sodium valproate)` for valproate. The phenoconversion takes the strongest inhibitor among all of them, a line is "Not in the inhibitor table" only when none of its drugs is, and a combination's second drug is marked `ON THE MEDICATION LIST` in the drug contraindications too. +- A pypgx `Indeterminate` call no longer counts as a call. Step 27 (`og pgx cpic-report`) read the word as a diplotype, so a gene PharmCAT could not call got a warning that pypgx "called Indeterminate", and the comparison table listed it as a pypgx call or a mismatch. Step 36 (`og pgx outside-calls`) and the summary's CYP2D6 block read a diplotype with one `Indeterminate` allele, such as `*1/Indeterminate`, as a call that could disagree with Cyrius. Now `Indeterminate`, in any case and as any allele, is no call in step 27, in step 36 and in the summary's CYP2D6 block. The comparison table's Match and Called_by columns change for such a gene. The pypgx block of `summary.json` counts a gene in `genes_called` only when its diplotype is a call by the same rule, so `*1/Indeterminate`, a lone allele and several diplotypes are no longer counted. +- Every drug of a combination product on the medication list is now checked. Step 27 read only the first word of a line, so `olanzapine/fluoxetine` was checked as olanzapine alone, and `naltrexone/bupropion 8/90 mg` was listed as not in the inhibitor table although bupropion is a strong CYP2D6 inhibitor. Now each word of a line counts: whitespace, commas, semicolons, `/`, `+` and brackets split it, punctuation at either end of a word is dropped, and the word `and`, doses, units and frequencies are dropped. A hyphenated word counts whole and by each part of three or more characters that starts with a letter, so `olanzapine-fluoxetine` is checked for fluoxetine while the `co` of `co-trimoxazole`, the `L` of `L-dopa` and the `5` of `5-HTP` never count as drugs. So `Contrave (naltrexone/bupropion) 8/90 mg` is checked for bupropion and `Epilim (sodium valproate)` for valproate. The phenoconversion takes the strongest inhibitor among all of them, a line is "Not in the inhibitor table" only when none of its drugs is, and a combination's second drug is marked `ON THE MEDICATION LIST` in the drug contraindications too. - The live site's family page and its pedigree drawing are now built by `og live family`, in Rust. `bin/owngenome_live_family.py` asks `og` for a family's state, its `family.json`, the list of files it serves and `pedigree.svg`, and no longer reads the family's tables itself; `bin/pedigree_svg.py` and `bin/family_report.py` are gone. The page shows the same thing: `family.json` and the drawing were compared with the old code on the demo family and the test families, field by field and number by number, and matched. The live site therefore needs `og` (`scripts/setup.sh --og` installs it); without it a family's `family.json` answers 500, its `pedigree.svg` answers 503, and the run list marks each family unreadable. A family file that cannot be read still gives no page and an unreadable family. - The local genome viewer runs on `og` and no longer needs `python3` on the host. `scripts/owngenome-view.sh` starts `og view serve` (through `bin/og`, or `OG`), which serves the same page, config and byte ranges on 127.0.0.1 as `assets/viewer/serve.py` did. Two requests it answered before are now refused. A locus whose end comes before its start (`chr1:13000-12000`) stops the script with exit 2 and the reason, instead of opening a view igv.js cannot show. A request with a `Forwarded`, `X-Forwarded-*` or `X-Real-IP` header gets 403: the viewer has no password, so a reverse proxy in front of it would hand the sample to anyone who reaches the proxy; an ssh port forward still works. The default SV track is now Manta's diploid SVs (step 4), else step 22's consensus, which keeps only the calls two callers agree on. `docs/viewer.md` says that every account on the machine can reach 127.0.0.1. No option of the script, file or output name changes; `og view serve` takes the flags `serve.py` took, plus `--assets`, the page's folder. The live site's viewer also opens Manta's diploid SVs first; the rest of it is unchanged until its server moves to `og`. Part of #411 (plat-11, plat-12). diff --git a/docs/27-cpic-lookup.md b/docs/27-cpic-lookup.md index 68386bfdc..362748bb7 100644 --- a/docs/27-cpic-lookup.md +++ b/docs/27-cpic-lookup.md @@ -43,7 +43,7 @@ MEDICATIONS=/path/to/medications.txt ./scripts/27-cpic-lookup.sh your_name 4. When PharmCAT lists more than one possible diplotype for a gene and their phenotypes differ (positions missing from the VCF leave it unable to choose), the gene is `ambiguous`: it is listed in its own section with the possible phenotypes and no drug guidance, never as its first diplotype. 5. With the pypgx summary it writes the comparison table and, for a gene PharmCAT reports as not called or ambiguous but pypgx called (CYP2D6 is the usual one; a pypgx `Indeterminate`, in any case or as one allele such as `*1/Indeterminate`, is no call), a warning in the recommendations naming every drug PharmCAT links to that gene. When pypgx's call is normal the line is a note instead. 6. With step 36's consensus table it writes a section "Calls From Other Tools": each gene passed to PharmCAT as an outside call, from which tool, and whether PharmCAT's report shows it as one (`callSource` `OUTSIDE`); and each gene held back, with the reason and what each caller said. For a held-back CYP2D6 it names the drugs CYP2D6 affects and says no guidance is given for them, and the pypgx-only warning of point 5 is not printed for it: one caller's call is what the consensus refused. Genes PharmCAT reports as outside calls carry `[outside call]` in the gene results. An outside call of CYP2D6, HLA-A or HLA-B in PharmCAT's report that the table does not pass on, with the same diplotype, comes from an earlier step 36 run that step 07 has not replaced: it gets no drug guidance, is listed as not called, and a warning says to rerun step 07. When the table is missing (a caller step ran again since) but PharmCAT's report has outside calls of those genes, the step passes the missing table, so none of them is confirmed. MT-RNR1's outside call comes from step 20's chrM calls through step 07, never from step 36: the table never lists it, so it is not checked against it and keeps its drug guidance. -7. With a medication list, every drug a line names is matched (whitespace, commas, semicolons, slashes, pluses and brackets split a line, and punctuation at either end of a word is dropped; the word `and` is dropped, and so are doses, units and frequencies such as `20`, `mg` and `daily`; so `olanzapine/fluoxetine` is checked for olanzapine and for fluoxetine, `Contrave (naltrexone/bupropion) 8/90 mg` for contrave, naltrexone and bupropion, and a line of only separators is skipped) against `assets/pgx_inhibitors.tsv`: the FDA's strong and moderate inhibitors of CYP2D6 and CYP2C19, its moderate CYP2C9 inhibitors (it lists no strong one) and its strong CYP3A inhibitors, one row each for CYP3A4 and CYP3A5, as the FDA's table of clinical CYP inhibitors classes them, each row with its source. A ritonavir-boosted combination the FDA classes as one (`lopinavir and ritonavir`) has a row under ritonavir and one under its partner. For CYP2D6 the step applies CPIC's rule from its opioid guideline: "for patients on strong CYP2D6 inhibitors, the CYP2D6 activity score is adjusted to 0 and the predicted phenotype is a poor metabolizer", and for a moderate inhibitor "the activity score is multiplied by 0.5 and then converted to the predicted phenotype" (CPIC's bands: 0 poor, under 1.25 intermediate, 1.25 to 2.25 normal, above 2.25 ultrarapid). The activity score is the one PharmCAT gives the called diplotype. With several inhibitors of one gene, from several lines or from the drugs of one combination product, the strongest counts. The result is written as `Poor Metabolizer (phenoconverted by paroxetine)` beside the genotype phenotype, never in its place, with a `WARNING:` line in the section "Medications and Phenoconversion", so the summary carries it. Nothing is converted for a gene that is not called, ambiguous or unclassified, or for a moderate inhibitor when the report gives no activity score: the line says why. CPIC has no activity score for CYP2C19, and gives no rule that converts the phenotype of CYP2C9, CYP3A4 or CYP3A5, so an inhibitor of one of these genes gets a note and a `not computed: ...` value, with no converted phenotype. For a poor metabolizer of these genes (the most common CYP3A5 result) the note does not say the inhibitor can lower the activity further. A line none of whose drugs is in the table is listed as "Not in the inhibitor table", never dropped. A list that names no drug converts nothing and leaves the phenotype table as it is without a list. An unreadable list or table is reported in that section; the rest of the report is written as usual. The FDA's table lists no strong or moderate CYP2B6 inhibitor, so CYP2B6 has no rows. +7. With a medication list, every drug a line names is matched (whitespace, commas, semicolons, slashes, pluses and brackets split a line, and punctuation at either end of a word is dropped; the word `and` is dropped, and so are doses, units and frequencies such as `20`, `mg` and `daily`; a word with a hyphen is checked whole and then by each part that starts with a letter, has three or more characters and is no dose word, so a hyphenated name in a table still matches and a prefix, a lone letter or a number is never taken for a drug; so `olanzapine/fluoxetine` and `olanzapine-fluoxetine` are checked for olanzapine and for fluoxetine, `Contrave (naltrexone/bupropion) 8/90 mg` for contrave, naltrexone and bupropion, `co-trimoxazole` for co-trimoxazole and trimoxazole but never `co`, `L-dopa` for l-dopa and dopa, and a line of only separators is skipped) against `assets/pgx_inhibitors.tsv`: the FDA's strong and moderate inhibitors of CYP2D6 and CYP2C19, its moderate CYP2C9 inhibitors (it lists no strong one) and its strong CYP3A inhibitors, one row each for CYP3A4 and CYP3A5, as the FDA's table of clinical CYP inhibitors classes them, each row with its source. A ritonavir-boosted combination the FDA classes as one (`lopinavir and ritonavir`) has a row under ritonavir and one under its partner. For CYP2D6 the step applies CPIC's rule from its opioid guideline: "for patients on strong CYP2D6 inhibitors, the CYP2D6 activity score is adjusted to 0 and the predicted phenotype is a poor metabolizer", and for a moderate inhibitor "the activity score is multiplied by 0.5 and then converted to the predicted phenotype" (CPIC's bands: 0 poor, under 1.25 intermediate, 1.25 to 2.25 normal, above 2.25 ultrarapid). The activity score is the one PharmCAT gives the called diplotype. With several inhibitors of one gene, from several lines or from the drugs of one combination product, the strongest counts. The result is written as `Poor Metabolizer (phenoconverted by paroxetine)` beside the genotype phenotype, never in its place, with a `WARNING:` line in the section "Medications and Phenoconversion", so the summary carries it. Nothing is converted for a gene that is not called, ambiguous or unclassified, or for a moderate inhibitor when the report gives no activity score: the line says why. CPIC has no activity score for CYP2C19, and gives no rule that converts the phenotype of CYP2C9, CYP3A4 or CYP3A5, so an inhibitor of one of these genes gets a note and a `not computed: ...` value, with no converted phenotype. For a poor metabolizer of these genes (the most common CYP3A5 result) the note does not say the inhibitor can lower the activity further. A line none of whose drugs is in the table is listed as "Not in the inhibitor table", never dropped. A list that names no drug converts nothing and leaves the phenotype table as it is without a list. An unreadable list or table is reported in that section; the rest of the report is written as usual. The FDA's table lists no strong or moderate CYP2B6 inhibitor, so CYP2B6 has no rows. 8. With step 06's ClinVar hits, each hit classed `Pathogenic` or `Likely_pathogenic` (one part of `CLNSIG`; a conflicting classification or `risk_factor` alone does not count) in a gene of `assets/pgx_contraindications.tsv` adds a line in the section "Drug Contraindications From Disease Variants" for each drug the table names for the gene, with the label's note, the provisional CPIC level and the label; a drug whose name is on your medication list, as any drug of a line (the second drug of a combination product too), is marked `ON THE MEDICATION LIST`. The table's `Report_if` column says when the line is a `WARNING:`. For POLG, OTC and HPRT1 (`any`) one variant gives it. For the recessive urea cycle genes ASL, ASS1, CPS1 and NAGS (`biallelic`) it needs a genotype with both copies changed (`1/1`, a hemizygous `1`, or `1/.` and `./1`, which step 06 writes for the two alleles of a `1/2` site: the missing copy holds the other allele, not the reference) or two distinct variants in the gene, and the line says which. The hits are not phased, so two variants on the same copy still give the warning. One heterozygous variant in such a gene makes a carrier: it gives a `NOTE:` line instead, which says so, and only `WARNING:` lines reach the summary. The table holds the CPIC gene-drug pairs at level A, B or A/B (CPIC API, queried 2026-11-03) whose gene is a disease gene PharmCAT does not call, whose drug the variant makes risky and whose risk a drug label names: POLG with valproic acid (the valproate label contraindicates it in POLG mitochondrial disorders), ASL, ASS1, CPS1, NAGS and OTC with valproic acid (the label contraindicates it in urea cycle disorders), and HPRT1 with mycophenolic acid (the label says to avoid it in hereditary HGPRT deficiency). Every one of these pairs is provisional in CPIC: no CPIC guideline covers it, and the line says so. SCN1A with carbamazepine and phenytoin is left out: no label or guideline names the gene, and SCN1A also has gain-of-function disease variants, for which a warning against these drugs does not follow. Without the hits table the section lists the table's genes as not checked. 9. A report that cannot be read, or that yields no gene, writes a "PARSING FAILED" report and the step exits 1. It never writes an all-clear report from a format it could not read. A field of the report with an unexpected type (a number where a name belongs, say) reads as missing. 10. The `Date:` line of the recommendations is today's date in UTC. The output files are written under a temporary name and renamed into place, so a step that stops half way leaves no half-written table. From fbd915e51169d16d0ab931ad897ee8cb0bc5615e Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 15:09:29 +0100 Subject: [PATCH 13/14] style(pgx): rustfmt the hyphen-part change and its tests Bead: pgx-06 --- rust/crates/og-pgx/src/tables.rs | 5 +---- rust/crates/og-pgx/tests/i411_pypgx_nocall.rs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/rust/crates/og-pgx/src/tables.rs b/rust/crates/og-pgx/src/tables.rs index f9dcb4f13..8fe0c5e0c 100644 --- a/rust/crates/og-pgx/src/tables.rs +++ b/rust/crates/og-pgx/src/tables.rs @@ -233,10 +233,7 @@ fn dose_word(w: &str) -> bool { /// never drugs, so they give nothing. A word without a hyphen has no parts. fn hyphen_parts(w: &str) -> impl Iterator { w.split('-').filter(move |p| { - *p != w - && p.chars().count() >= 3 - && p.starts_with(char::is_alphabetic) - && !dose_word(p) + *p != w && p.chars().count() >= 3 && p.starts_with(char::is_alphabetic) && !dose_word(p) }) } diff --git a/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs b/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs index 49c22a2d8..d7e82ea4c 100644 --- a/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs +++ b/rust/crates/og-pgx/tests/i411_pypgx_nocall.rs @@ -307,7 +307,13 @@ fn a_combinations_second_drug_is_on_the_list() { /// strong inhibitor; the rows are invented for the test. fn convert_with(name: &str, drugs: &[&str], meds: &str) -> (String, String) { let s = Scratch::new(name); - let rep = report(&[gene("CYP2D6", "*1", "*1", "Normal Metabolizer", Some("2.0"))]); + let rep = report(&[gene( + "CYP2D6", + "*1", + "*1", + "Normal Metabolizer", + Some("2.0"), + )]); let list = s.put("meds.txt", meds); let mut table = "Drug\tGene\tStrength\tActivity_score_factor\tClass_source\tRule_source\n".to_owned(); @@ -365,7 +371,12 @@ fn a_hyphenated_drug_name_of_the_table_still_matches_whole() { fn a_hyphen_part_gives_no_false_hit() { // With the shipped table none of these names an inhibitor, whole or by // its parts, so each line stays unchecked. - for line in ["co-trimoxazole 960 mg", "L-dopa 100 mg", "L 5 mg", "5-HTP 100 mg"] { + for line in [ + "co-trimoxazole 960 mg", + "L-dopa 100 mg", + "L 5 mg", + "5-HTP 100 mg", + ] { let (col, rec) = convert("parts", &NORMAL, &format!("{line}\n")); assert_eq!(col, "-", "{line}: {rec}"); assert!( From 44e6accc37d34e231f2dda25fb9fe65f2295dbbc Mon Sep 17 00:00:00 2001 From: GeiserX <9169332+GeiserX@users.noreply.github.com> Date: Sat, 21 Nov 2026 16:07:21 +0100 Subject: [PATCH 14/14] docs(pgx): name step 32's Status column as the rule the summary shares Bead: pgx-06 --- CHANGELOG.md | 2 +- rust/crates/og-summary/src/collect/pgx.rs | 6 ++++-- rust/crates/og-summary/tests/i411_pypgx_nocall_2.rs | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4465c8be..369b7a9a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Each release's notes. From 1.0.0 on, a major or minor release has hand-written n ## Unreleased -- A pypgx `Indeterminate` call no longer counts as a call. Step 27 (`og pgx cpic-report`) read the word as a diplotype, so a gene PharmCAT could not call got a warning that pypgx "called Indeterminate", and the comparison table listed it as a pypgx call or a mismatch. Step 36 (`og pgx outside-calls`) and the summary's CYP2D6 block read a diplotype with one `Indeterminate` allele, such as `*1/Indeterminate`, as a call that could disagree with Cyrius. Now `Indeterminate`, in any case and as any allele, is no call in step 27, in step 36 and in the summary's CYP2D6 block. The comparison table's Match and Called_by columns change for such a gene. The pypgx block of `summary.json` counts a gene in `genes_called` only when its diplotype is a call by the same rule, so `*1/Indeterminate`, a lone allele and several diplotypes are no longer counted. +- A pypgx `Indeterminate` call no longer counts as a call. Step 27 (`og pgx cpic-report`) read the word as a diplotype, so a gene PharmCAT could not call got a warning that pypgx "called Indeterminate", and the comparison table listed it as a pypgx call or a mismatch. Step 36 (`og pgx outside-calls`) and the summary's CYP2D6 block read a diplotype with one `Indeterminate` allele, such as `*1/Indeterminate`, as a call that could disagree with Cyrius. Now `Indeterminate`, in any case and as any allele, is no call in step 27, in step 36 and in the summary's CYP2D6 block. The comparison table's Match and Called_by columns change for such a gene. The pypgx block of `summary.json` counts a gene in `genes_called` only when its diplotype is a call by the rule step 32's Status column uses, so `*1/Indeterminate`, a lone allele and several diplotypes are no longer counted. - Every drug of a combination product on the medication list is now checked. Step 27 read only the first word of a line, so `olanzapine/fluoxetine` was checked as olanzapine alone, and `naltrexone/bupropion 8/90 mg` was listed as not in the inhibitor table although bupropion is a strong CYP2D6 inhibitor. Now each word of a line counts: whitespace, commas, semicolons, `/`, `+` and brackets split it, punctuation at either end of a word is dropped, and the word `and`, doses, units and frequencies are dropped. A hyphenated word counts whole and by each part of three or more characters that starts with a letter, so `olanzapine-fluoxetine` is checked for fluoxetine while the `co` of `co-trimoxazole`, the `L` of `L-dopa` and the `5` of `5-HTP` never count as drugs. So `Contrave (naltrexone/bupropion) 8/90 mg` is checked for bupropion and `Epilim (sodium valproate)` for valproate. The phenoconversion takes the strongest inhibitor among all of them, a line is "Not in the inhibitor table" only when none of its drugs is, and a combination's second drug is marked `ON THE MEDICATION LIST` in the drug contraindications too. - The live site's family page and its pedigree drawing are now built by `og live family`, in Rust. `bin/owngenome_live_family.py` asks `og` for a family's state, its `family.json`, the list of files it serves and `pedigree.svg`, and no longer reads the family's tables itself; `bin/pedigree_svg.py` and `bin/family_report.py` are gone. The page shows the same thing: `family.json` and the drawing were compared with the old code on the demo family and the test families, field by field and number by number, and matched. The live site therefore needs `og` (`scripts/setup.sh --og` installs it); without it a family's `family.json` answers 500, its `pedigree.svg` answers 503, and the run list marks each family unreadable. A family file that cannot be read still gives no page and an unreadable family. diff --git a/rust/crates/og-summary/src/collect/pgx.rs b/rust/crates/og-summary/src/collect/pgx.rs index 5d900fac6..0445bbd35 100644 --- a/rust/crates/og-summary/src/collect/pgx.rs +++ b/rust/crates/og-summary/src/collect/pgx.rs @@ -230,8 +230,10 @@ fn key_text(v: Option<&str>) -> String { impl Pypgx { pub fn read(path: &str, s: &str) -> Result { let rows = rows_or_note(path)?; - // A called gene is one whose diplotype steps 27 and 36 take as a - // call: `*1/Indeterminate`, one allele or several diplotypes are not. + // A called gene is one whose diplotype is a call by + // `og_steps::pgx_rules::is_call`, the rule of step 32's Status column + // and of step 36: `*1/Indeterminate`, one allele or several + // diplotypes are not. let called = rows .iter() .filter(|r| is_call(stripped(r, "Diplotype"))) diff --git a/rust/crates/og-summary/tests/i411_pypgx_nocall_2.rs b/rust/crates/og-summary/tests/i411_pypgx_nocall_2.rs index d5586922a..528c93a75 100644 --- a/rust/crates/og-summary/tests/i411_pypgx_nocall_2.rs +++ b/rust/crates/og-summary/tests/i411_pypgx_nocall_2.rs @@ -1,6 +1,6 @@ //! summary.json's pypgx block counts a gene as called only when its -//! diplotype is a call by the rule steps 27 and 36 use -//! (`og_steps::pgx_rules::is_call`): a diplotype with one `Indeterminate` +//! diplotype is a call by `og_steps::pgx_rules::is_call`, the rule of +//! step 32's Status column and of step 36: a diplotype with one `Indeterminate` //! allele, such as `*1/Indeterminate`, in any case, is no call, and so is //! one that names no two alleles or several diplotypes. A real call still //! counts (issue #411, pgx-06). @@ -79,8 +79,8 @@ fn a_real_call_still_counts_beside_the_no_calls() { #[test] fn a_diplotype_the_steps_refuse_is_not_counted() { - // one allele, several diplotypes, and a missing allele are no call in - // steps 27 and 36, so the summary does not count them either + // one allele, several diplotypes, and a missing allele are no call by + // step 32's Status column and step 36, so the summary does not count them let p = read( "refused", &[