RBCeq2 2.4.3__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 (103) hide show
  1. rbceq2-2.4.5/CITATION.cff +39 -0
  2. {rbceq2-2.4.3 → rbceq2-2.4.5}/MANIFEST.in +2 -1
  3. rbceq2-2.4.5/PKG-INFO +274 -0
  4. rbceq2-2.4.5/README.md +247 -0
  5. {rbceq2-2.4.3 → rbceq2-2.4.5}/pyproject.toml +5 -5
  6. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/IO/PDF_reports.py +226 -70
  7. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/IO/encoders.py +0 -913
  8. rbceq2-2.4.5/src/rbceq2/IO/record_data.py +430 -0
  9. rbceq2-2.4.5/src/rbceq2/IO/vcf.py +2208 -0
  10. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/core_logic/alleles.py +168 -21
  11. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/core_logic/co_existing.py +10 -18
  12. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/core_logic/constants.py +499 -59
  13. rbceq2-2.4.5/src/rbceq2/core_logic/data_procesing.py +3073 -0
  14. rbceq2-2.4.5/src/rbceq2/core_logic/filter_semantics.py +158 -0
  15. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/core_logic/large_variants.py +152 -156
  16. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/core_logic/utils.py +71 -39
  17. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/db/db.py +365 -57
  18. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/filters/geno.py +666 -87
  19. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/filters/knops.py +5 -137
  20. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/filters/phased.py +602 -146
  21. rbceq2-2.4.5/src/rbceq2/filters/shared_filter_functionality.py +182 -0
  22. rbceq2-2.4.5/src/rbceq2/main.py +820 -0
  23. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/phenotype/antigens.py +40 -42
  24. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/phenotype/choose_pheno.py +32 -50
  25. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/resources/db.tsv +99 -100
  26. rbceq2-2.4.5/src/rbceq2/resources/filter_values.tsv +27 -0
  27. rbceq2-2.4.5/src/rbceq2.egg-info/PKG-INFO +274 -0
  28. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2.egg-info/SOURCES.txt +37 -0
  29. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2.egg-info/requires.txt +1 -1
  30. rbceq2-2.4.5/tests/test_VCF.py +1259 -0
  31. rbceq2-2.4.5/tests/test_allele_coverage.py +249 -0
  32. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_alleles.py +126 -5
  33. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_ants.py +21 -1
  34. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_choose_pheno.py +57 -1
  35. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_coexisting.py +85 -26
  36. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_data_processing.py +1308 -329
  37. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_db.py +97 -0
  38. rbceq2-2.4.5/tests/test_deletion_phase_seed.py +167 -0
  39. rbceq2-2.4.5/tests/test_deletion_placement.py +123 -0
  40. rbceq2-2.4.5/tests/test_duplicate_row_agreement.py +91 -0
  41. rbceq2-2.4.5/tests/test_filter_semantics.py +167 -0
  42. rbceq2-2.4.5/tests/test_filters_phase.py +1836 -0
  43. rbceq2-2.4.5/tests/test_fut3_secretor.py +104 -0
  44. rbceq2-2.4.5/tests/test_fy_null_token.py +82 -0
  45. rbceq2-2.4.5/tests/test_geno_filters.py +1550 -0
  46. rbceq2-2.4.5/tests/test_gvcf.py +311 -0
  47. rbceq2-2.4.5/tests/test_gvcf_block_filter.py +218 -0
  48. rbceq2-2.4.5/tests/test_gvcf_block_safety.py +142 -0
  49. rbceq2-2.4.5/tests/test_gvcf_blocks.py +213 -0
  50. rbceq2-2.4.5/tests/test_gvcf_phased_end_to_end.py +271 -0
  51. rbceq2-2.4.5/tests/test_gvcf_strict.py +318 -0
  52. rbceq2-2.4.5/tests/test_lane_reference_assumptions.py +94 -0
  53. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_large_variants.py +5 -5
  54. rbceq2-2.4.5/tests/test_locus_copies.py +763 -0
  55. rbceq2-2.4.5/tests/test_lu_reference_fallback.py +238 -0
  56. rbceq2-2.4.5/tests/test_main.py +65 -0
  57. rbceq2-2.4.5/tests/test_multiallelic.py +270 -0
  58. rbceq2-2.4.5/tests/test_pdf.py +260 -0
  59. rbceq2-2.4.5/tests/test_pdf_undetermined_class.py +144 -0
  60. rbceq2-2.4.5/tests/test_phase_evidence.py +232 -0
  61. rbceq2-2.4.5/tests/test_phase_flip_invariance.py +600 -0
  62. rbceq2-2.4.5/tests/test_phase_set_provenance.py +125 -0
  63. rbceq2-2.4.5/tests/test_placeholder_row_selection.py +210 -0
  64. rbceq2-2.4.5/tests/test_ploidy.py +590 -0
  65. rbceq2-2.4.5/tests/test_reader_block_fast_path.py +110 -0
  66. rbceq2-2.4.5/tests/test_record_data.py +86 -0
  67. rbceq2-2.4.5/tests/test_strict_fallback_guards.py +283 -0
  68. rbceq2-2.4.5/tests/test_strict_uncalled_locus_warning.py +175 -0
  69. rbceq2-2.4.5/tests/test_strict_weak_reference_warning.py +232 -0
  70. rbceq2-2.4.5/tests/test_sv_build_selection.py +83 -0
  71. rbceq2-2.4.5/tests/test_sv_match_ambiguity.py +158 -0
  72. rbceq2-2.4.5/tests/test_sv_match_ties.py +73 -0
  73. rbceq2-2.4.5/tests/test_sv_provenance.py +170 -0
  74. rbceq2-2.4.5/tests/test_sv_row_event_rule.py +133 -0
  75. rbceq2-2.4.5/tests/test_unused_variants_table.py +422 -0
  76. rbceq2-2.4.3/PKG-INFO +0 -103
  77. rbceq2-2.4.3/README.md +0 -69
  78. rbceq2-2.4.3/src/rbceq2/IO/record_data.py +0 -171
  79. rbceq2-2.4.3/src/rbceq2/IO/vcf.py +0 -640
  80. rbceq2-2.4.3/src/rbceq2/core_logic/data_procesing.py +0 -1559
  81. rbceq2-2.4.3/src/rbceq2/filters/shared_filter_functionality.py +0 -108
  82. rbceq2-2.4.3/src/rbceq2/main.py +0 -482
  83. rbceq2-2.4.3/src/rbceq2.egg-info/PKG-INFO +0 -103
  84. rbceq2-2.4.3/tests/test_VCF.py +0 -340
  85. rbceq2-2.4.3/tests/test_filters_phase.py +0 -308
  86. rbceq2-2.4.3/tests/test_geno_filters.py +0 -813
  87. rbceq2-2.4.3/tests/test_main.py +0 -5
  88. rbceq2-2.4.3/tests/test_pdf.py +0 -101
  89. {rbceq2-2.4.3 → rbceq2-2.4.5}/LICENSE +0 -0
  90. {rbceq2-2.4.3 → rbceq2-2.4.5}/setup.cfg +0 -0
  91. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/IO/__init__.py +0 -0
  92. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/IO/validation.py +0 -0
  93. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/__init__.py +0 -0
  94. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/core_logic/__init__.py +0 -0
  95. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/db/__init__.py +0 -0
  96. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/filters/__init__.py +0 -0
  97. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2/phenotype/__init__.py +0 -0
  98. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2.egg-info/dependency_links.txt +0 -0
  99. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2.egg-info/entry_points.txt +0 -0
  100. {rbceq2-2.4.3 → rbceq2-2.4.5}/src/rbceq2.egg-info/top_level.txt +0 -0
  101. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_IO.py +0 -0
  102. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_co_filters.py +0 -0
  103. {rbceq2-2.4.3 → rbceq2-2.4.5}/tests/test_utils.py +0 -0
