RBCeq2 2.4.4__tar.gz → 2.4.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. {rbceq2-2.4.4 → rbceq2-2.4.5}/CITATION.cff +4 -4
  2. {rbceq2-2.4.4/src/rbceq2.egg-info → rbceq2-2.4.5}/PKG-INFO +84 -12
  3. {rbceq2-2.4.4 → rbceq2-2.4.5}/README.md +83 -11
  4. {rbceq2-2.4.4 → rbceq2-2.4.5}/pyproject.toml +1 -1
  5. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/IO/PDF_reports.py +143 -22
  6. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/IO/record_data.py +97 -16
  7. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/IO/vcf.py +562 -22
  8. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/core_logic/alleles.py +2 -2
  9. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/core_logic/constants.py +359 -52
  10. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/core_logic/data_procesing.py +297 -3
  11. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/core_logic/large_variants.py +71 -6
  12. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/filters/geno.py +19 -6
  13. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/main.py +132 -7
  14. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/phenotype/antigens.py +6 -0
  15. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/resources/db.tsv +92 -93
  16. {rbceq2-2.4.4 → rbceq2-2.4.5/src/rbceq2.egg-info}/PKG-INFO +84 -12
  17. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2.egg-info/SOURCES.txt +16 -0
  18. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_VCF.py +1 -1
  19. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_alleles.py +1 -3
  20. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_ants.py +18 -0
  21. rbceq2-2.4.5/tests/test_gvcf.py +311 -0
  22. rbceq2-2.4.5/tests/test_gvcf_block_filter.py +218 -0
  23. rbceq2-2.4.5/tests/test_gvcf_block_safety.py +142 -0
  24. rbceq2-2.4.5/tests/test_gvcf_blocks.py +213 -0
  25. rbceq2-2.4.5/tests/test_gvcf_phased_end_to_end.py +271 -0
  26. rbceq2-2.4.5/tests/test_gvcf_strict.py +318 -0
  27. rbceq2-2.4.5/tests/test_lane_reference_assumptions.py +94 -0
  28. rbceq2-2.4.5/tests/test_lu_reference_fallback.py +238 -0
  29. rbceq2-2.4.5/tests/test_pdf_undetermined_class.py +144 -0
  30. rbceq2-2.4.5/tests/test_placeholder_row_selection.py +210 -0
  31. rbceq2-2.4.5/tests/test_reader_block_fast_path.py +110 -0
  32. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_record_data.py +6 -0
  33. rbceq2-2.4.5/tests/test_strict_fallback_guards.py +283 -0
  34. rbceq2-2.4.5/tests/test_strict_uncalled_locus_warning.py +175 -0
  35. rbceq2-2.4.5/tests/test_strict_weak_reference_warning.py +232 -0
  36. rbceq2-2.4.5/tests/test_sv_row_event_rule.py +133 -0
  37. rbceq2-2.4.5/tests/test_unused_variants_table.py +422 -0
  38. {rbceq2-2.4.4 → rbceq2-2.4.5}/LICENSE +0 -0
  39. {rbceq2-2.4.4 → rbceq2-2.4.5}/MANIFEST.in +0 -0
  40. {rbceq2-2.4.4 → rbceq2-2.4.5}/setup.cfg +0 -0
  41. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/IO/__init__.py +0 -0
  42. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/IO/encoders.py +0 -0
  43. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/IO/validation.py +0 -0
  44. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/__init__.py +0 -0
  45. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/core_logic/__init__.py +0 -0
  46. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/core_logic/co_existing.py +0 -0
  47. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/core_logic/filter_semantics.py +0 -0
  48. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/core_logic/utils.py +0 -0
  49. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/db/__init__.py +0 -0
  50. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/db/db.py +0 -0
  51. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/filters/__init__.py +0 -0
  52. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/filters/knops.py +0 -0
  53. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/filters/phased.py +0 -0
  54. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/filters/shared_filter_functionality.py +0 -0
  55. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/phenotype/__init__.py +0 -0
  56. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/phenotype/choose_pheno.py +0 -0
  57. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2/resources/filter_values.tsv +0 -0
  58. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2.egg-info/dependency_links.txt +0 -0
  59. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2.egg-info/entry_points.txt +0 -0
  60. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2.egg-info/requires.txt +0 -0
  61. {rbceq2-2.4.4 → rbceq2-2.4.5}/src/rbceq2.egg-info/top_level.txt +0 -0
  62. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_IO.py +0 -0
  63. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_allele_coverage.py +0 -0
  64. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_choose_pheno.py +0 -0
  65. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_co_filters.py +0 -0
  66. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_coexisting.py +0 -0
  67. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_data_processing.py +0 -0
  68. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_db.py +0 -0
  69. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_deletion_phase_seed.py +0 -0
  70. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_deletion_placement.py +0 -0
  71. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_duplicate_row_agreement.py +0 -0
  72. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_filter_semantics.py +0 -0
  73. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_filters_phase.py +0 -0
  74. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_fut3_secretor.py +0 -0
  75. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_fy_null_token.py +0 -0
  76. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_geno_filters.py +0 -0
  77. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_large_variants.py +0 -0
  78. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_locus_copies.py +0 -0
  79. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_main.py +0 -0
  80. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_multiallelic.py +0 -0
  81. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_pdf.py +0 -0
  82. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_phase_evidence.py +0 -0
  83. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_phase_flip_invariance.py +0 -0
  84. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_phase_set_provenance.py +0 -0
  85. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_ploidy.py +0 -0
  86. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_sv_build_selection.py +0 -0
  87. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_sv_match_ambiguity.py +0 -0
  88. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_sv_match_ties.py +0 -0
  89. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_sv_provenance.py +0 -0
  90. {rbceq2-2.4.4 → rbceq2-2.4.5}/tests/test_utils.py +0 -0
