ensembl.vep.output.parser package#

Readers of already-annotated output.

Submodules#

ensembl.vep.output.parser.base module#

The reader contract.

class ensembl.vep.output.parser.base.OutputParser[source]#

Bases: ABC

Parser for annotated files containing variation consequences.

A reader needs no transcript or sequence source: the consequences are seeded straight onto each allele, leaving the feature overlaps empty, and everything a summary reads still answers.

abstractmethod parse(path)[source]#

Yield one variation per record, with its alleles’ consequences attached.

Return type:

Iterator[Variation]

ensembl.vep.output.parser.json module#

JSON output. A declared seam; the writer it mirrors does not exist yet.

class ensembl.vep.output.parser.json.JSONOutputParser[source]#

Bases: OutputParser

Parser for VEP JSON output.

parse(path)[source]#

Not implemented yet.

Raises:

NotImplementedError – Always; the JSON format has no reader yet.

Return type:

Iterator[Variation]

ensembl.vep.output.parser.tab module#

Tab-delimited output. A declared seam; the writer it mirrors does not exist yet.

class ensembl.vep.output.parser.tab.TabOutputParser[source]#

Bases: OutputParser

Parser for VEP tab-delimited output.

parse(path)[source]#

Not implemented yet.

Raises:

NotImplementedError – Always; the tab format has no reader yet.

Return type:

Iterator[Variation]

ensembl.vep.output.parser.vcf module#

Annotated VCF consequence parsing.

VEP writes them as CSQ and SnpEff as ANN: one INFO field whose layout the header’s Description declares, one entry per (allele, feature) separated by commas, fields by pipes, several terms by &. Both are read the same way; only the field names differ.

Two mechanics that must stay right, both confirmed on this codebase:

  • seed_attrs takes the public name and prepends the underscore itself: seed_attrs(overlap_consequences=...), never _overlap_consequences.

  • transcript_variation_alleles carries on_setattr=invalidates("_overlap_consequences"), so assigning it after seeding silently wipes the seed. This reader never assigns it, which is also why it needs no --gff/--fasta: the terms live on the allele, and Variation.most_severe_consequence and .class_so_term answer with zero transcripts.

ensembl.vep.output.parser.vcf.ANNOTATION_FIELDS = {'ANN': ('Allele', 'Annotation'), 'CSQ': ('Allele', 'Consequence')}#

INFO key -> the names of its allele and consequence fields, as each tool spells them.

ensembl.vep.output.parser.vcf.UNKNOWN_RANK = 999#

Rank given to a term the catalogue does not model. Rank 1 is the most severe and the model’s default is 0, so an unranked term must sit below every real one rather than above.

class ensembl.vep.output.parser.vcf.VCFOutputParser(*, ruleset=build_fact_ruleset())[source]#

Bases: OutputParser

Parser for annotated VCF files.

Variables:

ruleset (FactRuleSet) – Where a known term’s rank, accession and impact come from. A term the catalogue does not model is kept, with UNKNOWN_RANK.

parse(path)[source]#

Yield one variation per record.

Parameters:

path (str | Path) – The annotated VCF.

Yields:

Variation – Each record, its alleles seeded with the terms the file assigned them.

ruleset: FactRuleSet#
ensembl.vep.output.parser.vcf.csq_alleles(reference, alternates)[source]#

Return how VEP spells each alternate allele in the CSQ Allele field.

An SNV is its base. When every allele shares the reference’s first base – an indel with its VCF padding – that base is dropped and an allele left empty becomes -.

Return type:

list[str]

ensembl.vep.output.parser.vcf.parser_for(path, input_format=None)[source]#

Return the reader for a file, by its declared format or its extension.

Raises:

ValueError – If the format is not one this package reads.

Return type:

OutputParser