@@ -0,0 +1,39 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use RBCeq2, plz cite this software entry."
3
+ authors:
4
+ - family-names: McIntyre
5
+ given-names: Liam
6
+ orcid: "https://orcid.org/0000-0002-3143-5192"
7
+ affiliation: "Australian Red Cross Lifeblood"
8
+ - family-names: Perros
9
+ given-names: Alexis
10
+ orcid: "https://orcid.org/0000-0001-5596-2934"
11
+ affiliation: "Australian Red Cross Lifeblood"
12
+ - family-names: Sowah
13
+ given-names: Sandra
14
+ orcid: "https://orcid.org/0000-0003-3339-3763"
15
+ affiliation: "Australian Red Cross Lifeblood"
16
+ - family-names: Davison
17
+ given-names: Candice
18
+ orcid: "https://orcid.org/0000-0003-3705-2544"
19
+ affiliation: "Australian Red Cross Lifeblood"
20
+ - family-names: Hyland
21
+ given-names: Catherine
22
+ orcid: "https://orcid.org/0000-0002-4124-6168"
23
+ affiliation: "Australian Red Cross Lifeblood"
24
+ - family-names: Robert
25
+ given-names: Flower
26
+ orcid: "https://orcid.org/0000-0002-7257-1844"
27
+ affiliation: "Australian Red Cross Lifeblood"
28
+ - family-names: Eileen
29
+ given-names: Roulis
30
+ orcid: "https://orcid.org/0000-0001-6824-5432"
31
+ affiliation: "Australian Red Cross Lifeblood"
32
+ title: "RBCeq2"
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
+ license: MIT
38
+ keywords: [bioinformatics, blood-group, genomics]
39
+ type: software
@@ -1,3 +1,4 @@
1
1
  recursive-include src/rbceq2/resources *.tsv