@@ -30,10 +30,10 @@ authors:
30
30
  orcid: "https://orcid.org/0000-0001-6824-5432"
31
31
  affiliation: "Australian Red Cross Lifeblood"
32
32
  title: "RBCeq2"
33
- version: 2.4.4
34
- date-released: 2026-09-16
35
- url: "https://github.com/liammcintyre/RBCeq2"
36
- repository-code: "https://github.com/liammcintyre/RBCeq2.git"
33
+ version: 2.4.5
34
+ date-released: 2026-11-30
35
+ url: "https://github.com/limcintyre/RBCeq2"
36
+ repository-code: "https://github.com/limcintyre/RBCeq2.git"
37
37
  license: MIT
38
38
  keywords: [bioinformatics, blood-group, genomics]
39
39
  type: software
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rbceq2
3
- Version: 2.4.4
3
+ Version: 2.4.5
4
4
  Summary: Call ISBT alleles from VCF/s
5
5
  Author-email: Liam McIntyre <limcintyre@redcrossblood.org.au>
6
6
  License-Expression: MIT
@@ -39,7 +39,7 @@ Dynamic: license-file
39
39
  > [!WARNING]
40
40
  > NOT FOR CLINICAL USE
41
41
 
42
- ## Version v2.4.4
42
+ ## Version v2.4.5
43
43
 
44
44
  RBCeq2 infers blood-group genotypes and phenotypes from supplied variant calls using
45
45
  the curated ISBT allele definitions distributed with the package. Deterministic
@@ -51,7 +51,7 @@ and named exclusions behind the result.
51
51
  Python 3.12 or newer is required.
52
52
 
53
53
  ```bash
54
- python -m pip install rbceq2==2.4.4
54
+ python -m pip install rbceq2==2.4.5
55
55
  rbceq2 --version
56
56
  rbceq2 --vcf sample.vcf.gz --out result --reference_genome GRCh38 --debug
57
57
  ```
@@ -72,18 +72,22 @@ Use `rbceq2 --help` for all current options. Useful switches include:
72
72
  | `--RH` | Include RHD/RHCE for the supported inputs described below. |
73
73
  | `--HPAs` | Include human platelet antigen results. |
74
74
  | `--no_filter` | Disable FILTER-based allele exclusion; inference checks still apply. |
75
+ | `--strict` | Refuse unsupported reference fallback at explicitly missing defining genotypes in VCF or gVCF. |
75
76
  | `--validate` | Run additional VCF format checks. Basic input checks always run. |
76
77
  | `--PDFs` | Generate per-sample PDF reports. |
78
+ | `--unused_variants` | Also write `result_unused_variants.tsv`, described under Outputs. Off by default. |
77
79
  | `--min_size` | Minimum indel/SV size for fuzzy structural matching; default 10. |
78
80
  | `--processes` | Worker processes; default 1. Large input loading also uses memory. |
79
81
 
80
82
  ## Input contract
81
83
 
82
- Provide genotyped VCF calls from an upstream caller, with its calling and coverage
83
- QC completed. **Native gVCFs are not supported in v2.4.4**: unspecified ALT
84
- placeholders such as `<NON_REF>`/`<*>` and reference blocks require additional
85
- handling. A gVCF can be read as text and still produce incomplete or misleading
86
- inference; use the caller's final genotyped VCF.
84
+ Provide genotyped VCF or gVCF calls from an upstream caller, with its calling and
85
+ coverage QC completed. From v2.4.5 the tool handles unspecified ALT placeholders
86
+ such as `<NON_REF>`/`<*>` and projects reference/no-call blocks onto database loci.
87
+ This does not establish coverage outside the supplied records or make different
88
+ callers' outputs equivalent. See the strict-mode limitations below. Releases before
89
+ v2.4.5 do not include this native gVCF handling; use the caller's final genotyped
90
+ VCF with those.
87
91
 
88
92
  GT must be the first FORMAT key when the row is used for inference. Called indices
89
93
  must refer to REF (`0`) or an ALT declared by that row. Missing alleles use `.`.
@@ -134,15 +138,64 @@ can be retained; call-correctness failures and unrecognized values can exclude.
134
138
  Unrecognized values are named in warnings. `--no_filter` bypasses this FILTER-based
135
139
  exclusion, while genotype validity and inference rules remain active.
