ensembl.vep.output.factory.write package#
Writers of annotated output.
Submodules#
ensembl.vep.output.factory.write.base module#
The contract a writer of annotated output implements.
ensembl.vep.output.factory.write.json module#
JSON-lines annotated-variant output.
ensembl.vep.output.factory.write.registry module#
Annotated-variant output writer registry.
- ensembl.vep.output.factory.write.registry.available_output_writers()[source]#
Return the sorted set of registered output formats.
- Return type:
tuple[str,...]
- ensembl.vep.output.factory.write.registry.get_output_writer(output_format, *, command_line='')[source]#
Return the writer for one output format.
- Raises:
ValueError – If no writer supports
output_format.- Return type:
- ensembl.vep.output.factory.write.registry.register_output_writer(name)[source]#
Register an output writer factory under a format name.
- Return type:
Callable[[Callable[[str],OutputWriter]],Callable[[str],OutputWriter]]
ensembl.vep.output.factory.write.vcf module#
VCF output: the input line back, with a CSQ INFO field of pipe-separated consequences.
A port of Perl VEP’s OutputFactory/VCF.pm. A snapshot’s original VCF line is written back with
any previous CSQ replaced. Each selected (allele, feature) record becomes one comma-separated
chunk whose fields follow the Format the header declares – which is exactly what
output/parser/vcf.py reads back.
A snapshot that did not come from a VCF line carries no columns, and VCF cannot invent them: an
indel’s spelling needs reference bases, which a detached snapshot deliberately does not hold. So
whoever builds such a snapshot supplies the columns, with the padding rule
corpus/exporter/formats/file/vcf.py uses; writing one without them is refused rather than
guessed at.
- class ensembl.vep.output.factory.write.vcf.VCFOutputWriter(*, records=AnnotatedVariantFactory(), info_field='CSQ', keep_csq=False, command_line='', time=None)[source]#
Bases:
objectVCF serializer for annotated-variant snapshots.
- Variables:
records (AnnotatedVariantFactory) – The factory whose flags the declared
Formatmust describe, so a reader of the header finds the fields the records actually carry.info_field (str) – The INFO key consequences are written under.
keep_csq (bool) – Keep a
CSQalready on the input line, and its header, instead of replacing them.command_line (str) – The command written into the header.
time (str | None) – The timestamp written into the header, or None for now.
- command_line: str#
- fields()[source]#
Return the fields each chunk carries: VEP’s defaults, then what the flags add.
- Return type:
list[str]
- headers(input_headers=())[source]#
Return the header lines, carrying the input file’s own when there are any.
- Parameters:
input_headers (
Sequence[str], default:()) – The input VCF’s header lines, column heading last.- Returns:
The meta lines, then VEP’s own, then the column heading.
- Return type:
list[str]
- info_chunk(output_hash, strand=1)[source]#
Encode one output hash as a pipe-separated chunk.
The escaping is VEP’s: the characters VCF reserves inside INFO –
,;|and whitespace – are replaced so a chunk can never split, and-means empty in every field butAllele. A zero is kept rather than blanked.- Return type:
str
- info_field: str#
- keep_csq: bool#
- prepare_input_columns(record_columns)[source]#
Copy input columns and remove an annotation field scheduled for replacement.
- Return type:
list[str]
- records: AnnotatedVariantFactory#
- time: str | None#
- property version: str#
Return the version written into the header.
- ensembl.vep.output.factory.write.vcf.VCF_COLS = ('Allele', 'Consequence', 'IMPACT', 'SYMBOL', 'Gene', 'Feature_type', 'Feature', 'BIOTYPE', 'EXON', 'INTRON', 'HGVSc', 'HGVSp', 'cDNA_position', 'CDS_position', 'Protein_position', 'Amino_acids', 'Codons', 'Existing_variation')#
The
CSQfields VEP writes by default, in its order.