allelix 2.7.0__tar.gz → 2.7.1__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.
- {allelix-2.7.0/allelix.egg-info → allelix-2.7.1}/PKG-INFO +3 -3
- {allelix-2.7.0 → allelix-2.7.1}/README.md +2 -2
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/_resolution.py +86 -3
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/clinvar.py +41 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/cli/_helpers.py +20 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/cli/utility.py +136 -23
- {allelix-2.7.0 → allelix-2.7.1}/allelix/models.py +5 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/_helpers.py +30 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/ancestrydna.py +2 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/decodeme.py +2 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/ftdna.py +2 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/ftdna_famfinder.py +2 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/ftdna_illumina.py +2 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/livingdna.py +2 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/myhappygenes.py +7 -2
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/myheritage.py +2 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/twentythreeandme.py +2 -1
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/vcf.py +333 -55
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/__init__.py +60 -6
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/_pipeline.py +143 -16
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/diff.py +33 -4
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/high_value.py +34 -4
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/html.py +85 -47
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/json_report.py +10 -2
- {allelix-2.7.0 → allelix-2.7.1/allelix.egg-info}/PKG-INFO +3 -3
- {allelix-2.7.0 → allelix-2.7.1}/pyproject.toml +1 -1
- {allelix-2.7.0 → allelix-2.7.1}/LICENSE +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/MANIFEST.in +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/__init__.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/__init__.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/_placement.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/alphamissense.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/base.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/cadd.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/gnomad.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/gwas.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/pharmgkb.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/reference_fallback.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/rsid_identity.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/annotators/snpedia.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/attribution.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/cli/__init__.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/cli/_options.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/cli/analyze.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/cli/config.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/cli/db.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/cli/focused.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/compare.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/config.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/data/__init__.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/data/clinvar_clnsig_snapshot.yaml +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/data/high_value_snps.yaml +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/__init__.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/_versions.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/alphamissense_loader.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/cache_state.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/cadd_loader.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/cpic_loader.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/gnomad_loader.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/gwas_loader.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/loader_utils.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/manager.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/pharmgkb_loader.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/rsid_identity_loader.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/schema.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/snpedia_loader.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/snpedia_parser.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/databases/staging.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/exporters/__init__.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/exporters/plink.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/__init__.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/base.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/genesforgood.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/parsers/rsidlist.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/py.typed +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/_sources.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/association_text.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/build_text.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/clinvar_text.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/methylation.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/terminal.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/reports/vcf.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/utils/__init__.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/utils/allele.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/utils/build_detect.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/utils/markup.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix/utils/plausibility.py +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix.egg-info/SOURCES.txt +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix.egg-info/dependency_links.txt +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix.egg-info/entry_points.txt +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix.egg-info/requires.txt +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/allelix.egg-info/top_level.txt +0 -0
- {allelix-2.7.0 → allelix-2.7.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: allelix
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.1
|
|
4
4
|
Summary: Open-source genotype analysis toolkit. Format-agnostic ingestion, database-agnostic annotation, offline-first.
|
|
5
5
|
Author: Allelix
|
|
6
6
|
Maintainer-email: dial481 <dial481@users.noreply.github.com>
|
|
@@ -118,7 +118,7 @@ See [Development](#development) for source installs and running tests, [Managing
|
|
|
118
118
|
| deCODEme | ✓ | `deCODEme_scan.csv` (deCODE genetics, service closed 2013): comma-separated, a per-row `Strand` column; minus-strand calls are complemented to the plus strand. Build 36: decided from known-SNP positions, then run with position lookups off (ADR-0025). See [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#decodeme). |
|
|
119
119
|
| FTDNA Illumina raw | ✓ | Tab-delimited variant of the FTDNA export (distinct from the CSV format above). `RSID/CHROMOSOME/POSITION/RESULT` columns. Build 37 default when known-SNP positions are present but do not decide (subject to the stops and the GRCh36 exception in [How the genome build is decided](#how-the-genome-build-is-decided-and-why-a-run-can-stop)). |
|
|
120
120
|
| FTDNA FamFinder | ✓ | Third FTDNA file shape: tab-delimited with **separate `ALLELE1` / `ALLELE2` columns** instead of a concatenated `RESULT`. Detected by the `famfinder` substring in the file header plus the 5-column canonical header. Build 37 default when known-SNP positions are present but do not decide (subject to the stops and the GRCh36 exception in [How the genome build is decided](#how-the-genome-build-is-decided-and-why-a-run-can-stop)). |
|
|
121
|
-
| VCF / gVCF | ✓ | REF/ALT encoding, `0/1` genotype notation. A confident homozygous-reference call (`0/0`, `0|0`, haploid `0`) is read by ClinPGx, SNPedia and the GWAS Catalog as the same chip call would be (ADR-0064). A gVCF reference block (lines with `<NON_REF>` ALT and `END=` INFO) is not expanded for them. For ClinVar, a reference call matches only where the reference genome itself carries a ClinVar allele (Factor V Leiden on GRCh37, for example): there a `0/0` call, or a reference block that passes the genotype-quality gate, is assessed as homozygous for that allele. See [docs/formats.md, Reference calls in VCFs](https://github.com/allelix/allelix/blob/main/docs/formats.md#reference-calls-in-vcfs) (ADR-0039, ADR-0059). At high-value positions, a block with low genotype quality or no reads makes the position a no-call, and so does a gVCF position no record covers. High-value no-calls list the reason (for example `low_gq_block`, `no_coverage`, `filtered`, `low_gq_call`). A record counts for a high-value or panel rsID when it is at one of the rsID's identity placements with that placement's REF, whatever its ID or ALT; an rsID the identity table does not place is matched by ID (ADR-0055). A plain VCF has no reference blocks, so a position without a record is reported as unknown rather than as reference or as a no-call; at such a ClinVar site the report counts the positions no record covers, and names the high-value ones (such as CYP3A5*3 rs776746 on GRCh37) as not checked. Multi-sample files require `--sample <ID>`. Rows the variant caller rejected (FILTER other than `PASS` or `.`, or a selected sample whose FORMAT `FT` is not `PASS` or `.`) are skipped and counted in the report under each filter code; `--keep-filtered` keeps them (ADR-0060). A call with genotype quality below `--min-gq` (default 20) or with no reads (DP 0) is reported as a no-call. The spanning-deletion allele `*` is treated as symbolic: such calls are not assessed, and the report counts them and lists their positions. A half call (`./1`) is assessed on its called allele by ClinVar and the GWAS Catalog and shown as `T/.` with zygosity "Half call"; ClinPGx and SNPedia, which need both alleles, skip it. Malformed rows, rows without a genotype, genotypes naming an allele the record lacks and genotypes naming a symbolic allele such as `<NON_REF>` beside a real ALT are counted in the report; a no-call written `./.` stays a no-call (ADR-0047). A VCF that holds only structural-variant or copy-number records (such as a provider's separate `sv` / `cnv` file) is rejected with a message naming the file to use instead; see [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#sequencingcom-30x-whole-genome) for per-provider deliverables. A VCF whose header declares an imputation tool's fields (Minimac, Beagle, GLIMPSE) is labelled imputed in every report; see [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#imputed-vcfs). Streams via stdlib; `.vcf.gz` handled transparently. Optional `pip install allelix[vcf-index]` enables pysam-backed tabix random access for fast `extract --snps` on huge VCFs. |
|
|
121
|
+
| VCF / gVCF | ✓ | REF/ALT encoding, `0/1` genotype notation. A confident homozygous-reference call (`0/0`, `0|0`, haploid `0`) is read by ClinPGx, SNPedia and the GWAS Catalog as the same chip call would be (ADR-0064). A gVCF reference block (lines with `<NON_REF>` ALT and `END=` INFO) is not expanded for them. For ClinVar, a reference call matches only where the reference genome itself carries a ClinVar allele (Factor V Leiden on GRCh37, for example): there a `0/0` call, or a reference block that passes the genotype-quality gate, is assessed as homozygous for that allele. See [docs/formats.md, Reference calls in VCFs](https://github.com/allelix/allelix/blob/main/docs/formats.md#reference-calls-in-vcfs) (ADR-0039, ADR-0059). At high-value positions, a block with low genotype quality or no reads makes the position a no-call, and so does a gVCF position no record covers. High-value no-calls list the reason (for example `low_gq_block`, `no_coverage`, `filtered`, `low_gq_call`). A record counts for a high-value or panel rsID when it is at one of the rsID's identity placements with that placement's REF, whatever its ID or ALT; an rsID the identity table does not place is matched by ID (ADR-0055). A plain VCF has no reference blocks, so a position without a record is reported as unknown rather than as reference or as a no-call; at such a ClinVar site the report counts the positions no record covers, and names the high-value ones (such as CYP3A5*3 rs776746 on GRCh37) as not checked. Multi-sample files require `--sample <ID>`. Rows the variant caller rejected (FILTER other than `PASS` or `.`, or a selected sample whose FORMAT `FT` is not `PASS` or `.`) are skipped and counted in the report under each filter code; `--keep-filtered` keeps them (ADR-0060). A call with genotype quality below `--min-gq` (default 20) or with no reads (DP 0) is reported as a no-call. The spanning-deletion allele `*` is treated as symbolic: such calls are not assessed, and the report counts them and lists their positions. A standalone half call (`./1`) is assessed on its called allele by ClinVar and the GWAS Catalog and shown as `T/.` with zygosity "Half call"; ClinPGx and SNPedia, which need both alleles, skip it. Two complementary half calls at one site (`1/.` and `./1`) are one full call for every source, unless the two records name, or are found by position under, two different rsIDs: then each stays a half call under its own rsID ([docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#one-site-written-over-several-records)). Malformed rows, rows without a genotype, genotypes naming an allele the record lacks and genotypes naming a symbolic allele such as `<NON_REF>` beside a real ALT are counted in the report; a no-call written `./.` stays a no-call (ADR-0047). A VCF that holds only structural-variant or copy-number records (such as a provider's separate `sv` / `cnv` file) is rejected with a message naming the file to use instead; see [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#sequencingcom-30x-whole-genome) for per-provider deliverables. A VCF whose header declares an imputation tool's fields (Minimac, Beagle, GLIMPSE) is labelled imputed in every report; see [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#imputed-vcfs). Streams via stdlib; `.vcf.gz` handled transparently. Optional `pip install allelix[vcf-index]` enables pysam-backed tabix random access for fast `extract --snps` on huge VCFs. |
|
|
122
122
|
|
|
123
123
|
Files can be passed as delivered: gzipped (Family Tree DNA's `.csv.gz`, for example), or a zip holding one genotype file. A zip with several files, a password or an unusual compression stops with a message to unzip it first. Windows, Linux and old-Mac line endings are read; a leading byte order mark or blank line is ignored.
|
|
124
124
|
|
|
@@ -274,7 +274,7 @@ Genotyping arrays sometimes miscall very rare variants, most visibly as a homozy
|
|
|
274
274
|
|
|
275
275
|
⚠ means the call looks doubtful because the variant's frequency in gnomAD is at or under Allelix's limit for that call (under it for two copies): with the default limits in the table, two copies of an allele below 0.01%, or one copy of an allele that gnomAD lists with no carriers. A call this rare can be a genotyping or sequencing error; confirm it before relying on it. Allelix can only check variants with population counts in gnomAD, so no ⚠ is not a guarantee. The HTML report shows ⚠ next to a flagged genotype, with the reason on hover and in the detail panel. The terminal table marks implausible calls with ⚠ and suspicious ones with ?. A call that was not assessed gets no mark in either. JSON reports carry `plausibility` on every annotation (`plausible`, `suspicious`, `implausible` or `not_assessed`) and, when not assessed, `plausibility_reason` (`no_frequency`, `gnomad_not_run`, `chromosome`, `half_call` or `no_allele`; ADR-0050).
|
|
276
276
|
|
|
277
|
-
A call is not assessed when gnomAD has no frequency for the allele. Allelix's gnomAD cache covers exome sites with an rsID, so a missing value says nothing about rarity. Calls are also not assessed when the gnomAD database is skipped. Homozygous calls on X are not assessed because a male's single X reads as homozygous; heterozygous X calls are. A call the file itself declares as one copy (a one-letter array call such as 23andMe's male X calls, or a one-index VCF genotype) is shown as Hemizygous and assessed as one copy. Y and mitochondrial calls are not assessed. When records at one position disagree on ploidy (one copy in one record, two in another), each finding keeps its own record's genotype and zygosity, and the report counts them in a warning, `contradictory_calls` (ADR-0062). Confirm a flagged call with a clinical-grade test before relying on it.
|
|
277
|
+
A call is not assessed when gnomAD has no frequency for the allele. Allelix's gnomAD cache covers exome sites with an rsID, so a missing value says nothing about rarity. Calls are also not assessed when the gnomAD database is skipped. Homozygous calls on X are not assessed because a male's single X reads as homozygous; heterozygous X calls are. A call the file itself declares as one copy (a one-letter array call such as 23andMe's male X calls, or a one-index VCF genotype) is shown as Hemizygous and assessed as one copy. Y and mitochondrial calls are not assessed. When records at one position that are read on their own disagree on ploidy (one copy in one record, two in another), each finding keeps its own record's genotype and zygosity, and the report counts them in a warning, `contradictory_calls` (ADR-0062). Consecutive single-base records of one REF naming different ALTs are read together instead ([docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#one-site-written-over-several-records)): when two or more passing calls include a haploid call, the site is withheld and counted as `split_site_calls`; a rejected sibling does not cancel a passing call. Confirm a flagged call with a clinical-grade test before relying on it.
|
|
278
278
|
|
|
279
279
|
When three or more variants on chromosomes 1 to 22 are called homozygous for an allele ClinVar classifies as Pathogenic or Likely pathogenic, and are rare in gnomAD or were looked up there and are absent, the report warns at the top. A call gnomAD was not asked about (gnomAD not installed, or a GRCh37 allele the identity table cannot translate) does not count. This is counted before any display filter, so `--min-magnitude` cannot hide it (ADR-0050).
|
|
280
280
|
|
|
@@ -78,7 +78,7 @@ See [Development](#development) for source installs and running tests, [Managing
|
|
|
78
78
|
| deCODEme | ✓ | `deCODEme_scan.csv` (deCODE genetics, service closed 2013): comma-separated, a per-row `Strand` column; minus-strand calls are complemented to the plus strand. Build 36: decided from known-SNP positions, then run with position lookups off (ADR-0025). See [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#decodeme). |
|
|
79
79
|
| FTDNA Illumina raw | ✓ | Tab-delimited variant of the FTDNA export (distinct from the CSV format above). `RSID/CHROMOSOME/POSITION/RESULT` columns. Build 37 default when known-SNP positions are present but do not decide (subject to the stops and the GRCh36 exception in [How the genome build is decided](#how-the-genome-build-is-decided-and-why-a-run-can-stop)). |
|
|
80
80
|
| FTDNA FamFinder | ✓ | Third FTDNA file shape: tab-delimited with **separate `ALLELE1` / `ALLELE2` columns** instead of a concatenated `RESULT`. Detected by the `famfinder` substring in the file header plus the 5-column canonical header. Build 37 default when known-SNP positions are present but do not decide (subject to the stops and the GRCh36 exception in [How the genome build is decided](#how-the-genome-build-is-decided-and-why-a-run-can-stop)). |
|
|
81
|
-
| VCF / gVCF | ✓ | REF/ALT encoding, `0/1` genotype notation. A confident homozygous-reference call (`0/0`, `0|0`, haploid `0`) is read by ClinPGx, SNPedia and the GWAS Catalog as the same chip call would be (ADR-0064). A gVCF reference block (lines with `<NON_REF>` ALT and `END=` INFO) is not expanded for them. For ClinVar, a reference call matches only where the reference genome itself carries a ClinVar allele (Factor V Leiden on GRCh37, for example): there a `0/0` call, or a reference block that passes the genotype-quality gate, is assessed as homozygous for that allele. See [docs/formats.md, Reference calls in VCFs](https://github.com/allelix/allelix/blob/main/docs/formats.md#reference-calls-in-vcfs) (ADR-0039, ADR-0059). At high-value positions, a block with low genotype quality or no reads makes the position a no-call, and so does a gVCF position no record covers. High-value no-calls list the reason (for example `low_gq_block`, `no_coverage`, `filtered`, `low_gq_call`). A record counts for a high-value or panel rsID when it is at one of the rsID's identity placements with that placement's REF, whatever its ID or ALT; an rsID the identity table does not place is matched by ID (ADR-0055). A plain VCF has no reference blocks, so a position without a record is reported as unknown rather than as reference or as a no-call; at such a ClinVar site the report counts the positions no record covers, and names the high-value ones (such as CYP3A5*3 rs776746 on GRCh37) as not checked. Multi-sample files require `--sample <ID>`. Rows the variant caller rejected (FILTER other than `PASS` or `.`, or a selected sample whose FORMAT `FT` is not `PASS` or `.`) are skipped and counted in the report under each filter code; `--keep-filtered` keeps them (ADR-0060). A call with genotype quality below `--min-gq` (default 20) or with no reads (DP 0) is reported as a no-call. The spanning-deletion allele `*` is treated as symbolic: such calls are not assessed, and the report counts them and lists their positions. A half call (`./1`) is assessed on its called allele by ClinVar and the GWAS Catalog and shown as `T/.` with zygosity "Half call"; ClinPGx and SNPedia, which need both alleles, skip it. Malformed rows, rows without a genotype, genotypes naming an allele the record lacks and genotypes naming a symbolic allele such as `<NON_REF>` beside a real ALT are counted in the report; a no-call written `./.` stays a no-call (ADR-0047). A VCF that holds only structural-variant or copy-number records (such as a provider's separate `sv` / `cnv` file) is rejected with a message naming the file to use instead; see [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#sequencingcom-30x-whole-genome) for per-provider deliverables. A VCF whose header declares an imputation tool's fields (Minimac, Beagle, GLIMPSE) is labelled imputed in every report; see [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#imputed-vcfs). Streams via stdlib; `.vcf.gz` handled transparently. Optional `pip install allelix[vcf-index]` enables pysam-backed tabix random access for fast `extract --snps` on huge VCFs. |
|
|
81
|
+
| VCF / gVCF | ✓ | REF/ALT encoding, `0/1` genotype notation. A confident homozygous-reference call (`0/0`, `0|0`, haploid `0`) is read by ClinPGx, SNPedia and the GWAS Catalog as the same chip call would be (ADR-0064). A gVCF reference block (lines with `<NON_REF>` ALT and `END=` INFO) is not expanded for them. For ClinVar, a reference call matches only where the reference genome itself carries a ClinVar allele (Factor V Leiden on GRCh37, for example): there a `0/0` call, or a reference block that passes the genotype-quality gate, is assessed as homozygous for that allele. See [docs/formats.md, Reference calls in VCFs](https://github.com/allelix/allelix/blob/main/docs/formats.md#reference-calls-in-vcfs) (ADR-0039, ADR-0059). At high-value positions, a block with low genotype quality or no reads makes the position a no-call, and so does a gVCF position no record covers. High-value no-calls list the reason (for example `low_gq_block`, `no_coverage`, `filtered`, `low_gq_call`). A record counts for a high-value or panel rsID when it is at one of the rsID's identity placements with that placement's REF, whatever its ID or ALT; an rsID the identity table does not place is matched by ID (ADR-0055). A plain VCF has no reference blocks, so a position without a record is reported as unknown rather than as reference or as a no-call; at such a ClinVar site the report counts the positions no record covers, and names the high-value ones (such as CYP3A5*3 rs776746 on GRCh37) as not checked. Multi-sample files require `--sample <ID>`. Rows the variant caller rejected (FILTER other than `PASS` or `.`, or a selected sample whose FORMAT `FT` is not `PASS` or `.`) are skipped and counted in the report under each filter code; `--keep-filtered` keeps them (ADR-0060). A call with genotype quality below `--min-gq` (default 20) or with no reads (DP 0) is reported as a no-call. The spanning-deletion allele `*` is treated as symbolic: such calls are not assessed, and the report counts them and lists their positions. A standalone half call (`./1`) is assessed on its called allele by ClinVar and the GWAS Catalog and shown as `T/.` with zygosity "Half call"; ClinPGx and SNPedia, which need both alleles, skip it. Two complementary half calls at one site (`1/.` and `./1`) are one full call for every source, unless the two records name, or are found by position under, two different rsIDs: then each stays a half call under its own rsID ([docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#one-site-written-over-several-records)). Malformed rows, rows without a genotype, genotypes naming an allele the record lacks and genotypes naming a symbolic allele such as `<NON_REF>` beside a real ALT are counted in the report; a no-call written `./.` stays a no-call (ADR-0047). A VCF that holds only structural-variant or copy-number records (such as a provider's separate `sv` / `cnv` file) is rejected with a message naming the file to use instead; see [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#sequencingcom-30x-whole-genome) for per-provider deliverables. A VCF whose header declares an imputation tool's fields (Minimac, Beagle, GLIMPSE) is labelled imputed in every report; see [docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#imputed-vcfs). Streams via stdlib; `.vcf.gz` handled transparently. Optional `pip install allelix[vcf-index]` enables pysam-backed tabix random access for fast `extract --snps` on huge VCFs. |
|
|
82
82
|
|
|
83
83
|
Files can be passed as delivered: gzipped (Family Tree DNA's `.csv.gz`, for example), or a zip holding one genotype file. A zip with several files, a password or an unusual compression stops with a message to unzip it first. Windows, Linux and old-Mac line endings are read; a leading byte order mark or blank line is ignored.
|
|
84
84
|
|
|
@@ -234,7 +234,7 @@ Genotyping arrays sometimes miscall very rare variants, most visibly as a homozy
|
|
|
234
234
|
|
|
235
235
|
⚠ means the call looks doubtful because the variant's frequency in gnomAD is at or under Allelix's limit for that call (under it for two copies): with the default limits in the table, two copies of an allele below 0.01%, or one copy of an allele that gnomAD lists with no carriers. A call this rare can be a genotyping or sequencing error; confirm it before relying on it. Allelix can only check variants with population counts in gnomAD, so no ⚠ is not a guarantee. The HTML report shows ⚠ next to a flagged genotype, with the reason on hover and in the detail panel. The terminal table marks implausible calls with ⚠ and suspicious ones with ?. A call that was not assessed gets no mark in either. JSON reports carry `plausibility` on every annotation (`plausible`, `suspicious`, `implausible` or `not_assessed`) and, when not assessed, `plausibility_reason` (`no_frequency`, `gnomad_not_run`, `chromosome`, `half_call` or `no_allele`; ADR-0050).
|
|
236
236
|
|
|
237
|
-
A call is not assessed when gnomAD has no frequency for the allele. Allelix's gnomAD cache covers exome sites with an rsID, so a missing value says nothing about rarity. Calls are also not assessed when the gnomAD database is skipped. Homozygous calls on X are not assessed because a male's single X reads as homozygous; heterozygous X calls are. A call the file itself declares as one copy (a one-letter array call such as 23andMe's male X calls, or a one-index VCF genotype) is shown as Hemizygous and assessed as one copy. Y and mitochondrial calls are not assessed. When records at one position disagree on ploidy (one copy in one record, two in another), each finding keeps its own record's genotype and zygosity, and the report counts them in a warning, `contradictory_calls` (ADR-0062). Confirm a flagged call with a clinical-grade test before relying on it.
|
|
237
|
+
A call is not assessed when gnomAD has no frequency for the allele. Allelix's gnomAD cache covers exome sites with an rsID, so a missing value says nothing about rarity. Calls are also not assessed when the gnomAD database is skipped. Homozygous calls on X are not assessed because a male's single X reads as homozygous; heterozygous X calls are. A call the file itself declares as one copy (a one-letter array call such as 23andMe's male X calls, or a one-index VCF genotype) is shown as Hemizygous and assessed as one copy. Y and mitochondrial calls are not assessed. When records at one position that are read on their own disagree on ploidy (one copy in one record, two in another), each finding keeps its own record's genotype and zygosity, and the report counts them in a warning, `contradictory_calls` (ADR-0062). Consecutive single-base records of one REF naming different ALTs are read together instead ([docs/formats.md](https://github.com/allelix/allelix/blob/main/docs/formats.md#one-site-written-over-several-records)): when two or more passing calls include a haploid call, the site is withheld and counted as `split_site_calls`; a rejected sibling does not cancel a passing call. Confirm a flagged call with a clinical-grade test before relying on it.
|
|
238
238
|
|
|
239
239
|
When three or more variants on chromosomes 1 to 22 are called homozygous for an allele ClinVar classifies as Pathogenic or Likely pathogenic, and are rare in gnomAD or were looked up there and are absent, the report warns at the top. A call gnomAD was not asked about (gnomAD not installed, or a GRCh37 allele the identity table cannot translate) does not count. This is counted before any display filter, so `--min-magnitude` cannot hide it (ADR-0050).
|
|
240
240
|
|
|
@@ -72,15 +72,29 @@ def resolve_batch(
|
|
|
72
72
|
gnomad: GnomadAnnotator | None,
|
|
73
73
|
identity: RsidIdentityAnnotator | None = None,
|
|
74
74
|
resolved_coords: ResolvedCoords | None = None,
|
|
75
|
-
) ->
|
|
75
|
+
) -> int:
|
|
76
76
|
"""Populate ``ref`` and stamp ``rsid`` in place on one batch (see module docstring).
|
|
77
77
|
|
|
78
78
|
``variants`` must already carry their effective ``build``. Sources
|
|
79
79
|
that are None or not ready are skipped. Resolved coordinates are
|
|
80
80
|
added to ``resolved_coords`` when given.
|
|
81
|
+
|
|
82
|
+
A merged split pair's identity is decided per ALT (2.7.1, owner decision
|
|
83
|
+
D1 point 1): each record keeps the rsID it names, and a record naming
|
|
84
|
+
none has its ALT looked up alone. Two different rsIDs make it no pair:
|
|
85
|
+
it is replaced in ``variants`` by one half call per record, ``ALT/.``
|
|
86
|
+
under that ALT's rsID. Exactly one rsID names the full call. Returns how
|
|
87
|
+
many pairs were split, for the caller's split-site counts.
|
|
81
88
|
"""
|
|
82
89
|
if not variants:
|
|
83
|
-
return
|
|
90
|
+
return 0
|
|
91
|
+
split = _decide_pairs_per_allele(
|
|
92
|
+
variants,
|
|
93
|
+
clinvar=clinvar,
|
|
94
|
+
gnomad=gnomad,
|
|
95
|
+
identity=identity,
|
|
96
|
+
resolved_coords=resolved_coords,
|
|
97
|
+
)
|
|
84
98
|
_resolve_as_written(
|
|
85
99
|
variants,
|
|
86
100
|
clinvar=clinvar,
|
|
@@ -93,7 +107,7 @@ def resolve_batch(
|
|
|
93
107
|
# spelling and takes only the recovered rsID.
|
|
94
108
|
views = {i: view for i, v in enumerate(variants) if (view := _trimmed_view(v)) is not None}
|
|
95
109
|
if not views:
|
|
96
|
-
return
|
|
110
|
+
return split
|
|
97
111
|
_resolve_as_written(
|
|
98
112
|
list(views.values()),
|
|
99
113
|
clinvar=clinvar,
|
|
@@ -105,6 +119,75 @@ def resolve_batch(
|
|
|
105
119
|
if view.rsid != variants[i].rsid:
|
|
106
120
|
variants[i].original_rsid = variants[i].rsid
|
|
107
121
|
variants[i].rsid = view.rsid
|
|
122
|
+
return split
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _decide_pairs_per_allele(
|
|
126
|
+
variants: list[Variant],
|
|
127
|
+
*,
|
|
128
|
+
clinvar: ClinVarAnnotator | None,
|
|
129
|
+
gnomad: GnomadAnnotator | None,
|
|
130
|
+
identity: RsidIdentityAnnotator | None,
|
|
131
|
+
resolved_coords: ResolvedCoords | None,
|
|
132
|
+
) -> int:
|
|
133
|
+
"""Decide, in place, each merged split pair's identity from its ALTs one by one.
|
|
134
|
+
|
|
135
|
+
Each record's ALT is a half call under the rsID that record names; one
|
|
136
|
+
naming none is looked up alone, by the usual routes. Two different
|
|
137
|
+
rsIDs: the pair is replaced by those two half calls (each with its own
|
|
138
|
+
record). Exactly one: the full call takes it, as when a record names
|
|
139
|
+
it. None: the pair is left for the ordinary resolution, unchanged.
|
|
140
|
+
Only accepted exact pairs (``allele_records``) are decided; a site whose
|
|
141
|
+
records only agree or contradict is never a pair. Returns the number of
|
|
142
|
+
pairs split.
|
|
143
|
+
"""
|
|
144
|
+
pairs = [
|
|
145
|
+
i
|
|
146
|
+
for i, v in enumerate(variants)
|
|
147
|
+
if v.allele_records is not None and len(v.allele_records) == 2 and v.allele_ids is not None
|
|
148
|
+
]
|
|
149
|
+
if not pairs:
|
|
150
|
+
return 0
|
|
151
|
+
halves = {
|
|
152
|
+
i: [
|
|
153
|
+
replace(
|
|
154
|
+
variants[i],
|
|
155
|
+
rsid=written,
|
|
156
|
+
allele1=allele,
|
|
157
|
+
allele2=NO_CALL_MARKER,
|
|
158
|
+
input_alt=allele,
|
|
159
|
+
record_index=record,
|
|
160
|
+
allele_records=None,
|
|
161
|
+
allele_ids=None,
|
|
162
|
+
)
|
|
163
|
+
for (allele, record), written in zip(
|
|
164
|
+
variants[i].allele_records or (), variants[i].allele_ids or (), strict=True
|
|
165
|
+
)
|
|
166
|
+
]
|
|
167
|
+
for i in pairs
|
|
168
|
+
}
|
|
169
|
+
unnamed = [h for pair in halves.values() for h in pair if not h.rsid.startswith("rs")]
|
|
170
|
+
if unnamed:
|
|
171
|
+
_resolve_as_written(
|
|
172
|
+
unnamed,
|
|
173
|
+
clinvar=clinvar,
|
|
174
|
+
gnomad=gnomad,
|
|
175
|
+
identity=identity,
|
|
176
|
+
resolved_coords=resolved_coords,
|
|
177
|
+
)
|
|
178
|
+
split = 0
|
|
179
|
+
for i in sorted(halves, reverse=True):
|
|
180
|
+
names = {h.rsid for h in halves[i] if h.rsid.startswith("rs")}
|
|
181
|
+
if len(names) == 2:
|
|
182
|
+
variants[i : i + 1] = halves[i]
|
|
183
|
+
split += 1
|
|
184
|
+
elif len(names) == 1:
|
|
185
|
+
pair = variants[i]
|
|
186
|
+
(name,) = names
|
|
187
|
+
if pair.rsid != name:
|
|
188
|
+
pair.original_rsid = pair.rsid
|
|
189
|
+
pair.rsid = name
|
|
190
|
+
return split
|
|
108
191
|
|
|
109
192
|
|
|
110
193
|
def _resolve_as_written(
|
|
@@ -61,7 +61,7 @@ from allelix.utils.allele import (
|
|
|
61
61
|
from allelix.utils.build_detect import BUILD_GRCH37, BUILD_GRCH38
|
|
62
62
|
|
|
63
63
|
if TYPE_CHECKING:
|
|
64
|
-
from collections.abc import Callable, Iterable, Iterator
|
|
64
|
+
from collections.abc import Callable, Iterable, Iterator, Sequence
|
|
65
65
|
|
|
66
66
|
from allelix.models import Variant
|
|
67
67
|
|
|
@@ -1386,6 +1386,46 @@ class ClinVarAnnotator(Annotator):
|
|
|
1386
1386
|
out.setdefault(rsid, gene or "")
|
|
1387
1387
|
return out
|
|
1388
1388
|
|
|
1389
|
+
def plp_at_sites(
|
|
1390
|
+
self, sites: Sequence[tuple[str, int, str, frozenset[str]]], build: str
|
|
1391
|
+
) -> list[tuple[str, str] | None]:
|
|
1392
|
+
"""ClinVar's rsID and gene of an aggregate-P/LP row for each site's carried ALT.
|
|
1393
|
+
|
|
1394
|
+
``sites`` are (chromosome, position, REF, ALTs the person's records
|
|
1395
|
+
carry) on ``build``; the answer is aligned with them, one entry per
|
|
1396
|
+
site, so two sites at one position never share evidence. Only a row
|
|
1397
|
+
of the site's REF and one of its ALTs counts: a P/LP row for an ALT
|
|
1398
|
+
the records do not carry does not. None where there is no such row.
|
|
1399
|
+
Read only (2.7.1, a contradicting split site).
|
|
1400
|
+
"""
|
|
1401
|
+
conn = self._connection(build) if sites else None
|
|
1402
|
+
if conn is None:
|
|
1403
|
+
return [None for _ in sites]
|
|
1404
|
+
rows_at: dict[tuple[str, int], list[tuple]] = {}
|
|
1405
|
+
out: list[tuple[str, str] | None] = []
|
|
1406
|
+
for chrom, pos, ref, alts in sites:
|
|
1407
|
+
rows = rows_at.get((chrom, pos))
|
|
1408
|
+
if rows is None:
|
|
1409
|
+
rows = rows_at[(chrom, pos)] = conn.execute(
|
|
1410
|
+
"SELECT rsid, ref, alt, aggregate, gene FROM clinvar_variants "
|
|
1411
|
+
"WHERE chromosome = ? AND position = ? ORDER BY id",
|
|
1412
|
+
(chrom, pos),
|
|
1413
|
+
).fetchall()
|
|
1414
|
+
carried = {a.upper() for a in alts}
|
|
1415
|
+
out.append(
|
|
1416
|
+
next(
|
|
1417
|
+
(
|
|
1418
|
+
(rsid or "", gene or "")
|
|
1419
|
+
for rsid, row_ref, row_alt, aggregate, gene in rows
|
|
1420
|
+
if (row_ref or "").upper() == ref.upper()
|
|
1421
|
+
and (row_alt or "").upper() in carried
|
|
1422
|
+
and is_pathogenic_aggregate(aggregate or "")
|
|
1423
|
+
),
|
|
1424
|
+
None,
|
|
1425
|
+
)
|
|
1426
|
+
)
|
|
1427
|
+
return out
|
|
1428
|
+
|
|
1389
1429
|
def _name_probe_di_calls(self, conn: sqlite3.Connection, variants: list[Variant]) -> None:
|
|
1390
1430
|
"""Name a D/I call that ClinVar cannot place by rsID, by position.
|
|
1391
1431
|
|
|
@@ -58,7 +58,7 @@ from allelix.reports.clinvar_text import (
|
|
|
58
58
|
scored_down_line,
|
|
59
59
|
scored_down_variant_text,
|
|
60
60
|
)
|
|
61
|
-
from allelix.reports.diff import compute_diff, load_previous_report
|
|
61
|
+
from allelix.reports.diff import baseline_build_differs, compute_diff, load_previous_report
|
|
62
62
|
from allelix.reports.high_value import (
|
|
63
63
|
DI_CALLS_NOT_CHECKED,
|
|
64
64
|
UNCHECKED_DI_CALL,
|
|
@@ -1086,6 +1086,14 @@ def _run_analysis_command(
|
|
|
1086
1086
|
f"--vcf-out refuses to overwrite an existing file or link: {vcf_out}. "
|
|
1087
1087
|
"Move or delete it, or choose a different path."
|
|
1088
1088
|
)
|
|
1089
|
+
# The annotated VCF is committed with a hard link: a file system
|
|
1090
|
+
# without them is refused now, not after the whole run (2.7.1).
|
|
1091
|
+
from allelix.reports import check_hard_links
|
|
1092
|
+
|
|
1093
|
+
try:
|
|
1094
|
+
check_hard_links(vcf_out)
|
|
1095
|
+
except OSError as exc:
|
|
1096
|
+
raise click.ClickException(str(exc)) from exc
|
|
1089
1097
|
|
|
1090
1098
|
resolved = resolve_data_dir(data_dir)
|
|
1091
1099
|
from allelix.config import load_config
|
|
@@ -1357,13 +1365,24 @@ def _run_analysis_command(
|
|
|
1357
1365
|
for a in result.filter(min_magnitude=0.0, category=category, genes=genes, rsids=rsids)
|
|
1358
1366
|
if id(a) not in displayed
|
|
1359
1367
|
]
|
|
1368
|
+
# A baseline from the other build has other positions for the same
|
|
1369
|
+
# variants: pair without the site, and say so once (2.7.1).
|
|
1370
|
+
other_build = baseline_build_differs(prev, result.build)
|
|
1360
1371
|
diff_result = compute_diff(
|
|
1361
1372
|
filtered_for_diff,
|
|
1362
1373
|
prev["annotations"],
|
|
1363
1374
|
prev.get("generated_at", ""),
|
|
1364
1375
|
unfiltered=filtered_for_diff + undisplayed,
|
|
1365
1376
|
below_floor={id(a) for a in undisplayed if id(a) not in above_floor},
|
|
1377
|
+
ignore_sites=other_build is not None,
|
|
1366
1378
|
)
|
|
1379
|
+
if other_build is not None:
|
|
1380
|
+
console.print(
|
|
1381
|
+
f"[bold yellow]Note:[/bold yellow] the --diff baseline is on {other_build} and "
|
|
1382
|
+
f"this run is on {result.build}; the builds differ, so findings with an rsID "
|
|
1383
|
+
"are compared by variant and allele, not by position (a finding known only by "
|
|
1384
|
+
"its position can still show as removed and new)."
|
|
1385
|
+
)
|
|
1367
1386
|
previous_input = (prev.get("input") or {}).get("file")
|
|
1368
1387
|
if previous_input and previous_input != file_path.name:
|
|
1369
1388
|
console.print(
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
|
+
from contextvars import ContextVar
|
|
8
9
|
from dataclasses import replace
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
from typing import TYPE_CHECKING, Any
|
|
@@ -23,7 +24,7 @@ from allelix.cli._options import (
|
|
|
23
24
|
_SAMPLE_OPT,
|
|
24
25
|
)
|
|
25
26
|
from allelix.databases import resolve_data_dir
|
|
26
|
-
from allelix.models import NO_CALL_MARKER
|
|
27
|
+
from allelix.models import NO_CALL_MARKER, Variant
|
|
27
28
|
from allelix.parsers._helpers import normalize_chromosome, summary_chromosome
|
|
28
29
|
from allelix.reports._pipeline import BuildDiagnostics, UnusableInputError
|
|
29
30
|
from allelix.reports.build_text import short_source
|
|
@@ -40,8 +41,8 @@ if TYPE_CHECKING:
|
|
|
40
41
|
from collections.abc import Callable, Iterator
|
|
41
42
|
|
|
42
43
|
from allelix.exporters.plink import RecordKey
|
|
43
|
-
from allelix.models import Variant
|
|
44
44
|
from allelix.parsers.base import GenotypeParser
|
|
45
|
+
from allelix.parsers.vcf import SplitSiteWithheld
|
|
45
46
|
from allelix.utils.build_detect import BuildDecision
|
|
46
47
|
|
|
47
48
|
|
|
@@ -200,16 +201,34 @@ def extract(
|
|
|
200
201
|
raise click.ClickException("--snps cannot be empty.")
|
|
201
202
|
|
|
202
203
|
build_override = _helpers._normalize_cli_build(build)
|
|
204
|
+
# Why a requested rsID's call is a no-call where the reason is not in the
|
|
205
|
+
# table (2.7.1: a split site whose records contradict each other).
|
|
206
|
+
notes: dict[str, set[tuple[str, int]]] = {}
|
|
207
|
+
token = _EXTRACT_NOTES.set(notes)
|
|
203
208
|
try:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
try:
|
|
210
|
+
found = _try_tabix_extract(file_path, wanted, sample, data_dir, build_override)
|
|
211
|
+
except BuildDecisionError as exc:
|
|
212
|
+
raise click.ClickException(str(exc)) from exc
|
|
213
|
+
if found is None:
|
|
214
|
+
# Sequential fallback — works for any parser.
|
|
215
|
+
found = _sequential_extract(parser, file_path, wanted, data_dir, build_override)
|
|
216
|
+
_maybe_print_vcf_index_hint(file_path)
|
|
217
|
+
finally:
|
|
218
|
+
_EXTRACT_NOTES.reset(token)
|
|
211
219
|
|
|
212
220
|
_render_extract_table(file_path, wanted, found)
|
|
221
|
+
# Only for the call shown: a full no-call at the withheld site itself,
|
|
222
|
+
# never another position's call of the same rsID, nor a call with a known
|
|
223
|
+
# allele (a half call) that another group at the same locus left.
|
|
224
|
+
for rsid in sorted(notes):
|
|
225
|
+
chosen = found.get(rsid)
|
|
226
|
+
if (
|
|
227
|
+
chosen is not None
|
|
228
|
+
and not _known_allele(chosen)
|
|
229
|
+
and (normalize_chromosome(chosen.chromosome), chosen.position) in notes[rsid]
|
|
230
|
+
):
|
|
231
|
+
console.print(f"{literal(rsid)}: {literal(WITHHELD_SPLIT_SITE_NOTE)}")
|
|
213
232
|
|
|
214
233
|
|
|
215
234
|
def _sequential_extract(
|
|
@@ -248,6 +267,9 @@ def _sequential_extract(
|
|
|
248
267
|
counter, stderr_handler, snapshot = _helpers._wire_parser_logging()
|
|
249
268
|
streamed: dict[str, list[Variant]] = {}
|
|
250
269
|
sequence = 0
|
|
270
|
+
if isinstance(parser, VcfParser):
|
|
271
|
+
# A split site is read as the analysis reads it (ADR-0062, 2.7.1).
|
|
272
|
+
parser.combine_split_sites = True
|
|
251
273
|
try:
|
|
252
274
|
with _helpers._resolved_variants(
|
|
253
275
|
parser, file_path, data_dir=data_dir, build_override=build_override
|
|
@@ -298,7 +320,16 @@ def _sequential_extract(
|
|
|
298
320
|
_helpers._unwire_parser_logging(counter, stderr_handler, snapshot)
|
|
299
321
|
if isinstance(parser, VcfParser):
|
|
300
322
|
parser.watch_extract(frozenset())
|
|
323
|
+
parser.combine_split_sites = False
|
|
301
324
|
rank = _contig_rank(getattr(parser, "contig_order", []))
|
|
325
|
+
# A split site withheld because its records contradict each other is in
|
|
326
|
+
# the file: it is a no-call for the rsIDs its records name or that are
|
|
327
|
+
# placed there, never absent and never a genotype (2.7.1).
|
|
328
|
+
for site in getattr(parser, "split_site_withheld", []):
|
|
329
|
+
for rsid in wanted:
|
|
330
|
+
if rsid in site.rsids or (site.chromosome, site.position) in placements.get(rsid, {}):
|
|
331
|
+
streamed.setdefault(rsid, []).append(_withheld_no_call(rsid, site))
|
|
332
|
+
_note_withheld(rsid, site)
|
|
302
333
|
found: dict[str, Variant] = {}
|
|
303
334
|
for rsid in wanted:
|
|
304
335
|
candidates = _candidates(rsid, streamed, parser, placements)
|
|
@@ -414,6 +445,15 @@ def _contig_rank(contig_order: list[str]) -> dict[str, int]:
|
|
|
414
445
|
return rank
|
|
415
446
|
|
|
416
447
|
|
|
448
|
+
def _known_allele(v: Variant) -> bool:
|
|
449
|
+
"""Whether a call names at least one allele: a full call or a half call (C/-).
|
|
450
|
+
|
|
451
|
+
``is_no_call`` is true for a half call too; only a call missing both
|
|
452
|
+
alleles (a full no-call or a rejected record) has none.
|
|
453
|
+
"""
|
|
454
|
+
return any(a and a != NO_CALL_MARKER for a in (v.allele1, v.allele2))
|
|
455
|
+
|
|
456
|
+
|
|
417
457
|
def _extract_choice(
|
|
418
458
|
candidates: list[Variant], places: dict[tuple[str, int], str], rank: dict[str, int]
|
|
419
459
|
) -> Variant:
|
|
@@ -422,8 +462,9 @@ def _extract_choice(
|
|
|
422
462
|
1. A call at one of its placements beats one elsewhere; a no-call at a
|
|
423
463
|
placement still beats a usable call elsewhere. A padded record is at
|
|
424
464
|
a placement when it trims to it (ADR-0061).
|
|
425
|
-
2. Among calls at a placement, a
|
|
426
|
-
rejected record
|
|
465
|
+
2. Among calls at a placement, a call with a known allele (a full call
|
|
466
|
+
or a half call) beats a full no-call or a rejected record, so a
|
|
467
|
+
rejected sibling never hides a split site's passing half call.
|
|
427
468
|
3. Then file order: the header's contig order, then POS, then line.
|
|
428
469
|
A call at a placement takes that placement's position, so a padded
|
|
429
470
|
call ties with the same call written trimmed (ADR-0061).
|
|
@@ -444,9 +485,10 @@ def _extract_choice(
|
|
|
444
485
|
else (name, v.position)
|
|
445
486
|
)
|
|
446
487
|
line = v.record_index if v.record_index is not None else 0
|
|
488
|
+
no_allele = mapped and not _known_allele(v)
|
|
447
489
|
if not rank:
|
|
448
|
-
return (not mapped,
|
|
449
|
-
return (not mapped,
|
|
490
|
+
return (not mapped, no_allele, 0, 0, line)
|
|
491
|
+
return (not mapped, no_allele, rank.get(chrom, len(rank)), pos, line)
|
|
450
492
|
|
|
451
493
|
return min(candidates, key=key)
|
|
452
494
|
|
|
@@ -650,7 +692,11 @@ def _execute_tabix_extract(
|
|
|
650
692
|
# The pending set excludes indexed no-calls and all other accepted hits.
|
|
651
693
|
found.update(
|
|
652
694
|
_sequential_extract(
|
|
653
|
-
VcfParser(sample=sample),
|
|
695
|
+
VcfParser(sample=sample),
|
|
696
|
+
file_path,
|
|
697
|
+
pending,
|
|
698
|
+
resolved_data_dir,
|
|
699
|
+
build_override,
|
|
654
700
|
)
|
|
655
701
|
)
|
|
656
702
|
else:
|
|
@@ -699,7 +745,7 @@ def _indexed_candidates(
|
|
|
699
745
|
pos: int,
|
|
700
746
|
ref: str,
|
|
701
747
|
sample_idx: int,
|
|
702
|
-
resolve: Callable[[list[Variant]],
|
|
748
|
+
resolve: Callable[[list[Variant]], object],
|
|
703
749
|
contig_aliases: dict[str, tuple[str, ...]],
|
|
704
750
|
raw_cache: dict[tuple[str, int], list[str]] | None = None,
|
|
705
751
|
) -> list[Variant]:
|
|
@@ -713,7 +759,13 @@ def _indexed_candidates(
|
|
|
713
759
|
among the fetched records as ``record_index``. ``raw_cache`` keeps each
|
|
714
760
|
interval's rows for the extraction, so an interval is fetched once.
|
|
715
761
|
"""
|
|
716
|
-
from allelix.parsers.vcf import
|
|
762
|
+
from allelix.parsers.vcf import (
|
|
763
|
+
VcfQualityStats,
|
|
764
|
+
_parse_record,
|
|
765
|
+
extract_reference_candidates,
|
|
766
|
+
split_site_calls,
|
|
767
|
+
split_site_component,
|
|
768
|
+
)
|
|
717
769
|
|
|
718
770
|
stats = VcfQualityStats()
|
|
719
771
|
streamed: list[Variant] = []
|
|
@@ -730,20 +782,46 @@ def _indexed_candidates(
|
|
|
730
782
|
lines.extend(_read_index_rows(rows))
|
|
731
783
|
if raw_cache is not None:
|
|
732
784
|
raw_cache[(chrom, pos)] = lines
|
|
785
|
+
|
|
786
|
+
def take(variant: Variant, order: int) -> None:
|
|
787
|
+
if pos in _stands_at(variant):
|
|
788
|
+
variant = replace(variant, build=BUILD_GRCH38)
|
|
789
|
+
variant.record_index = order
|
|
790
|
+
streamed.append(variant)
|
|
791
|
+
|
|
792
|
+
# One site's single-base records are read together, as the analysis
|
|
793
|
+
# reads them (ADR-0062, 2.7.1): consecutive records at one CHROM and POS.
|
|
794
|
+
site: list[tuple[Variant | None, int, list[str]]] = []
|
|
795
|
+
|
|
796
|
+
def end_site() -> None:
|
|
797
|
+
withheld: list[SplitSiteWithheld] = []
|
|
798
|
+
for call in split_site_calls(site, sample_idx, stats, withheld):
|
|
799
|
+
take(call, call.record_index if call.record_index is not None else 0)
|
|
800
|
+
for held in withheld:
|
|
801
|
+
if rsid in held.rsids or (held.chromosome, held.position) == (chrom, pos):
|
|
802
|
+
out.append(_withheld_no_call(rsid, held))
|
|
803
|
+
_note_withheld(rsid, held)
|
|
804
|
+
site.clear()
|
|
805
|
+
|
|
733
806
|
for order, line in enumerate(lines, start=1):
|
|
734
807
|
cols = line.split("\t")
|
|
808
|
+
if site and (len(cols) < 8 or (site[0][2][0], site[0][2][1]) != (cols[0], cols[1])):
|
|
809
|
+
end_site()
|
|
735
810
|
variant, state = _parse_record(cols, line, sample_idx, stats, want_state=True)
|
|
736
|
-
if variant is not None:
|
|
737
|
-
if pos in _stands_at(variant):
|
|
738
|
-
variant = replace(variant, build=BUILD_GRCH38)
|
|
739
|
-
variant.record_index = order
|
|
740
|
-
streamed.append(variant)
|
|
741
|
-
elif state is not None:
|
|
811
|
+
if variant is None and state is not None:
|
|
742
812
|
for named, locus, call in extract_reference_candidates(
|
|
743
813
|
cols, state, order, rsids=frozenset({rsid}), loci=loci
|
|
744
814
|
):
|
|
745
815
|
if named == rsid or locus == (chrom, pos):
|
|
746
816
|
out.append(call if call.rsid == rsid else replace(call, rsid=rsid))
|
|
817
|
+
if split_site_component(cols, sample_idx):
|
|
818
|
+
if variant is not None:
|
|
819
|
+
variant.record_index = order
|
|
820
|
+
site.append((variant, order, cols))
|
|
821
|
+
elif variant is not None:
|
|
822
|
+
take(variant, order)
|
|
823
|
+
if site:
|
|
824
|
+
end_site()
|
|
747
825
|
resolve(streamed)
|
|
748
826
|
out.extend(v for v in streamed if v.rsid == rsid)
|
|
749
827
|
# A call recovery could not name is the call at this placement too.
|
|
@@ -751,6 +829,41 @@ def _indexed_candidates(
|
|
|
751
829
|
return out
|
|
752
830
|
|
|
753
831
|
|
|
832
|
+
# Why a requested rsID's call is a no-call where the table does not say
|
|
833
|
+
# (2.7.1: a split site whose records contradict each other). Set by
|
|
834
|
+
# ``extract`` for its run, so no reader's signature carries it.
|
|
835
|
+
# Keyed by rsID, then by the withheld site's locus, so the note is printed
|
|
836
|
+
# only when the call shown is the no-call at that site.
|
|
837
|
+
_EXTRACT_NOTES: ContextVar[dict[str, set[tuple[str, int]]] | None] = ContextVar(
|
|
838
|
+
"_EXTRACT_NOTES", default=None
|
|
839
|
+
)
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
def _note_withheld(rsid: str, site: SplitSiteWithheld) -> None:
|
|
843
|
+
notes = _EXTRACT_NOTES.get()
|
|
844
|
+
if notes is not None:
|
|
845
|
+
notes.setdefault(rsid, set()).add((normalize_chromosome(site.chromosome), site.position))
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
WITHHELD_SPLIT_SITE_NOTE = (
|
|
849
|
+
"its records at this position contradict each other, so no genotype is given "
|
|
850
|
+
"there (analyze withholds the site too)."
|
|
851
|
+
)
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
def _withheld_no_call(rsid: str, site: SplitSiteWithheld) -> Variant:
|
|
855
|
+
"""A no-call for ``rsid`` at a split site withheld because its records contradict."""
|
|
856
|
+
return Variant(
|
|
857
|
+
rsid=rsid,
|
|
858
|
+
chromosome=site.chromosome,
|
|
859
|
+
position=site.position,
|
|
860
|
+
allele1=NO_CALL_MARKER,
|
|
861
|
+
allele2=NO_CALL_MARKER,
|
|
862
|
+
ref=site.ref or None,
|
|
863
|
+
ref_from_input=True,
|
|
864
|
+
)
|
|
865
|
+
|
|
866
|
+
|
|
754
867
|
def _stands_at(variant: Variant) -> set[int]:
|
|
755
868
|
"""The positions a VCF call's record stands at (``record_positions``, ADR-0061)."""
|
|
756
869
|
from allelix.parsers.vcf import record_positions
|
|
@@ -779,7 +892,7 @@ def _fetch_resolved(
|
|
|
779
892
|
pos: int,
|
|
780
893
|
rsid: str,
|
|
781
894
|
sample_idx: int,
|
|
782
|
-
resolve: Callable[[list[Variant]],
|
|
895
|
+
resolve: Callable[[list[Variant]], object],
|
|
783
896
|
*,
|
|
784
897
|
parse_row: Callable[[str, int], Variant | None],
|
|
785
898
|
build: str,
|
|
@@ -121,6 +121,11 @@ class Variant:
|
|
|
121
121
|
allele_records: tuple[tuple[str, int], ...] | None = field(
|
|
122
122
|
default=None, compare=False, repr=False
|
|
123
123
|
)
|
|
124
|
+
# The canonical rsID each of those records names, in the same order, or
|
|
125
|
+
# "" for a record naming none (a missing, positional or other ID). The
|
|
126
|
+
# pair's identity is decided per ALT from these, never from the merged
|
|
127
|
+
# call's one rsID (2.7.1). None with ``allele_records``.
|
|
128
|
+
allele_ids: tuple[str, ...] | None = field(default=None, compare=False, repr=False)
|
|
124
129
|
# A chip call's own rsID's single-base alleles at its build and locus, as
|
|
125
130
|
# the resolution step learns them while filling REF: the identity table's
|
|
126
131
|
# SNV rows and gnomAD's rows of that rsID there. ClinVar adds
|
|
@@ -552,6 +552,36 @@ def _open_genotype_text(file_path: Path, errors: str = "strict") -> TextIO:
|
|
|
552
552
|
return open(file_path, encoding="utf-8-sig", errors=errors)
|
|
553
553
|
|
|
554
554
|
|
|
555
|
+
# The largest position a cache can hold: SQLite's INTEGER is a signed 64-bit
|
|
556
|
+
# integer. A position below 1 names no base (2.7.1, the owner's int64 limit).
|
|
557
|
+
MAX_POSITION = 2**63 - 1
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
def parse_position(text: str) -> int:
|
|
561
|
+
"""An explicit position, 1 to ``MAX_POSITION``; ValueError for anything else.
|
|
562
|
+
|
|
563
|
+
A readers' row with such a position is malformed and skipped, as a
|
|
564
|
+
position that is not a number is.
|
|
565
|
+
"""
|
|
566
|
+
position = int(text)
|
|
567
|
+
if not 1 <= position <= MAX_POSITION:
|
|
568
|
+
raise ValueError(f"position {text!r} is outside 1 to {MAX_POSITION}")
|
|
569
|
+
return position
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
def parse_array_position(text: str) -> int:
|
|
573
|
+
"""An array row's position: ``parse_position``, or 0 for an unplaced call.
|
|
574
|
+
|
|
575
|
+
Arrays write 0 for an rsID they did not place (PLINK's and GenomeStudio's
|
|
576
|
+
code). Such a row is read as 2.7.0 read it, an rsID call with no locus:
|
|
577
|
+
sources that match by rsID see it, and nothing looks it up by position.
|
|
578
|
+
A VCF POS stays 1 or more (``parse_position``).
|
|
579
|
+
"""
|
|
580
|
+
if int(text) == 0: # "0", "00", " 0": every spelling 2.7.0's int() read as 0
|
|
581
|
+
return 0
|
|
582
|
+
return parse_position(text)
|
|
583
|
+
|
|
584
|
+
|
|
555
585
|
def first_nonblank_line(fh: TextIO, limit: int) -> str:
|
|
556
586
|
"""The first line of ``fh`` with any non-whitespace in it, or "" (within ``limit`` lines)."""
|
|
557
587
|
for _ in range(limit):
|
|
@@ -35,6 +35,7 @@ from allelix.parsers._helpers import (
|
|
|
35
35
|
first_nonblank_line,
|
|
36
36
|
no_call_allele,
|
|
37
37
|
open_genotype_text,
|
|
38
|
+
parse_array_position,
|
|
38
39
|
)
|
|
39
40
|
from allelix.parsers.base import GenotypeMetadata, GenotypeParser, read_header_build
|
|
40
41
|
|
|
@@ -106,7 +107,7 @@ class AncestryDNAParser(GenotypeParser):
|
|
|
106
107
|
|
|
107
108
|
rsid, chrom_raw, pos_str, allele1, allele2 = parts
|
|
108
109
|
try:
|
|
109
|
-
position =
|
|
110
|
+
position = parse_array_position(pos_str)
|
|
110
111
|
except ValueError:
|
|
111
112
|
logger.warning("Line %d: invalid position %r — skipping", lineno, pos_str)
|
|
112
113
|
continue
|