136
140
 
141
+ A gVCF reference block is read for its genotype and its FILTER value only. Its
142
+ depth and genotype quality decide nothing: a `0/0` block is a reference call
143
+ however little is behind it, so a position the caller could not call must be
144
+ written as a missing genotype. If a reference block carries a FILTER value that
145
+ would exclude a variant call, it does not establish reference at the database loci
146
+ it covers and is read there as a no-call; `PASS`, absent filtering and values
147
+ unrelated to call correctness leave it a reference call. `--no_filter` bypasses
148
+ this too.
149
+
137
150
  A no-call such as `.`, `./.`, or a partial missing GT becomes `NO_DATA` and alleles
138
151
  requiring that uncalled variant are excluded by name. All nonmissing indices must
139
- still be valid for the row.
152
+ still be valid for the row. The no-call summary lists the affected loci and the
153
+ number of samples with a no-call at each. Read the genotype table for each
154
+ sample’s reported result.
140
155
 
141
156
  **A reference output does not establish sequencing coverage.** Missing records can
142
157
  lead to reference defaults, and a no-call can still reach a reference fallback when
143
158
  no candidate remains. Inspect the debug evidence and exclusions; a fallback is not
144
159
  a measured homozygous-reference call.
145
160
 
161
+ The `--strict` option is new in v2.4.5. It applies to ordinary VCF and gVCF
162
+ input. Its defensible meaning
163
+ is **"reference is not established by this input"**; it does not establish that an
164
+ assay failed or that there were no reads.
165
+
166
+ Explicit missing genotypes remain `NO_DATA` in both modes and do not generate
167
+ `_ref` tokens. With `--strict`, a reference slot that depends on an explicitly
168
+ missing genotype at a required defining site becomes `Undetermined`;
169
+ independently supported slots are retained. This rule remains active with
170
+ `--no_filter`.
171
+
172
+ **Strict mode warns where the evidence it accepted is thin or incomplete.** Two
173
+ warnings are logged, each once per sample and blood group with a count of database
174
+ loci; the loci themselves are in the debug log. Neither changes a result.
175
+
176
+ - Reference taken from a gVCF reference block with depth under 5 or genotype
177
+ quality under 5. The block is still read as a measured reference call.
178
+ - Database loci that the input leaves uncalled and that led to no refusal. Strict
179
+ mode refuses a reference slot only where the reference allele itself depends on
180
+ an uncalled locus. At another uncalled locus, the input cannot establish
181
+ whether the sample carries an allele defined there. The reported genotype
182
+ uses the remaining evidence.
183
+
184
+ **Missing genotypes have different possible origins.** A cohort merge can insert
185
+ `./.` when a sample's input file has no record at a site. Such an entry does not
186
+ prove that the site was assayed and the assay failed. A native gVCF can also report
187
+ `./.` despite nonzero depth. Strict mode does not distinguish these origins; it
188
+ uses the missing genotype in the supplied input. A missing genotype is not a
189
+ measured homozygous-reference call (`0/0`). Check the input's calling and merging
190
+ history before interpreting strict refusals.
191
+
192
+ **Absent-row reference synthesis is unchanged, including in strict mode.** An
193
+ omitted site in a variant-only single-sample VCF can still generate `_ref` tokens
194
+ under the existing rules. A covering gVCF block supplies evidence even without a
195
+ row starting at the exact locus; a no-call block is therefore explicit missing
196
+ evidence. Strict mode does not infer coverage gaps from absent records and is not
197
+ a guarantee that every reported reference allele was measured.
198
+
146
199
  ## Outputs and interpretation
147
200
 
148
201
  With `--out result`, the main outputs are:
@@ -172,6 +225,25 @@ Genotype alternatives are comma-separated. Phenotype alternatives are listed
172
225
  independently and can be deduplicated, so entries must not be joined by position
173
226
  between files. A slash can be part of a phenotype name.
174
227
 
228
+ ### Unused variants table
229
+
230
+ `--unused_variants` adds `result_unused_variants.tsv`, with the rows and columns of
231
+ the genotype table. A cell lists the variants the sample was called with at that
232
+ blood group's database positions that the result did not use, comma-separated, in
233
+ the order of the `Vars_unused` section of the `--debug` log:
234
+
235
+ `1:42830901_C_T : c.219C>T : Heterozygous : PASS`
236
+
237
+ The fields are the variant (a long allele is shown as type and length), its coding
238
+ annotation, its zygosity and its FILTER value. `(None)` means the database has no
239
+ coding annotation for that exact change. A comma inside a FILTER value is written
240
+ `%2C`. Positions the caller left uncalled are not listed; see the no-call summary,
241
+ the strict warnings and the debug log for those. Reference tokens (`_ref`), which
242
+ the debug log lists in that section, are not listed either: they state the
243
+ reference at a position, not a variant. An empty cell means no called variant went
244
+ unused, not that every position was called. The table does not need `--debug` and
245
+ does not change the other three tables.
246
+
175
247
  Malformed retained GTs fail the affected sample and are reported with a named error;