2
2
  include LICENSE
3
- include README.md
3
+ include README.md
4
+ include CITATION.cff
rbceq2-2.4.5/PKG-INFO ADDED
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.4
2
+ Name: rbceq2
3
+ Version: 2.4.5
4
+ Summary: Call ISBT alleles from VCF/s
5
+ Author-email: Liam McIntyre <limcintyre@redcrossblood.org.au>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pandas>=2.2.2
17
+ Requires-Dist: polars>=0.20.31
18
+ Requires-Dist: icecream>=2.1
19
+ Requires-Dist: loguru>=0.7.2
20
+ Requires-Dist: pyarrow>=18.1
21
+ Requires-Dist: reportlab>=4.3.1
22
+ Requires-Dist: frozendict>=2.4.6
23
+ Provides-Extra: dev
24
+ Requires-Dist: flake8>=3.9.2; extra == "dev"
25
+ Requires-Dist: coverage>=7.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ <table>
29
+ <tr>
30
+ <td>
31
+ <h1>RBCeq2: blood group allele inference</h1>
32
+ </td>
33
+ <td align="right">
34
+ <img src="images/Lifeblood-R_Primary_Keyline_RGB.jpg" alt="Lifeblood Logo" width="150">
35
+ </td>
36
+ </tr>
37
+ </table>
38
+
39
+ > [!WARNING]
40
+ > NOT FOR CLINICAL USE
41
+
42
+ ## Version v2.4.5
43
+
44
+ RBCeq2 infers blood-group genotypes and phenotypes from supplied variant calls using
45
+ the curated ISBT allele definitions distributed with the package. Deterministic
46
+ rules select and exclude candidate alleles and pairs; `--debug` records the evidence
47
+ and named exclusions behind the result.
48
+
49
+ ## Install and run
50
+
51
+ Python 3.12 or newer is required.
52
+
53
+ ```bash
54
+ python -m pip install rbceq2==2.4.5
55
+ rbceq2 --version
56
+ rbceq2 --vcf sample.vcf.gz --out result --reference_genome GRCh38 --debug
57
+ ```
58
+
59
+ Supply `GRCh37` or `GRCh38` to match the input coordinates. A single-sample VCF,
60
+ multi-sample VCF, or directory of separate `.vcf`/`.vcf.gz` files can be supplied.
61
+ Both ordinary gzip and uncompressed VCF input are read. For a directory:
62
+
63
+ ```bash
64
+ rbceq2 --vcf samples/ --out cohort --reference_genome GRCh38 --processes 4 --debug
65
+ ```
66
+
67
+ Use `rbceq2 --help` for all current options. Useful switches include:
68
+
69
+ | Option | Purpose |
70
+ |---|---|
71
+ | `--phased` | Use genotype phasing and phase-set information where available. |
72
+ | `--RH` | Include RHD/RHCE for the supported inputs described below. |
73
+ | `--HPAs` | Include human platelet antigen results. |
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. |
76
+ | `--validate` | Run additional VCF format checks. Basic input checks always run. |
77
+ | `--PDFs` | Generate per-sample PDF reports. |
78
+ | `--unused_variants` | Also write `result_unused_variants.tsv`, described under Outputs. Off by default. |
79
+ | `--min_size` | Minimum indel/SV size for fuzzy structural matching; default 10. |
80
+ | `--processes` | Worker processes; default 1. Large input loading also uses memory. |
81
+
82
+ ## Input contract
83
+
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.
91
+
92
+ GT must be the first FORMAT key when the row is used for inference. Called indices
93
+ must refer to REF (`0`) or an ALT declared by that row. Missing alleles use `.`.
94
+ Supported GT spellings use `/` or `|` between canonical integer indices; initial
95
+ phasing separators and leading-zero indices are explicitly unsupported.
96
+
97
+ Small-variant multiallelic records are processed into per-ALT calls internally.
98
+ Some reference-containing multiallelic configurations can remain partially
99
+ unresolved. Inspect `Undetermined` results and normalize such sites upstream where
100
+ appropriate. Mixed symbolic structural/small-variant records need caller-specific
101
+ assessment and are not a general supported input route.
102
+
103
+
104
+ ### Chromosome copies and gene copies
105
+
106
+ These are different statements and lead to different output shapes:
107
+
108
+ - A valid called haploid GT outside PAR on X/Y supplies per-sample evidence for one
109
+ chromosome in that region.
110
+ - Gene copy number can be read from GT ploidy only when the upstream caller
111
+ explicitly uses that convention.
112
+
113
+ Called structural deletions are evaluated against the curated database and can
114
+ constrain which chromosome carries an overlapping allele. The deletion's presence
115
+ and the gene-copy interpretation inferred from GT are kept distinct.
116
+
117
+ ### RHD and RHCE
118
+
119
+ Use `--RH` for long-read VCFs with structural-variant information, or for callers
120
+ that explicitly encode RH gene copy number as GT ploidy. Ordinary short-read
121
+ variant calls without either source of information are unsupported for RH
122
+ inference because of the similarity between RHD and RHCE.
123
+
124
+ Compatibility depends on the caller's stated encoding convention. Synthetic
125
+ examples establish the software's behavior; they do not establish compatibility
126
+ with every caller.
127
+
128
+ ### Structural-variant selection
129
+
130
+ Structural variants are fuzzy matched against allele definitions for the selected
131
+ `--reference_genome`.
132
+
133
+ ### FILTER and missing data
134
+
135
+ By default, `PASS` and absent filtering (`.` or empty) do not exclude an allele.
136
+ Other FILTER values are classified: recognized values unrelated to call correctness
137
+ can be retained; call-correctness failures and unrecognized values can exclude.
138
+ Unrecognized values are named in warnings. `--no_filter` bypasses this FILTER-based
139
+ exclusion, while genotype validity and inference rules remain active.
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
+
150
+ A no-call such as `.`, `./.`, or a partial missing GT becomes `NO_DATA` and alleles
151
+ requiring that uncalled variant are excluded by name. All nonmissing indices must
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.
155
+
156
+ **A reference output does not establish sequencing coverage.** Missing records can
157
+ lead to reference defaults, and a no-call can still reach a reference fallback when
158
+ no candidate remains. Inspect the debug evidence and exclusions; a fallback is not
159
+ a measured homozygous-reference call.
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
+
199
+ ## Outputs and interpretation
200
+
201
+ With `--out result`, the main outputs are:
202
+
203
+ - `result_geno.tsv`
204
+ - `result_pheno_numeric.tsv`
205
+ - `result_pheno_alphanumeric.tsv`
206
+ - `result_<run UUID>_log.txt`
207
+
208
+ The first TSV column identifies the sample; its heading contains the run UUID.
209
+ Cohort input uses the VCF sample names. Single-file and directory input uses the
210
+ filename with its final suffix removed, so `sample.vcf.gz` is named `sample.vcf`.
211
+
212
+ | Slot value | Meaning |
213
+ |---|---|
214
+ | A named allele | The selected database allele. |
215
+ | `-` | No second chromosome slot in the inferred single-copy region. |
216
+ | An absent-gene subtype, e.g. `RHAG*01N` | The database's designation for a missing gene copy without naming a specific breakpoint-defined allele. |
217
+ | `Novel_gene_deletion` | A missing gene copy for which no applicable database absence subtype is available. GT-based use depends on the caller convention above. |
218
+ | `Undetermined` | An allele slot that could not be named. Both slots can be undetermined when the blood group cannot be interpreted. |
219
+
220
+ `allele/Undetermined` retains one resolved slot. `Undetermined/Undetermined` can
221
+ represent a whole-group refusal; it does not establish the physical copy count.
222
+ Neither is a database allele.
223
+
224
+ Genotype alternatives are comma-separated. Phenotype alternatives are listed
225
+ independently and can be deduplicated, so entries must not be joined by position
226
+ between files. A slash can be part of a phenotype name.
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
+
247
+ Malformed retained GTs fail the affected sample and are reported with a named error;
248
+ the other samples in a cohort or directory can continue. Shared header/FORMAT
249
+ problems can prevent loading an input file. A nonzero process exit and the log must
250
+ be reviewed even when some result files were written.
251
+
252
+ ### PDF reports
253
+
254
+ `--PDFs` writes reports to `<output prefix>_PDFs/`. Each report preserves the exact
255
+ sample identity used in the TSVs, including suffixes and letter case.
256
+
257
+ ## Database v2.5.2
258
+
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
260
+ used by inference. It is curated against ISBT definitions and includes explicit
261
+ modelling and nomenclature choices. Package and database versions are reported
262
+ separately by `--version`.
263
+
264
+ ## Documentation and reporting issues
265
+
266
+ This README describes the v2.4.5 input and output contract. Longer PDF worked
267
+ examples attached to earlier releases are historical and may describe earlier
268
+ behavior; use the version-matched contract here when interpreting current output.
269
+
270
+ When reporting an issue, include the package/database versions, genome build,
271
+ command, and the complete affected sample/blood-group debug block where shareable.
272
+ State the caller and its genotype/copy-number convention. Expected answers can
273
+ require biological adjudication; a successful run or agreement with stored gold
274
+ does not establish clinical validity.
rbceq2-2.4.5/README.md ADDED
@@ -0,0 +1,247 @@
1
+ <table>
2
+ <tr>
3
+ <td>
4
+ <h1>RBCeq2: blood group allele inference</h1>
5
+ </td>
6
+ <td align="right">
7
+ <img src="images/Lifeblood-R_Primary_Keyline_RGB.jpg" alt="Lifeblood Logo" width="150">
8
+ </td>
9
+ </tr>
10
+ </table>
11
+
12
+ > [!WARNING]
13
+ > NOT FOR CLINICAL USE
14
+
15
+ ## Version v2.4.5
16
+
17
+ RBCeq2 infers blood-group genotypes and phenotypes from supplied variant calls using
18
+ the curated ISBT allele definitions distributed with the package. Deterministic
19
+ rules select and exclude candidate alleles and pairs; `--debug` records the evidence
20
+ and named exclusions behind the result.
21
+
22
+ ## Install and run
23
+
24
+ Python 3.12 or newer is required.
25
+
26
+ ```bash
27
+ python -m pip install rbceq2==2.4.5
28
+ rbceq2 --version
29
+ rbceq2 --vcf sample.vcf.gz --out result --reference_genome GRCh38 --debug
30
+ ```
31
+
32
+ Supply `GRCh37` or `GRCh38` to match the input coordinates. A single-sample VCF,
33
+ multi-sample VCF, or directory of separate `.vcf`/`.vcf.gz` files can be supplied.
34
+ Both ordinary gzip and uncompressed VCF input are read. For a directory:
35
+
36
+ ```bash
37
+ rbceq2 --vcf samples/ --out cohort --reference_genome GRCh38 --processes 4 --debug
38
+ ```
39
+
40
+ Use `rbceq2 --help` for all current options. Useful switches include:
41
+
42
+ | Option | Purpose |
43
+ |---|---|
44
+ | `--phased` | Use genotype phasing and phase-set information where available. |
45
+ | `--RH` | Include RHD/RHCE for the supported inputs described below. |
46
+ | `--HPAs` | Include human platelet antigen results. |
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. |
49
+ | `--validate` | Run additional VCF format checks. Basic input checks always run. |
50
+ | `--PDFs` | Generate per-sample PDF reports. |
51
+ | `--unused_variants` | Also write `result_unused_variants.tsv`, described under Outputs. Off by default. |
52
+ | `--min_size` | Minimum indel/SV size for fuzzy structural matching; default 10. |
53
+ | `--processes` | Worker processes; default 1. Large input loading also uses memory. |
54
+
55
+ ## Input contract
56
+
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.
64
+
65
+ GT must be the first FORMAT key when the row is used for inference. Called indices
66
+ must refer to REF (`0`) or an ALT declared by that row. Missing alleles use `.`.
67
+ Supported GT spellings use `/` or `|` between canonical integer indices; initial
68
+ phasing separators and leading-zero indices are explicitly unsupported.
69
+
70
+ Small-variant multiallelic records are processed into per-ALT calls internally.
71
+ Some reference-containing multiallelic configurations can remain partially
72
+ unresolved. Inspect `Undetermined` results and normalize such sites upstream where
73
+ appropriate. Mixed symbolic structural/small-variant records need caller-specific
74
+ assessment and are not a general supported input route.
75
+
76
+
77
+ ### Chromosome copies and gene copies
78
+
79
+ These are different statements and lead to different output shapes:
80
+
81
+ - A valid called haploid GT outside PAR on X/Y supplies per-sample evidence for one
82
+ chromosome in that region.
83
+ - Gene copy number can be read from GT ploidy only when the upstream caller
84
+ explicitly uses that convention.
85
+
86
+ Called structural deletions are evaluated against the curated database and can
87
+ constrain which chromosome carries an overlapping allele. The deletion's presence
88
+ and the gene-copy interpretation inferred from GT are kept distinct.
89
+
90
+ ### RHD and RHCE
91
+
92
+ Use `--RH` for long-read VCFs with structural-variant information, or for callers
93
+ that explicitly encode RH gene copy number as GT ploidy. Ordinary short-read
94
+ variant calls without either source of information are unsupported for RH
95
+ inference because of the similarity between RHD and RHCE.
96
+
97
+ Compatibility depends on the caller's stated encoding convention. Synthetic
98
+ examples establish the software's behavior; they do not establish compatibility
99
+ with every caller.
100
+
101
+ ### Structural-variant selection
102
+
103
+ Structural variants are fuzzy matched against allele definitions for the selected
104
+ `--reference_genome`.
105
+
106
+ ### FILTER and missing data
107
+
108
+ By default, `PASS` and absent filtering (`.` or empty) do not exclude an allele.
109
+ Other FILTER values are classified: recognized values unrelated to call correctness
110
+ can be retained; call-correctness failures and unrecognized values can exclude.
111
+ Unrecognized values are named in warnings. `--no_filter` bypasses this FILTER-based
112
+ exclusion, while genotype validity and inference rules remain active.
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
+
123
+ A no-call such as `.`, `./.`, or a partial missing GT becomes `NO_DATA` and alleles
124
+ requiring that uncalled variant are excluded by name. All nonmissing indices must
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.
128
+
129
+ **A reference output does not establish sequencing coverage.** Missing records can
130
+ lead to reference defaults, and a no-call can still reach a reference fallback when
131
+ no candidate remains. Inspect the debug evidence and exclusions; a fallback is not
132
+ a measured homozygous-reference call.
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
+
172
+ ## Outputs and interpretation
173
+
174
+ With `--out result`, the main outputs are:
175
+
176
+ - `result_geno.tsv`
177
+ - `result_pheno_numeric.tsv`
178
+ - `result_pheno_alphanumeric.tsv`
179
+ - `result_<run UUID>_log.txt`
180
+
181
+ The first TSV column identifies the sample; its heading contains the run UUID.
182
+ Cohort input uses the VCF sample names. Single-file and directory input uses the
183
+ filename with its final suffix removed, so `sample.vcf.gz` is named `sample.vcf`.
184
+
185
+ | Slot value | Meaning |
186
+ |---|---|
187
+ | A named allele | The selected database allele. |
188
+ | `-` | No second chromosome slot in the inferred single-copy region. |
189
+ | An absent-gene subtype, e.g. `RHAG*01N` | The database's designation for a missing gene copy without naming a specific breakpoint-defined allele. |
190
+ | `Novel_gene_deletion` | A missing gene copy for which no applicable database absence subtype is available. GT-based use depends on the caller convention above. |
191
+ | `Undetermined` | An allele slot that could not be named. Both slots can be undetermined when the blood group cannot be interpreted. |
192
+
193
+ `allele/Undetermined` retains one resolved slot. `Undetermined/Undetermined` can
194
+ represent a whole-group refusal; it does not establish the physical copy count.
195
+ Neither is a database allele.
196
+
197
+ Genotype alternatives are comma-separated. Phenotype alternatives are listed
198
+ independently and can be deduplicated, so entries must not be joined by position
199
+ between files. A slash can be part of a phenotype name.
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
+
220
+ Malformed retained GTs fail the affected sample and are reported with a named error;
221
+ the other samples in a cohort or directory can continue. Shared header/FORMAT
222
+ problems can prevent loading an input file. A nonzero process exit and the log must
223
+ be reviewed even when some result files were written.
224
+
225
+ ### PDF reports
226
+
227
+ `--PDFs` writes reports to `<output prefix>_PDFs/`. Each report preserves the exact
228
+ sample identity used in the TSVs, including suffixes and letter case.
229
+
230
+ ## Database v2.5.2
231
+
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
233
+ used by inference. It is curated against ISBT definitions and includes explicit
234
+ modelling and nomenclature choices. Package and database versions are reported
235
+ separately by `--version`.
236
+
237
+ ## Documentation and reporting issues
238
+
239
+ This README describes the v2.4.5 input and output contract. Longer PDF worked
240
+ examples attached to earlier releases are historical and may describe earlier
241
+ behavior; use the version-matched contract here when interpreting current output.
242
+
243
+ When reporting an issue, include the package/database versions, genome build,
244
+ command, and the complete affected sample/blood-group debug block where shareable.
245
+ State the caller and its genotype/copy-number convention. Expected answers can
246
+ require biological adjudication; a successful run or agreement with stored gold
247
+ does not establish clinical validity.
@@ -1,15 +1,16 @@
1
1
  # pyproject.toml
