RBCeq2 2.4.3__tar.gz → 2.4.4__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.
- rbceq2-2.4.4/CITATION.cff +39 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/MANIFEST.in +2 -1
- rbceq2-2.4.4/PKG-INFO +202 -0
- rbceq2-2.4.4/README.md +175 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/pyproject.toml +5 -5
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/IO/PDF_reports.py +83 -48
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/IO/encoders.py +0 -913
- rbceq2-2.4.4/src/rbceq2/IO/record_data.py +349 -0
- rbceq2-2.4.4/src/rbceq2/IO/vcf.py +1668 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/core_logic/alleles.py +167 -20
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/core_logic/co_existing.py +10 -18
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/core_logic/constants.py +142 -9
- rbceq2-2.4.4/src/rbceq2/core_logic/data_procesing.py +2779 -0
- rbceq2-2.4.4/src/rbceq2/core_logic/filter_semantics.py +158 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/core_logic/large_variants.py +81 -150
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/core_logic/utils.py +71 -39
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/db/db.py +365 -57
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/filters/geno.py +653 -87
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/filters/knops.py +5 -137
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/filters/phased.py +602 -146
- rbceq2-2.4.4/src/rbceq2/filters/shared_filter_functionality.py +182 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/main.py +259 -46
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/phenotype/antigens.py +34 -42
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/phenotype/choose_pheno.py +32 -50
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/resources/db.tsv +7 -7
- rbceq2-2.4.4/src/rbceq2/resources/filter_values.tsv +27 -0
- rbceq2-2.4.4/src/rbceq2.egg-info/PKG-INFO +202 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2.egg-info/SOURCES.txt +21 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2.egg-info/requires.txt +1 -1
- rbceq2-2.4.4/tests/test_VCF.py +1259 -0
- rbceq2-2.4.4/tests/test_allele_coverage.py +249 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/tests/test_alleles.py +128 -5
- {rbceq2-2.4.3 → rbceq2-2.4.4}/tests/test_ants.py +3 -1
- {rbceq2-2.4.3 → rbceq2-2.4.4}/tests/test_choose_pheno.py +57 -1
- {rbceq2-2.4.3 → rbceq2-2.4.4}/tests/test_coexisting.py +85 -26
- {rbceq2-2.4.3 → rbceq2-2.4.4}/tests/test_data_processing.py +1308 -329
- {rbceq2-2.4.3 → rbceq2-2.4.4}/tests/test_db.py +97 -0
- rbceq2-2.4.4/tests/test_deletion_phase_seed.py +167 -0
- rbceq2-2.4.4/tests/test_deletion_placement.py +123 -0
- rbceq2-2.4.4/tests/test_duplicate_row_agreement.py +91 -0
- rbceq2-2.4.4/tests/test_filter_semantics.py +167 -0
- rbceq2-2.4.4/tests/test_filters_phase.py +1836 -0
- rbceq2-2.4.4/tests/test_fut3_secretor.py +104 -0
- rbceq2-2.4.4/tests/test_fy_null_token.py +82 -0
- rbceq2-2.4.4/tests/test_geno_filters.py +1550 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/tests/test_large_variants.py +5 -5
- rbceq2-2.4.4/tests/test_locus_copies.py +763 -0
- rbceq2-2.4.4/tests/test_main.py +65 -0
- rbceq2-2.4.4/tests/test_multiallelic.py +270 -0
- rbceq2-2.4.4/tests/test_pdf.py +260 -0
- rbceq2-2.4.4/tests/test_phase_evidence.py +232 -0
- rbceq2-2.4.4/tests/test_phase_flip_invariance.py +600 -0
- rbceq2-2.4.4/tests/test_phase_set_provenance.py +125 -0
- rbceq2-2.4.4/tests/test_ploidy.py +590 -0
- rbceq2-2.4.4/tests/test_record_data.py +80 -0
- rbceq2-2.4.4/tests/test_sv_build_selection.py +83 -0
- rbceq2-2.4.4/tests/test_sv_match_ambiguity.py +158 -0
- rbceq2-2.4.4/tests/test_sv_match_ties.py +73 -0
- rbceq2-2.4.4/tests/test_sv_provenance.py +170 -0
- rbceq2-2.4.3/PKG-INFO +0 -103
- rbceq2-2.4.3/README.md +0 -69
- rbceq2-2.4.3/src/rbceq2/IO/record_data.py +0 -171
- rbceq2-2.4.3/src/rbceq2/IO/vcf.py +0 -640
- rbceq2-2.4.3/src/rbceq2/core_logic/data_procesing.py +0 -1559
- rbceq2-2.4.3/src/rbceq2/filters/shared_filter_functionality.py +0 -108
- rbceq2-2.4.3/src/rbceq2.egg-info/PKG-INFO +0 -103
- rbceq2-2.4.3/tests/test_VCF.py +0 -340
- rbceq2-2.4.3/tests/test_filters_phase.py +0 -308
- rbceq2-2.4.3/tests/test_geno_filters.py +0 -813
- rbceq2-2.4.3/tests/test_main.py +0 -5
- rbceq2-2.4.3/tests/test_pdf.py +0 -101
- {rbceq2-2.4.3 → rbceq2-2.4.4}/LICENSE +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/setup.cfg +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/IO/__init__.py +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/IO/validation.py +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/__init__.py +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/core_logic/__init__.py +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/db/__init__.py +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/filters/__init__.py +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2/phenotype/__init__.py +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2.egg-info/dependency_links.txt +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2.egg-info/entry_points.txt +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/src/rbceq2.egg-info/top_level.txt +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/tests/test_IO.py +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/tests/test_co_filters.py +0 -0
- {rbceq2-2.4.3 → rbceq2-2.4.4}/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.4
|
|
34
|
+
date-released: 2026-09-16
|
|
35
|
+
url: "https://github.com/liammcintyre/RBCeq2"
|
|
36
|
+
repository-code: "https://github.com/liammcintyre/RBCeq2.git"
|
|
37
|
+
license: MIT
|
|
38
|
+
keywords: [bioinformatics, blood-group, genomics]
|
|
39
|
+
type: software
|
rbceq2-2.4.4/PKG-INFO
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rbceq2
|
|
3
|
+
Version: 2.4.4
|
|
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.4
|
|
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.4
|
|
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
|
+
| `--validate` | Run additional VCF format checks. Basic input checks always run. |
|
|
76
|
+
| `--PDFs` | Generate per-sample PDF reports. |
|
|
77
|
+
| `--min_size` | Minimum indel/SV size for fuzzy structural matching; default 10. |
|
|
78
|
+
| `--processes` | Worker processes; default 1. Large input loading also uses memory. |
|
|
79
|
+
|
|
80
|
+
## Input contract
|
|
81
|
+
|
|
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.
|
|
87
|
+
|
|
88
|
+
GT must be the first FORMAT key when the row is used for inference. Called indices
|
|
89
|
+
must refer to REF (`0`) or an ALT declared by that row. Missing alleles use `.`.
|
|
90
|
+
Supported GT spellings use `/` or `|` between canonical integer indices; initial
|
|
91
|
+
phasing separators and leading-zero indices are explicitly unsupported.
|
|
92
|
+
|
|
93
|
+
Small-variant multiallelic records are processed into per-ALT calls internally.
|
|
94
|
+
Some reference-containing multiallelic configurations can remain partially
|
|
95
|
+
unresolved. Inspect `Undetermined` results and normalize such sites upstream where
|
|
96
|
+
appropriate. Mixed symbolic structural/small-variant records need caller-specific
|
|
97
|
+
assessment and are not a general supported input route.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
### Chromosome copies and gene copies
|
|
101
|
+
|
|
102
|
+
These are different statements and lead to different output shapes:
|
|
103
|
+
|
|
104
|
+
- A valid called haploid GT outside PAR on X/Y supplies per-sample evidence for one
|
|
105
|
+
chromosome in that region.
|
|
106
|
+
- Gene copy number can be read from GT ploidy only when the upstream caller
|
|
107
|
+
explicitly uses that convention.
|
|
108
|
+
|
|
109
|
+
Called structural deletions are evaluated against the curated database and can
|
|
110
|
+
constrain which chromosome carries an overlapping allele. The deletion's presence
|
|
111
|
+
and the gene-copy interpretation inferred from GT are kept distinct.
|
|
112
|
+
|
|
113
|
+
### RHD and RHCE
|
|
114
|
+
|
|
115
|
+
Use `--RH` for long-read VCFs with structural-variant information, or for callers
|
|
116
|
+
that explicitly encode RH gene copy number as GT ploidy. Ordinary short-read
|
|
117
|
+
variant calls without either source of information are unsupported for RH
|
|
118
|
+
inference because of the similarity between RHD and RHCE.
|
|
119
|
+
|
|
120
|
+
Compatibility depends on the caller's stated encoding convention. Synthetic
|
|
121
|
+
examples establish the software's behavior; they do not establish compatibility
|
|
122
|
+
with every caller.
|
|
123
|
+
|
|
124
|
+
### Structural-variant selection
|
|
125
|
+
|
|
126
|
+
Structural variants are fuzzy matched against allele definitions for the selected
|
|
127
|
+
`--reference_genome`.
|
|
128
|
+
|
|
129
|
+
### FILTER and missing data
|
|
130
|
+
|
|
131
|
+
By default, `PASS` and absent filtering (`.` or empty) do not exclude an allele.
|
|
132
|
+
Other FILTER values are classified: recognized values unrelated to call correctness
|
|
133
|
+
can be retained; call-correctness failures and unrecognized values can exclude.
|
|
134
|
+
Unrecognized values are named in warnings. `--no_filter` bypasses this FILTER-based
|
|
135
|
+
exclusion, while genotype validity and inference rules remain active.
|
|
136
|
+
|
|
137
|
+
A no-call such as `.`, `./.`, or a partial missing GT becomes `NO_DATA` and alleles
|
|
138
|
+
requiring that uncalled variant are excluded by name. All nonmissing indices must
|
|
139
|
+
still be valid for the row.
|
|
140
|
+
|
|
141
|
+
**A reference output does not establish sequencing coverage.** Missing records can
|
|
142
|
+
lead to reference defaults, and a no-call can still reach a reference fallback when
|
|
143
|
+
no candidate remains. Inspect the debug evidence and exclusions; a fallback is not
|
|
144
|
+
a measured homozygous-reference call.
|
|
145
|
+
|
|
146
|
+
## Outputs and interpretation
|
|
147
|
+
|
|
148
|
+
With `--out result`, the main outputs are:
|
|
149
|
+
|
|
150
|
+
- `result_geno.tsv`
|
|
151
|
+
- `result_pheno_numeric.tsv`
|
|
152
|
+
- `result_pheno_alphanumeric.tsv`
|
|
153
|
+
- `result_<run UUID>_log.txt`
|
|
154
|
+
|
|
155
|
+
The first TSV column identifies the sample; its heading contains the run UUID.
|
|
156
|
+
Cohort input uses the VCF sample names. Single-file and directory input uses the
|
|
157
|
+
filename with its final suffix removed, so `sample.vcf.gz` is named `sample.vcf`.
|
|
158
|
+
|
|
159
|
+
| Slot value | Meaning |
|
|
160
|
+
|---|---|
|
|
161
|
+
| A named allele | The selected database allele. |
|
|
162
|
+
| `-` | No second chromosome slot in the inferred single-copy region. |
|
|
163
|
+
| An absent-gene subtype, e.g. `RHAG*01N` | The database's designation for a missing gene copy without naming a specific breakpoint-defined allele. |
|
|
164
|
+
| `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. |
|
|
165
|
+
| `Undetermined` | An allele slot that could not be named. Both slots can be undetermined when the blood group cannot be interpreted. |
|
|
166
|
+
|
|
167
|
+
`allele/Undetermined` retains one resolved slot. `Undetermined/Undetermined` can
|
|
168
|
+
represent a whole-group refusal; it does not establish the physical copy count.
|
|
169
|
+
Neither is a database allele.
|
|
170
|
+
|
|
171
|
+
Genotype alternatives are comma-separated. Phenotype alternatives are listed
|
|
172
|
+
independently and can be deduplicated, so entries must not be joined by position
|
|
173
|
+
between files. A slash can be part of a phenotype name.
|
|
174
|
+
|
|
175
|
+
Malformed retained GTs fail the affected sample and are reported with a named error;
|
|
176
|
+
the other samples in a cohort or directory can continue. Shared header/FORMAT
|
|
177
|
+
problems can prevent loading an input file. A nonzero process exit and the log must
|
|
178
|
+
be reviewed even when some result files were written.
|
|
179
|
+
|
|
180
|
+
### PDF reports
|
|
181
|
+
|
|
182
|
+
`--PDFs` writes reports to `<output prefix>_PDFs/`. Each report preserves the exact
|
|
183
|
+
sample identity used in the TSVs, including suffixes and letter case.
|
|
184
|
+
|
|
185
|
+
## Database v2.5.1
|
|
186
|
+
|
|
187
|
+
The packaged [db.tsv](src/rbceq2/resources/db.tsv) is the source of allele definitions
|
|
188
|
+
used by inference. It is curated against ISBT definitions and includes explicit
|
|
189
|
+
modelling and nomenclature choices. Package and database versions are reported
|
|
190
|
+
separately by `--version`.
|
|
191
|
+
|
|
192
|
+
## Documentation and reporting issues
|
|
193
|
+
|
|
194
|
+
This README describes the v2.4.4 input and output contract. Longer PDF worked
|
|
195
|
+
examples attached to earlier releases are historical and may describe earlier
|
|
196
|
+
behavior; use the version-matched contract here when interpreting current output.
|
|
197
|
+
|
|
198
|
+
When reporting an issue, include the package/database versions, genome build,
|
|
199
|
+
command, and the complete affected sample/blood-group debug block where shareable.
|
|
200
|
+
State the caller and its genotype/copy-number convention. Expected answers can
|
|
201
|
+
require biological adjudication; a successful run or agreement with stored gold
|
|
202
|
+
does not establish clinical validity.
|
rbceq2-2.4.4/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
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.4
|
|
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.4
|
|
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
|
+
| `--validate` | Run additional VCF format checks. Basic input checks always run. |
|
|
49
|
+
| `--PDFs` | Generate per-sample PDF reports. |
|
|
50
|
+
| `--min_size` | Minimum indel/SV size for fuzzy structural matching; default 10. |
|
|
51
|
+
| `--processes` | Worker processes; default 1. Large input loading also uses memory. |
|
|
52
|
+
|
|
53
|
+
## Input contract
|
|
54
|
+
|
|
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.
|
|
60
|
+
|
|
61
|
+
GT must be the first FORMAT key when the row is used for inference. Called indices
|
|
62
|
+
must refer to REF (`0`) or an ALT declared by that row. Missing alleles use `.`.
|
|
63
|
+
Supported GT spellings use `/` or `|` between canonical integer indices; initial
|
|
64
|
+
phasing separators and leading-zero indices are explicitly unsupported.
|
|
65
|
+
|
|
66
|
+
Small-variant multiallelic records are processed into per-ALT calls internally.
|
|
67
|
+
Some reference-containing multiallelic configurations can remain partially
|
|
68
|
+
unresolved. Inspect `Undetermined` results and normalize such sites upstream where
|
|
69
|
+
appropriate. Mixed symbolic structural/small-variant records need caller-specific
|
|
70
|
+
assessment and are not a general supported input route.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Chromosome copies and gene copies
|
|
74
|
+
|
|
75
|
+
These are different statements and lead to different output shapes:
|
|
76
|
+
|
|
77
|
+
- A valid called haploid GT outside PAR on X/Y supplies per-sample evidence for one
|
|
78
|
+
chromosome in that region.
|
|
79
|
+
- Gene copy number can be read from GT ploidy only when the upstream caller
|
|
80
|
+
explicitly uses that convention.
|
|
81
|
+
|
|
82
|
+
Called structural deletions are evaluated against the curated database and can
|
|
83
|
+
constrain which chromosome carries an overlapping allele. The deletion's presence
|
|
84
|
+
and the gene-copy interpretation inferred from GT are kept distinct.
|
|
85
|
+
|
|
86
|
+
### RHD and RHCE
|
|
87
|
+
|
|
88
|
+
Use `--RH` for long-read VCFs with structural-variant information, or for callers
|
|
89
|
+
that explicitly encode RH gene copy number as GT ploidy. Ordinary short-read
|
|
90
|
+
variant calls without either source of information are unsupported for RH
|
|
91
|
+
inference because of the similarity between RHD and RHCE.
|
|
92
|
+
|
|
93
|
+
Compatibility depends on the caller's stated encoding convention. Synthetic
|
|
94
|
+
examples establish the software's behavior; they do not establish compatibility
|
|
95
|
+
with every caller.
|
|
96
|
+
|
|
97
|
+
### Structural-variant selection
|
|
98
|
+
|
|
99
|
+
Structural variants are fuzzy matched against allele definitions for the selected
|
|
100
|
+
`--reference_genome`.
|
|
101
|
+
|
|
102
|
+
### FILTER and missing data
|
|
103
|
+
|
|
104
|
+
By default, `PASS` and absent filtering (`.` or empty) do not exclude an allele.
|
|
105
|
+
Other FILTER values are classified: recognized values unrelated to call correctness
|
|
106
|
+
can be retained; call-correctness failures and unrecognized values can exclude.
|
|
107
|
+
Unrecognized values are named in warnings. `--no_filter` bypasses this FILTER-based
|
|
108
|
+
exclusion, while genotype validity and inference rules remain active.
|
|
109
|
+
|
|
110
|
+
A no-call such as `.`, `./.`, or a partial missing GT becomes `NO_DATA` and alleles
|
|
111
|
+
requiring that uncalled variant are excluded by name. All nonmissing indices must
|
|
112
|
+
still be valid for the row.
|
|
113
|
+
|
|
114
|
+
**A reference output does not establish sequencing coverage.** Missing records can
|
|
115
|
+
lead to reference defaults, and a no-call can still reach a reference fallback when
|
|
116
|
+
no candidate remains. Inspect the debug evidence and exclusions; a fallback is not
|
|
117
|
+
a measured homozygous-reference call.
|
|
118
|
+
|
|
119
|
+
## Outputs and interpretation
|
|
120
|
+
|
|
121
|
+
With `--out result`, the main outputs are:
|
|
122
|
+
|
|
123
|
+
- `result_geno.tsv`
|
|
124
|
+
- `result_pheno_numeric.tsv`
|
|
125
|
+
- `result_pheno_alphanumeric.tsv`
|
|
126
|
+
- `result_<run UUID>_log.txt`
|
|
127
|
+
|
|
128
|
+
The first TSV column identifies the sample; its heading contains the run UUID.
|
|
129
|
+
Cohort input uses the VCF sample names. Single-file and directory input uses the
|
|
130
|
+
filename with its final suffix removed, so `sample.vcf.gz` is named `sample.vcf`.
|
|
131
|
+
|
|
132
|
+
| Slot value | Meaning |
|
|
133
|
+
|---|---|
|
|
134
|
+
| A named allele | The selected database allele. |
|
|
135
|
+
| `-` | No second chromosome slot in the inferred single-copy region. |
|
|
136
|
+
| An absent-gene subtype, e.g. `RHAG*01N` | The database's designation for a missing gene copy without naming a specific breakpoint-defined allele. |
|
|
137
|
+
| `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. |
|
|
138
|
+
| `Undetermined` | An allele slot that could not be named. Both slots can be undetermined when the blood group cannot be interpreted. |
|
|
139
|
+
|
|
140
|
+
`allele/Undetermined` retains one resolved slot. `Undetermined/Undetermined` can
|
|
141
|
+
represent a whole-group refusal; it does not establish the physical copy count.
|
|
142
|
+
Neither is a database allele.
|
|
143
|
+
|
|
144
|
+
Genotype alternatives are comma-separated. Phenotype alternatives are listed
|
|
145
|
+
independently and can be deduplicated, so entries must not be joined by position
|
|
146
|
+
between files. A slash can be part of a phenotype name.
|
|
147
|
+
|
|
148
|
+
Malformed retained GTs fail the affected sample and are reported with a named error;
|
|
149
|
+
the other samples in a cohort or directory can continue. Shared header/FORMAT
|
|
150
|
+
problems can prevent loading an input file. A nonzero process exit and the log must
|
|
151
|
+
be reviewed even when some result files were written.
|
|
152
|
+
|
|
153
|
+
### PDF reports
|
|
154
|
+
|
|
155
|
+
`--PDFs` writes reports to `<output prefix>_PDFs/`. Each report preserves the exact
|
|
156
|
+
sample identity used in the TSVs, including suffixes and letter case.
|
|
157
|
+
|
|
158
|
+
## Database v2.5.1
|
|
159
|
+
|
|
160
|
+
The packaged [db.tsv](src/rbceq2/resources/db.tsv) is the source of allele definitions
|
|
161
|
+
used by inference. It is curated against ISBT definitions and includes explicit
|
|
162
|
+
modelling and nomenclature choices. Package and database versions are reported
|
|
163
|
+
separately by `--version`.
|
|
164
|
+
|
|
165
|
+
## Documentation and reporting issues
|
|
166
|
+
|
|
167
|
+
This README describes the v2.4.4 input and output contract. Longer PDF worked
|
|
168
|
+
examples attached to earlier releases are historical and may describe earlier
|
|
169
|
+
behavior; use the version-matched contract here when interpreting current output.
|
|
170
|
+
|
|
171
|
+
When reporting an issue, include the package/database versions, genome build,
|
|
172
|
+
command, and the complete affected sample/blood-group debug block where shareable.
|
|
173
|
+
State the caller and its genotype/copy-number convention. Expected answers can
|
|
174
|
+
require biological adjudication; a successful run or agreement with stored gold
|
|
175
|
+
does not establish clinical validity.
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# pyproject.toml
|
|
2
2
|
|
|
3
3
|
[build-system]
|
|
4
|
-
requires = ["setuptools>=
|
|
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.
|
|
9
|
+
version = "2.4.4"
|
|
10
10
|
description = "Call ISBT alleles from VCF/s"
|
|
11
11
|
readme = "README.md"
|
|
12
|
-
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.
|
|
28
|
+
"polars>=0.20.31",
|
|
29
29
|
"icecream>=2.1",
|
|
30
30
|
"loguru>=0.7.2",
|
|
31
31
|
"pyarrow>=18.1",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import hashlib
|
|
1
2
|
import html
|
|
2
3
|
import os
|
|
3
|
-
import re
|
|
4
4
|
from datetime import datetime
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Any, Dict, List, Optional, Set, Tuple
|
|
@@ -133,13 +133,30 @@ DEFAULT_ROW_COLOR_ODD = colors.Color(1.0, 1.0, 1.0) # White
|
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
def _normalize_sample_id(sample_id: str) -> str:
|
|
136
|
-
"""
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
"""Validate an exact sample ID without removing suffixes or converting types.
|
|
137
|
+
|
|
138
|
+
Raises:
|
|
139
|
+
ValueError: The identity is empty or is not a string.
|
|
140
|
+
"""
|
|
141
|
+
if not isinstance(sample_id, str) or not sample_id:
|
|
142
|
+
raise ValueError(f"PDF sample IDs must be nonempty strings: {sample_id!r}")
|
|
143
|
+
return sample_id
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _pdf_filename(sample_id: str) -> str:
|
|
147
|
+
"""Build a bounded ASCII filename tied to the complete, exact sample ID.
|
|
148
|
+
|
|
149
|
+
The readable prefix is for navigation; the full digest distinguishes IDs
|
|
150
|
+
whose prefixes sanitize alike, differ only in case, or exceed its length.
|
|
151
|
+
The name depends only on the identity, not the other samples in a run.
|
|
152
|
+
"""
|
|
153
|
+
sample_id = _normalize_sample_id(sample_id)
|
|
154
|
+
prefix = "".join(
|
|
155
|
+
c if c.isascii() and (c.isalnum() or c in "_-") else "_"
|
|
156
|
+
for c in sample_id[:48]
|
|
140
157
|
)
|
|
141
|
-
|
|
142
|
-
return
|
|
158
|
+
digest = hashlib.sha256(sample_id.encode("utf-8")).hexdigest()
|
|
159
|
+
return f"{prefix}__{digest}_BloodGroupReport.pdf"
|
|
143
160
|
|
|
144
161
|
|
|
145
162
|
def _format_cell_content(text: Optional[Any], separator: Optional[str] = None) -> str:
|
|
@@ -215,30 +232,32 @@ def _prepare_dataframes(
|
|
|
215
232
|
df_pheno_alpha: Optional[pd.DataFrame],
|
|
216
233
|
df_pheno_num: Optional[pd.DataFrame],
|
|
217
234
|
) -> Tuple[Dict[str, Optional[pd.DataFrame]], Set[str], Dict[str, str]]:
|
|
218
|
-
"""
|
|
235
|
+
"""Copy report frames while preserving exact, unique string sample identities.
|
|
236
|
+
|
|
237
|
+
No metadata column is inserted into the biological data. Missing rows in a
|
|
238
|
+
phenotype frame stay missing rather than borrowing another sample's row.
|
|
239
|
+
|
|
240
|
+
Raises:
|
|
241
|
+
ValueError: A frame contains an invalid or duplicate sample identity.
|
|
242
|
+
"""
|
|
219
243
|
dfs = {"genotype": df_genotypes, "alpha": df_pheno_alpha, "numeric": df_pheno_num}
|
|
220
244
|
processed_dfs: Dict[str, Optional[pd.DataFrame]] = {}
|
|
221
245
|
original_id_map: Dict[str, str] = {}
|
|
222
|
-
|
|
246
|
+
all_sample_ids: Set[str] = set()
|
|
223
247
|
|
|
224
248
|
for df_type, df in dfs.items():
|
|
225
249
|
if df is not None and not df.empty:
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
for i, norm_id in enumerate(df_processed["SampleID_Normalized"]):
|
|
234
|
-
if norm_id not in original_id_map:
|
|
235
|
-
original_id_map[norm_id] = original_ids[i]
|
|
236
|
-
|
|
237
|
-
processed_dfs[df_type] = df_processed
|
|
250
|
+
sample_ids = [_normalize_sample_id(sample) for sample in df.index]
|
|
251
|
+
if not df.index.is_unique:
|
|
252
|
+
duplicates = sorted(set(df.index[df.index.duplicated()]))
|
|
253
|
+
raise ValueError(f"Duplicate PDF sample IDs in {df_type}: {duplicates!r}")
|
|
254
|
+
processed_dfs[df_type] = df.copy()
|
|
255
|
+
all_sample_ids.update(sample_ids)
|
|
256
|
+
original_id_map.update({sample: sample for sample in sample_ids})
|
|
238
257
|
else:
|
|
239
258
|
processed_dfs[df_type] = None
|
|
240
259
|
|
|
241
|
-
return processed_dfs,
|
|
260
|
+
return processed_dfs, all_sample_ids, original_id_map
|
|
242
261
|
|
|
243
262
|
|
|
244
263
|
# --- PDF Styling and Content Generation ---
|
|
@@ -347,26 +366,22 @@ def _create_report_header(
|
|
|
347
366
|
story.append(Spacer(1, 0.1 * inch))
|
|
348
367
|
story.append(Paragraph("Not for clinical use", styles["warning"]))
|
|
349
368
|
story.append(Spacer(1, 0.2 * inch))
|
|
350
|
-
story.append(Paragraph(f"Sample ID: {original_id_display}", styles["heading"]))
|
|
369
|
+
story.append(Paragraph(f"Sample ID: {html.escape(original_id_display)}", styles["heading"]))
|
|
351
370
|
story.append(Spacer(1, 0.1 * inch))
|
|
352
371
|
|
|
353
372
|
|
|
354
373
|
def _get_data_for_sample(
|
|
355
374
|
norm_id: str, processed_dfs: Dict[str, Optional[pd.DataFrame]]
|
|
356
375
|
) -> Tuple[Dict[str, Optional[pd.Series]], Set[str]]:
|
|
357
|
-
"""
|
|
376
|
+
"""Retrieve rows for an exact sample ID from the validated report frames."""
|
|
358
377
|
sample_data: Dict[str, Optional[pd.Series]] = {}
|
|
359
378
|
all_keys_for_sample: Set[str] = set()
|
|
360
379
|
|
|
361
380
|
for df_type, df in processed_dfs.items():
|
|
362
381
|
row_data: Optional[pd.Series] = None
|
|
363
|
-
if df is not None:
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
row_data = matching_rows.iloc[0].drop(
|
|
367
|
-
"SampleID_Normalized", errors="ignore"
|
|
368
|
-
)
|
|
369
|
-
all_keys_for_sample.update(row_data.index)
|
|
382
|
+
if df is not None and norm_id in df.index:
|
|
383
|
+
row_data = df.loc[norm_id]
|
|
384
|
+
all_keys_for_sample.update(row_data.index)
|
|
370
385
|
|
|
371
386
|
sample_data[df_type] = row_data
|
|
372
387
|
|
|
@@ -516,11 +531,8 @@ def _generate_pdf_report_for_sample(
|
|
|
516
531
|
output_dir: Path,
|
|
517
532
|
UUID: str,
|
|
518
533
|
) -> None:
|
|
519
|
-
"""
|
|
520
|
-
|
|
521
|
-
c if c.isalnum() or c in ("_", "-") else "_" for c in original_id_display
|
|
522
|
-
)
|
|
523
|
-
pdf_filename = os.path.join(output_dir, f"{safe_original_id}_BloodGroupReport.pdf")
|
|
534
|
+
"""Generate one PDF report, propagating rendering and write failures."""
|
|
535
|
+
pdf_filename = os.path.join(output_dir, _pdf_filename(original_id_display))
|
|
524
536
|
|
|
525
537
|
doc = BaseDocTemplate(
|
|
526
538
|
pdf_filename,
|
|
@@ -614,10 +626,7 @@ def _generate_pdf_report_for_sample(
|
|
|
614
626
|
story.extend(table_flowables)
|
|
615
627
|
|
|
616
628
|
# 6. Build the PDF
|
|
617
|
-
|
|
618
|
-
doc.build(story)
|
|
619
|
-
except Exception as e:
|
|
620
|
-
logger.error(f"ERROR generating PDF for {norm_id} ({original_id_display}): {e}")
|
|
629
|
+
doc.build(story)
|
|
621
630
|
|
|
622
631
|
|
|
623
632
|
# --- Main Orchestration Function ---
|
|
@@ -630,25 +639,43 @@ def generate_all_reports(
|
|
|
630
639
|
output_name: Path,
|
|
631
640
|
UUID: str,
|
|
632
641
|
) -> None:
|
|
633
|
-
"""
|
|
634
|
-
|
|
642
|
+
"""Generate every sample report and report any failures to the caller.
|
|
643
|
+
|
|
644
|
+
Successful reports are retained when another sample fails. Each failure is
|
|
645
|
+
logged with its sample identity before a combined error is raised.
|
|
646
|
+
|
|
647
|
+
Raises:
|
|
648
|
+
ValueError: Sample identities are invalid, duplicated, or map to one filename.
|
|
649
|
+
RuntimeError: One or more sample reports could not be generated.
|
|
650
|
+
"""
|
|
651
|
+
processed_dfs, all_sample_ids, original_id_map = _prepare_dataframes(
|
|
635
652
|
df_genotypes, df_pheno_alpha, df_pheno_num
|
|
636
653
|
)
|
|
637
654
|
|
|
638
|
-
if not
|
|
655
|
+
if not all_sample_ids:
|
|
639
656
|
logger.warning("No samples found in the input DataFrames. Exiting.")
|
|
640
657
|
return
|
|
641
658
|
|
|
642
|
-
num_samples = len(
|
|
643
|
-
logger.info(f"Found {num_samples} unique
|
|
659
|
+
num_samples = len(all_sample_ids)
|
|
660
|
+
logger.info(f"Found {num_samples} unique sample IDs.")
|
|
644
661
|
output_dir = f"{output_name}_PDFs"
|
|
645
662
|
|
|
663
|
+
filenames: Dict[str, str] = {}
|
|
664
|
+
for sample_id in sorted(all_sample_ids):
|
|
665
|
+
name = _pdf_filename(sample_id).casefold()
|
|
666
|
+
if name in filenames:
|
|
667
|
+
raise ValueError(
|
|
668
|
+
f"PDF filename collision for {filenames[name]!r} and {sample_id!r}"
|
|
669
|
+
)
|
|
670
|
+
filenames[name] = sample_id
|
|
671
|
+
|
|
646
672
|
os.makedirs(output_dir, exist_ok=True)
|
|
647
673
|
logger.info(f"Reports will be saved to '{os.path.abspath(output_dir)}'.")
|
|
648
674
|
|
|
649
675
|
styles = _setup_styles()
|
|
650
676
|
|
|
651
|
-
|
|
677
|
+
failed_samples: List[str] = []
|
|
678
|
+
for norm_id in sorted(list(all_sample_ids)):
|
|
652
679
|
original_id_display = original_id_map.get(norm_id, norm_id)
|
|
653
680
|
|
|
654
681
|
try:
|
|
@@ -657,5 +684,13 @@ def generate_all_reports(
|
|
|
657
684
|
)
|
|
658
685
|
except Exception as e:
|
|
659
686
|
logger.error(
|
|
660
|
-
f"
|
|
661
|
-
)
|
|
687
|
+
f"PDF generation failed for {original_id_display!r}: {e}"
|
|
688
|
+
)
|
|
689
|
+
failed_samples.append(original_id_display)
|
|
690
|
+
|
|
691
|
+
if failed_samples:
|
|
692
|
+
names = ", ".join(repr(sample) for sample in failed_samples)
|
|
693
|
+
raise RuntimeError(
|
|
694
|
+
f"Failed to generate {len(failed_samples)} PDF report(s): {names}. "
|
|
695
|
+
"See the log for each failure."
|
|
696
|
+
)
|