176
248
  the other samples in a cohort or directory can continue. Shared header/FORMAT
177
249
  problems can prevent loading an input file. A nonzero process exit and the log must
@@ -182,16 +254,16 @@ be reviewed even when some result files were written.
182
254
  `--PDFs` writes reports to `<output prefix>_PDFs/`. Each report preserves the exact
183
255
  sample identity used in the TSVs, including suffixes and letter case.
184
256
 
185
- ## Database v2.5.1
257
+ ## Database v2.5.2
186
258
 
187
- The packaged [db.tsv](src/rbceq2/resources/db.tsv) is the source of allele definitions
259
+ The packaged [db.tsv](https://github.com/limcintyre/RBCeq2/blob/v2.4.5/src/rbceq2/resources/db.tsv) is the source of allele definitions
188
260
  used by inference. It is curated against ISBT definitions and includes explicit
189
261
  modelling and nomenclature choices. Package and database versions are reported
190
262
  separately by `--version`.
191
263
 
192
264
  ## Documentation and reporting issues
193
265
 
194
- This README describes the v2.4.4 input and output contract. Longer PDF worked
266
+ This README describes the v2.4.5 input and output contract. Longer PDF worked
195
267
  examples attached to earlier releases are historical and may describe earlier
196
268
  behavior; use the version-matched contract here when interpreting current output.
197
269
 
@@ -12,7 +12,7 @@
12
12
  > [!WARNING]
13
13
  > NOT FOR CLINICAL USE
14
14
 
15
- ## Version v2.4.4
15
+ ## Version v2.4.5
16
16
 
17
17
  RBCeq2 infers blood-group genotypes and phenotypes from supplied variant calls using
18
18
  the curated ISBT allele definitions distributed with the package. Deterministic
@@ -24,7 +24,7 @@ and named exclusions behind the result.
24
24
  Python 3.12 or newer is required.
25
25
 
26
26
  ```bash
27
- python -m pip install rbceq2==2.4.4
27
+ python -m pip install rbceq2==2.4.5
28
28
  rbceq2 --version
29
29
  rbceq2 --vcf sample.vcf.gz --out result --reference_genome GRCh38 --debug
30
30
  ```
@@ -45,18 +45,22 @@ Use `rbceq2 --help` for all current options. Useful switches include:
45
45
  | `--RH` | Include RHD/RHCE for the supported inputs described below. |
46
46
  | `--HPAs` | Include human platelet antigen results. |
47
47
  | `--no_filter` | Disable FILTER-based allele exclusion; inference checks still apply. |
48
+ | `--strict` | Refuse unsupported reference fallback at explicitly missing defining genotypes in VCF or gVCF. |
48
49
  | `--validate` | Run additional VCF format checks. Basic input checks always run. |
49
50
  | `--PDFs` | Generate per-sample PDF reports. |
51
+ | `--unused_variants` | Also write `result_unused_variants.tsv`, described under Outputs. Off by default. |
50
52
  | `--min_size` | Minimum indel/SV size for fuzzy structural matching; default 10. |
51
53
  | `--processes` | Worker processes; default 1. Large input loading also uses memory. |
52
54
 
53
55
  ## Input contract
54
56
 
55
- Provide genotyped VCF calls from an upstream caller, with its calling and coverage
56
- QC completed. **Native gVCFs are not supported in v2.4.4**: unspecified ALT
57
- placeholders such as `<NON_REF>`/`<*>` and reference blocks require additional
58
- handling. A gVCF can be read as text and still produce incomplete or misleading
59
- inference; use the caller's final genotyped VCF.
57
+ Provide genotyped VCF or gVCF calls from an upstream caller, with its calling and
58
+ coverage QC completed. From v2.4.5 the tool handles unspecified ALT placeholders
59
+ such as `<NON_REF>`/`<*>` and projects reference/no-call blocks onto database loci.
60
+ This does not establish coverage outside the supplied records or make different
61
+ callers' outputs equivalent. See the strict-mode limitations below. Releases before
62
+ v2.4.5 do not include this native gVCF handling; use the caller's final genotyped
63
+ VCF with those.
60
64
 
61
65
  GT must be the first FORMAT key when the row is used for inference. Called indices
62
66
  must refer to REF (`0`) or an ALT declared by that row. Missing alleles use `.`.
@@ -107,15 +111,64 @@ can be retained; call-correctness failures and unrecognized values can exclude.
107
111
  Unrecognized values are named in warnings. `--no_filter` bypasses this FILTER-based
108
112
  exclusion, while genotype validity and inference rules remain active.
109
113
 
114
+ A gVCF reference block is read for its genotype and its FILTER value only. Its
115
+ depth and genotype quality decide nothing: a `0/0` block is a reference call
116
+ however little is behind it, so a position the caller could not call must be
117
+ written as a missing genotype. If a reference block carries a FILTER value that
118
+ would exclude a variant call, it does not establish reference at the database loci
119
+ it covers and is read there as a no-call; `PASS`, absent filtering and values
120
+ unrelated to call correctness leave it a reference call. `--no_filter` bypasses
121
+ this too.
122
+
110
123
  A no-call such as `.`, `./.`, or a partial missing GT becomes `NO_DATA` and alleles
111
124
  requiring that uncalled variant are excluded by name. All nonmissing indices must
112
- still be valid for the row.
125
+ still be valid for the row. The no-call summary lists the affected loci and the
126
+ number of samples with a no-call at each. Read the genotype table for each
127
+ sample’s reported result.
113
128
 
114
129
  **A reference output does not establish sequencing coverage.** Missing records can
115
130
  lead to reference defaults, and a no-call can still reach a reference fallback when
116
131
  no candidate remains. Inspect the debug evidence and exclusions; a fallback is not
117
132
  a measured homozygous-reference call.
118
133
 
134
+ The `--strict` option is new in v2.4.5. It applies to ordinary VCF and gVCF
135
+ input. Its defensible meaning
136
+ is **"reference is not established by this input"**; it does not establish that an
137
+ assay failed or that there were no reads.
138
+
139
+ Explicit missing genotypes remain `NO_DATA` in both modes and do not generate
140
+ `_ref` tokens. With `--strict`, a reference slot that depends on an explicitly
141
+ missing genotype at a required defining site becomes `Undetermined`;
142
+ independently supported slots are retained. This rule remains active with
143
+ `--no_filter`.
144
+
145
+ **Strict mode warns where the evidence it accepted is thin or incomplete.** Two
146
+ warnings are logged, each once per sample and blood group with a count of database
147
+ loci; the loci themselves are in the debug log. Neither changes a result.
148
+
149
+ - Reference taken from a gVCF reference block with depth under 5 or genotype
150
+ quality under 5. The block is still read as a measured reference call.
151
+ - Database loci that the input leaves uncalled and that led to no refusal. Strict
152
+ mode refuses a reference slot only where the reference allele itself depends on
153
+ an uncalled locus. At another uncalled locus, the input cannot establish
154
+ whether the sample carries an allele defined there. The reported genotype
155
+ uses the remaining evidence.
156
+
157
+ **Missing genotypes have different possible origins.** A cohort merge can insert
158
+ `./.` when a sample's input file has no record at a site. Such an entry does not
159
+ prove that the site was assayed and the assay failed. A native gVCF can also report
160
+ `./.` despite nonzero depth. Strict mode does not distinguish these origins; it
161
+ uses the missing genotype in the supplied input. A missing genotype is not a
162
+ measured homozygous-reference call (`0/0`). Check the input's calling and merging
163
+ history before interpreting strict refusals.
164
+
165
+ **Absent-row reference synthesis is unchanged, including in strict mode.** An
166
+ omitted site in a variant-only single-sample VCF can still generate `_ref` tokens
167
+ under the existing rules. A covering gVCF block supplies evidence even without a
168
+ row starting at the exact locus; a no-call block is therefore explicit missing
169
+ evidence. Strict mode does not infer coverage gaps from absent records and is not
170
+ a guarantee that every reported reference allele was measured.
171
+
119
172
  ## Outputs and interpretation
120
173
 
121
174
  With `--out result`, the main outputs are:
@@ -145,6 +198,25 @@ Genotype alternatives are comma-separated. Phenotype alternatives are listed
145
198
  independently and can be deduplicated, so entries must not be joined by position
146
199
  between files. A slash can be part of a phenotype name.
147
200
 
201
+ ### Unused variants table
202
+
203
+ `--unused_variants` adds `result_unused_variants.tsv`, with the rows and columns of
204
+ the genotype table. A cell lists the variants the sample was called with at that
205
+ blood group's database positions that the result did not use, comma-separated, in
206
+ the order of the `Vars_unused` section of the `--debug` log:
207
+
208
+ `1:42830901_C_T : c.219C>T : Heterozygous : PASS`
209
+
210
+ The fields are the variant (a long allele is shown as type and length), its coding
211
+ annotation, its zygosity and its FILTER value. `(None)` means the database has no
212
+ coding annotation for that exact change. A comma inside a FILTER value is written
213
+ `%2C`. Positions the caller left uncalled are not listed; see the no-call summary,
214
+ the strict warnings and the debug log for those. Reference tokens (`_ref`), which
215
+ the debug log lists in that section, are not listed either: they state the
216
+ reference at a position, not a variant. An empty cell means no called variant went
217
+ unused, not that every position was called. The table does not need `--debug` and
218
+ does not change the other three tables.
219
+
148
220
  Malformed retained GTs fail the affected sample and are reported with a named error;
149
221
  the other samples in a cohort or directory can continue. Shared header/FORMAT
150
222
  problems can prevent loading an input file. A nonzero process exit and the log must
@@ -155,16 +227,16 @@ be reviewed even when some result files were written.
155
227
  `--PDFs` writes reports to `<output prefix>_PDFs/`. Each report preserves the exact
156
228
  sample identity used in the TSVs, including suffixes and letter case.
157
229
 
158
- ## Database v2.5.1
230
+ ## Database v2.5.2
159
231
 
160
- The packaged [db.tsv](src/rbceq2/resources/db.tsv) is the source of allele definitions
232
+ The packaged [db.tsv](https://github.com/limcintyre/RBCeq2/blob/v2.4.5/src/rbceq2/resources/db.tsv) is the source of allele definitions
161
233
  used by inference. It is curated against ISBT definitions and includes explicit
162
234
  modelling and nomenclature choices. Package and database versions are reported
163
235
  separately by `--version`.
164
236
 
165
237
  ## Documentation and reporting issues
166
238
 
167
- This README describes the v2.4.4 input and output contract. Longer PDF worked
239
+ This README describes the v2.4.5 input and output contract. Longer PDF worked
168
240
  examples attached to earlier releases are historical and may describe earlier
169
241
  behavior; use the version-matched contract here when interpreting current output.
170
242
 
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "rbceq2"
9
- version = "2.4.4"
9
+ version = "2.4.5"
10
10
  description = "Call ISBT alleles from VCF/s"
11
11
  readme = "README.md"
12
12
  license = "MIT"
@@ -23,7 +23,7 @@ from reportlab.platypus import (
23
23
  TableStyle,
24
24
  )
25
25
 
26
- from rbceq2.core_logic.constants import DB_VERSION, VERSION
26
+ from rbceq2.core_logic.constants import DB_VERSION, UNDETERMINED_SLOT, VERSION
27
27
 
28
28
  # --- Reference Alleles ---
29
29
  # Used to determine if a genotype is homozygous reference (ref/ref).
@@ -124,6 +124,14 @@ REFERENCE_ALLELES: Dict[str, str] = {
124
124
 
125
125
  # Highlight color for non-reference genotypes — visible yellow
126
126
  HIGHLIGHT_COLOR = colors.Color(1.0, 0.92, 0.40) # Bright yellow
127
+ # Rows whose genotype could not be determined — pale blue, so that an absent
128
+ # answer is never read as a detected variant.
129
+ UNDETERMINED_COLOR = colors.Color(0.80, 0.87, 0.96)
130
+
131
+ # The three classes a report row can fall into.
132
+ ROW_REFERENCE = "reference"
133
+ ROW_NON_REFERENCE = "non_reference"
134
+ ROW_UNDETERMINED = "undetermined"
127
135
  # Default row backgrounds for alternating stripes
128
136
  DEFAULT_ROW_COLOR_EVEN = colors.Color(0.95, 0.95, 0.93) # Beige-ish
129
137
  DEFAULT_ROW_COLOR_ODD = colors.Color(1.0, 1.0, 1.0) # White
@@ -224,6 +232,86 @@ def _is_ref_ref(key: str, genotype_value: Optional[Any]) -> bool:
224
232
  return True
225
233
 
226
234
 
235
+ def _is_undetermined(key: str, genotype_value: Optional[Any]) -> bool:
236
+ """Checks whether a genotype value names nothing beyond the reference.
237
+
238
+ A row is undetermined when at least one slot of a reported candidate is
239
+ the undetermined slot and no candidate names a non-reference allele. A
240
+ candidate that names a non-reference allele beside an undetermined slot
241
+ is evidence of that allele, so the row is not undetermined.
242
+
243
+ Args:
244
+ key: The gene/system name (e.g., "FY", "KEL", "HPA1").
245
+ genotype_value: The raw genotype value from the DataFrame.
246
+
247
+ Returns:
248
+ True if the genotype is undetermined, False otherwise.
249
+
250
+ Example:
251
+ "Undetermined/Undetermined" -> True
252
+ "KN*01.-05/KN*01.10,KN*01.-05/Undetermined" -> False
253
+ """
254
+ if pd.isna(genotype_value) or genotype_value is None:
255
+ return False
256
+ clean_geno = str(genotype_value).replace("\n", "").replace("\r", "").strip()
257
+ slots = [
258
+ slot.strip()
259
+ for segment in clean_geno.split(",")
260
+ for slot in segment.split("/")
261
+ if slot.strip()
262
+ ]
263
+ if UNDETERMINED_SLOT not in slots:
264
+ return False
265
+ ref_allele = REFERENCE_ALLELES.get(key)
266
+ return all(slot == ref_allele for slot in slots if slot != UNDETERMINED_SLOT)
267
+
268
+
269
+ def _row_class(key: str, genotype_value: Optional[Any]) -> str:
270
+ """Classifies a report row as reference, non-reference or undetermined.
271
+
272
+ Args:
273
+ key: The gene/system name (e.g., "FY", "KEL", "HPA1").
274
+ genotype_value: The raw genotype value from the DataFrame.
275
+
276
+ Returns:
277
+ One of ROW_REFERENCE, ROW_NON_REFERENCE and ROW_UNDETERMINED.
278
+ """
279
+ if _is_undetermined(key, genotype_value):
280
+ return ROW_UNDETERMINED
281
+ if _is_ref_ref(key, genotype_value):
282
+ return ROW_REFERENCE
283
+ return ROW_NON_REFERENCE
284
+
285
+
286
+ def _summary_part(
287
+ non_reference: int, undetermined: int, total: int, noun: str
288
+ ) -> str:
289
+ """Builds one half of the summary line above the tables.
290
+
291
+ Args:
292
+ non_reference: Rows showing a non-reference genotype.
293
+ undetermined: Rows whose genotype is undetermined.
294
+ total: All rows of this kind.
295
+ noun: What a row is called, e.g. "blood group system".
296
+
297
+ Returns:
298
+ The count of non-reference rows, followed by the count of
299
+ undetermined rows where there are any.
300
+
301
+ Example:
302
+ (18, 2, 51, "blood group system") ->
303
+ "18 of 51 blood group systems show non-reference genotypes, 2 undetermined"
304
+ """
305
+ text = (
306
+ f"{non_reference} of {total} {noun}{'s' if total != 1 else ''}"
307
+ f" show{'s' if non_reference == 1 else ''}"
308
+ f" non-reference genotype{'s' if non_reference != 1 else ''}"
309
+ )
310
+ if undetermined:
311
+ text += f", {undetermined} undetermined"
312
+ return text
313
+
314
+
227
315
  # --- Data Preparation ---
228
316
 
229
317
 
@@ -392,10 +480,11 @@ def _build_table_from_keys(
392
480
  keys: List[str],
393
481
  sample_data: Dict[str, Optional[pd.Series]],
394
482
  styles: Dict[str, ParagraphStyle],
395
- ) -> Tuple[Table, int]:
483
+ ) -> Tuple[Table, int, int]:
396
484
  """Builds a ReportLab Table from a list of gene/system keys.
397
485
 
398
- Returns the Table and the count of non-ref/ref rows (highlighted rows).
486
+ Returns the Table, the count of non-reference rows and the count of
487
+ undetermined rows. The two kinds of row are shaded differently.
399
488
  """
400
489
  header_content = ["System/Gene", "Genotype", "Phenotype (Alpha)", "Phenotype (Num)"]
401
490
  header_row: List[Paragraph] = [
@@ -403,6 +492,7 @@ def _build_table_from_keys(
403
492
  ]
404
493
  table_data: List[List[Flowable]] = [header_row]
405
494
  highlight_rows: List[int] = [] # 1-based row indices to highlight
495
+ undetermined_rows: List[int] = [] # 1-based, shaded separately
406
496
 
407
497
  for i, key in enumerate(keys):
408
498
  geno_val = (
@@ -425,9 +515,12 @@ def _build_table_from_keys(
425
515
  formatted_alpha = _format_cell_content(alpha_val, separator="|")
426
516
  formatted_num = _format_cell_content(num_val, separator="|")
427
517
 
428
- # Check if this row should be highlighted (not ref/ref)
429
- if not _is_ref_ref(key, geno_val):
430
- highlight_rows.append(i + 1) # +1 because row 0 is the header
518
+ # Shade the row by class; +1 because row 0 is the header
519
+ row_class = _row_class(key, geno_val)
520
+ if row_class == ROW_NON_REFERENCE:
521
+ highlight_rows.append(i + 1)
522
+ elif row_class == ROW_UNDETERMINED:
523
+ undetermined_rows.append(i + 1)
431
524
 
432
525
  table_data.append(
433
526
  [
@@ -472,24 +565,34 @@ def _build_table_from_keys(
472
565
  ("BACKGROUND", (0, row_idx), (-1, row_idx), HIGHLIGHT_COLOR)
473
566
  )
474
567
 
568
+ for row_idx in undetermined_rows:
569
+ style_commands.append(
570
+ ("BACKGROUND", (0, row_idx), (-1, row_idx), UNDETERMINED_COLOR)
571
+ )
572
+
475
573
  table.setStyle(TableStyle(style_commands))
476
- return table, len(highlight_rows)
574
+ return table, len(highlight_rows), len(undetermined_rows)
477
575
 
478
576
 
479
577
  def _create_consolidated_table(
480
578
  sample_data: Dict[str, Optional[pd.Series]],
481
579
  all_keys_for_sample: Set[str],
482
580
  styles: Dict[str, ParagraphStyle],
483
- ) -> Tuple[List[Flowable], int, int]:
581
+ ) -> Tuple[List[Flowable], int, int, int, int]:
484
582
  """Creates the main data tables, separating HPA alleles to the bottom.
485
583
 
486
584
  Returns a tuple of:
487
585
  - List of Flowables (blood group table, then optionally HPA section)
488
586
  - Count of non-ref blood group systems
489
587
  - Count of non-ref HPA systems
588
+ - Count of undetermined blood group systems
589
+ - Count of undetermined HPA systems
490
590
  """
491
591
  if not all_keys_for_sample:
492
- return [Paragraph("No data available for this sample.", styles["body"])], 0, 0
592
+ return (
593
+ [Paragraph("No data available for this sample.", styles["body"])],
594
+ 0, 0, 0, 0,
595
+ )
493
596
 
494
597
  sorted_keys = sorted(list(all_keys_for_sample))
495
598
 
@@ -500,10 +603,12 @@ def _create_consolidated_table(
500
603
  flowables: List[Flowable] = []
501
604
  bg_highlight_count = 0
502
605
  hpa_highlight_count = 0
606
+ bg_undetermined_count = 0
607
+ hpa_undetermined_count = 0
503
608
 
504
609
  # Blood group systems table
505
610
  if blood_group_keys:
506
- bg_table, bg_highlight_count = _build_table_from_keys(
611
+ bg_table, bg_highlight_count, bg_undetermined_count = _build_table_from_keys(
507
612
  blood_group_keys, sample_data, styles
508
613
  )
509
614
  flowables.append(bg_table)
@@ -515,12 +620,20 @@ def _create_consolidated_table(
515
620
  Paragraph("Human Platelet Antigens (HPA)", styles["section_heading"])
516
621
  )
517
622
  flowables.append(Spacer(1, 0.05 * inch))
518
- hpa_table, hpa_highlight_count = _build_table_from_keys(
519
- hpa_keys, sample_data, styles
623
+ hpa_table, hpa_highlight_count, hpa_undetermined_count = (
624
+ _build_table_from_keys(
625
+ hpa_keys, sample_data, styles
626
+ )
520
627
  )
521
628
  flowables.append(hpa_table)
522
629
 
523
- return flowables, bg_highlight_count, hpa_highlight_count
630
+ return (
631
+ flowables,
632
+ bg_highlight_count,
633
+ hpa_highlight_count,
634
+ bg_undetermined_count,
635
+ hpa_undetermined_count,
636
+ )
524
637
 
525
638
 
526
639
  def _generate_pdf_report_for_sample(
@@ -577,6 +690,10 @@ def _generate_pdf_report_for_sample(
577
690
  "Non-reference genotype detected", styles["table_cell"]
578
691
  ),
579
692
  ],
693
+ [
694
+ Paragraph("", styles["table_cell"]),
695
+ Paragraph("Genotype undetermined", styles["table_cell"]),
696
+ ],
580
697
  ]
581
698
  legend_table = Table(legend_data, colWidths=[0.3 * inch, 3.0 * inch])
582
699
  legend_table.setStyle(
@@ -584,8 +701,10 @@ def _generate_pdf_report_for_sample(
584
701
  [
585
702
  ("BACKGROUND", (0, 0), (0, 0), DEFAULT_ROW_COLOR_EVEN),
586
703
  ("BACKGROUND", (0, 1), (0, 1), HIGHLIGHT_COLOR),
704
+ ("BACKGROUND", (0, 2), (0, 2), UNDETERMINED_COLOR),
587
705
  ("BOX", (0, 0), (0, 0), 0.75, colors.black),
588
706
  ("BOX", (0, 1), (0, 1), 0.75, colors.black),
707
+ ("BOX", (0, 2), (0, 2), 0.75, colors.black),
589
708
  ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
590
709
  ("LEFTPADDING", (0, 0), (-1, -1), 4),
591
710
  ("RIGHTPADDING", (0, 0), (-1, -1), 4),
@@ -598,11 +717,15 @@ def _generate_pdf_report_for_sample(
598
717
  story.append(Spacer(1, 0.15 * inch))
599
718
 
600
719
  # 5. Create tables (blood groups + HPA separated)
601
- table_flowables, bg_count, hpa_count = _create_consolidated_table(
602
- sample_data, all_keys_for_sample, styles
603
- )
604
-
605
- # 5a. Summary count of non-reference genotypes
720
+ (
721
+ table_flowables,
722
+ bg_count,
723
+ hpa_count,
724
+ bg_undetermined,
725
+ hpa_undetermined,
726
+ ) = _create_consolidated_table(sample_data, all_keys_for_sample, styles)
727
+
728
+ # 5a. Summary count of non-reference and undetermined genotypes
606
729
  sorted_keys = sorted(list(all_keys_for_sample))
607
730
  total_bg = len([k for k in sorted_keys if not _is_hpa_key(k)])
608
731
  total_hpa = len([k for k in sorted_keys if _is_hpa_key(k)])
@@ -610,13 +733,11 @@ def _generate_pdf_report_for_sample(
610
733
  summary_parts = []
611
734
  if total_bg > 0:
612
735
  summary_parts.append(
613
- f"{bg_count} of {total_bg} blood group system{'s' if total_bg != 1 else ''}"
614
- f" show{'s' if bg_count == 1 else ''} non-reference genotype{'s' if bg_count != 1 else ''}"
736
+ _summary_part(bg_count, bg_undetermined, total_bg, "blood group system")
615
737
  )
616
738
  if total_hpa > 0:
617
739
  summary_parts.append(
618
- f"{hpa_count} of {total_hpa} HPA system{'s' if total_hpa != 1 else ''}"
619
- f" show{'s' if hpa_count == 1 else ''} non-reference genotype{'s' if hpa_count != 1 else ''}"
740
+ _summary_part(hpa_count, hpa_undetermined, total_hpa, "HPA system")
620
741
  )
621
742
  if summary_parts:
622
743
  summary_text = " | ".join(summary_parts)