2
2
 
3
3
  [build-system]
4
- requires = ["setuptools>=61.0"] # Minimum version of setuptools needed
4
+ requires = ["setuptools>=77.0.3"]
5
5
  build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "rbceq2"
9
- version = "2.4.3"
9
+ version = "2.4.5"
10
10
  description = "Call ISBT alleles from VCF/s"
11
11
  readme = "README.md"
12
- license = { file = "LICENSE" }
12
+ license = "MIT"
13
+ license-files = ["LICENSE"]
13
14
  requires-python = ">=3.12"
14
15
  authors = [
15
16
  { name = "Liam McIntyre", email = "limcintyre@redcrossblood.org.au" }
@@ -17,7 +18,6 @@ authors = [
17
18
  classifiers = [
18
19
  "Programming Language :: Python :: 3",
19
20
  "Programming Language :: Python :: 3.12",
20
- "License :: OSI Approved :: MIT License",
21
21
  "Operating System :: OS Independent",
22
22
  "Intended Audience :: Science/Research",
23
23
  "Intended Audience :: Developers",
@@ -25,7 +25,7 @@ classifiers = [
25
25
  ]
26
26
  dependencies = [
27
27
  "pandas>=2.2.2",
28
- "polars>=0.20.26",
28
+ "polars>=0.20.31",
29
29
  "icecream>=2.1",
30
30
  "loguru>=0.7.2",
31
31
  "pyarrow>=18.1",