ensembl.vep.corpus.golden package#
Golden corpora and pinned annotation terms.
Submodules#
ensembl.vep.corpus.golden.base module#
The golden corpus model.
- class ensembl.vep.corpus.golden.base.GoldenCorpus(*, spec, corpus, expected_terms, resource_context=None)[source]#
Bases:
CorpusPair a corpus with pinned expected consequence terms.
- Variables:
spec (CorpusSpec) – Specification identifying the golden dataset.
corpus (Corpus) – Loaded or generated corpus whose overlaps the terms describe.
expected_terms (GoldenTerms) – Pinned consequences for the wrapped corpus.
resource_context (AbstractContextManager[object] | None) – Context retaining packaged files for the lifetime of the corpus.
- property description: str#
Return a short golden-corpus description.
- expected_terms: GoldenTerms#
- property named_overlaps: tuple[tuple[str, TranscriptVariationAllele], ...]#
Return the wrapped overlaps.
- property named_variants: tuple[tuple[str, VariationAllele], ...]#
Return the wrapped variants.
- resource_context: AbstractContextManager[object] | None#
- property spec: CorpusSpec#
Return the golden corpus specification.
- property transcripts: tuple[Transcript, ...]#
Return the wrapped transcripts.
ensembl.vep.corpus.golden.resolve module#
Resolve a loaded golden corpus or explicitly generate its fallback.
- ensembl.vep.corpus.golden.resolve.load_golden_corpus(specification, *, directory=None, fallback=None, allow_generate=False)[source]#
Load pinned corpus files and terms, or explicitly generate a missing fallback.
Existing but malformed data always raises. Generation is limited to absent data so a corrupt golden reference cannot silently validate against newly generated expectations.
- Parameters:
specification (
CorpusSpec) – Identity of the requested golden dataset.directory (
Path|None, default:None) – Explicit bundle directory, orNonefor packaged data.fallback (
CorpusSpec|None, default:None) – Corpus to annotate when missing data may be generated.allow_generate (
bool, default:False) – Whether an absent dataset may usefallback.
- Returns:
Loaded or generated corpus with pinned expected terms.
- Return type:
- Raises:
FileNotFoundError – If required corpus or term files are absent without an allowed fallback.
TypeError – If the dataset parameter has an invalid type.
ValueError – If loaded terms identify a different corpus specification.
ensembl.vep.corpus.golden.terms module#
Frozen expected terms emitted for a corpus and pinned to a file.
Conformance proves every annotator agrees with consequence.linear. It cannot catch all of them
agreeing on the same wrong answer; a golden file can. It freezes the terms one annotator produced
for one corpus, together with the corpus spec and the catalogue that produced them, so a later run
is checked against a fixed expectation rather than only against itself.
Named golden on purpose: in this repository “oracle” already means the external Perl
VariationEffect.pm, whose whole value is that it is not us. This is the opposite thing.
A mismatch is reported three distinct ways, because each calls for a different response. The catalogue changed under the file – regenerate it, deliberately. The file was recorded for another corpus – it is the wrong file. Or the terms moved with neither changed – a regression.
- ensembl.vep.corpus.golden.terms.FORMAT_VERSION = 1#
Bumped whenever the file layout changes, so an old file is rejected rather than misread.
- class ensembl.vep.corpus.golden.terms.GoldenReport(*, catalogue_changed=False, spec_changed=False, annotator_changed=False, missing=(), unexpected=(), mismatches=())[source]#
Bases:
objectHow recorded terms differ from golden ones.
- Variables:
catalogue_changed (bool) – The catalogue is not the one the golden file was recorded against.
spec_changed (bool) – The corpus is not the one the golden file was recorded over.
annotator_changed (bool) – A different annotator produced the recording. Informational – checking another strategy against one annotator’s golden file is a legitimate use.
missing (tuple[str, ...]) – Keys the golden file has and the recording does not.
unexpected (tuple[str, ...]) – Keys the recording has and the golden file does not.
mismatches (tuple[tuple[str, tuple[str, ...], tuple[str, ...]], ...]) – Key, golden terms, recorded terms, for every overlap whose terms moved.
- annotator_changed: bool#
- catalogue_changed: bool#
- classmethod compare(golden, recorded)[source]#
Compare a recording against golden terms.
- Return type:
- lines(limit=20)[source]#
Return the report as readable lines, the reason first, then at most
limitexamples.- Return type:
list[str]
- mismatches: tuple[tuple[str, tuple[str, ...], tuple[str, ...]], ...]#
- missing: tuple[str, ...]#
- property ok: bool#
Whether the recording matches, against the same catalogue and corpus.
- spec_changed: bool#
- unexpected: tuple[str, ...]#
- class ensembl.vep.corpus.golden.terms.GoldenTerms(*, spec, annotator, catalogue, terms=dict())[source]#
Bases:
objectThe terms one annotator emitted for every overlap of one corpus.
- Variables:
spec (CorpusSpec) – The corpus the terms were recorded over.
annotator (str) – The annotator that emitted them.
catalogue (str) – Digest of the catalogue they were emitted against.
terms (dict[str, tuple[str, ...]]) –
feature::name-> the emitted terms, in order.
- annotator: str#
- catalogue: str#
- classmethod from_json(text)[source]#
Read terms back from file text.
- Raises:
ValueError – If the file was written in a different format version.
- Return type:
- spec: CorpusSpec#
- terms: dict[str, tuple[str, ...]]#
- ensembl.vep.corpus.golden.terms.overlap_key(name, overlap)[source]#
Return the key an overlap is filed under: its feature, then its variant’s name.
A name identifies the variant, not the overlap – one variant pairs with every feature in its flank window – so the feature has to be part of the key.
- Return type:
str
- ensembl.vep.corpus.golden.terms.record_golden(corpus, annotator, annotator_name)[source]#
Annotate every overlap of a corpus and freeze the terms.
- Parameters:
corpus (
Corpus) – The corpus to record over.annotator (
Annotator[OverlapConsequence]) – The annotator whose terms are frozen.annotator_name (
str) – Its registry name, recorded in the file.
- Returns:
The frozen terms.
- Return type:
- Raises:
ValueError – If two overlaps would be filed under the same key.