anyvar.vcf.ingest
Support processing and manipulation of VCF objects.
- exception anyvar.vcf.ingest.RequiredAnnotationsError[source]
Raise when encountering incomplete or invalid VRS annotations
- class anyvar.vcf.ingest.VcfRegistrar(data_proxy, **kwargs)[source]
Custom implementation of annotator class from VRS-Python. Rewrite some methods and values in order to enable use of existing AnyVar translator.
- __init__(data_proxy, **kwargs)[source]
Initialize the VCFAnnotator class.
- Parameters:
data_proxy (
_DataProxy) – GA4GH sequence dataproxy instance.
- annotate(input_vcf_path, output_vcf_path=None, vrs_attributes=False, assembly='GRCh38', compute_for_ref=True, require_validation=True, **kwargs)[source]
Calls the parent ‘annotate’ function, then adds the final batch of VRS objects to the database
- Return type:
None
- on_vrs_object(vcf_coords, vrs_allele, **kwargs)[source]
Adds the VRS object to the batcher, which handles bulk registration
- Return type:
Allele|None
- on_vrs_object_collection(vrs_alleles_collection, **kwargs)[source]
Perform clean-up operations (eg file writing) on VRS objects collected during VCF ingestion.
- Parameters:
vrs_alleles_collection (
list[Allele] |None) – VRS alleles constructed from ingested VCF- Return type:
None
- raise_for_output_args(output_vcf_path, **kwargs)[source]
Raise an exception if no output (VCF, PKL, NDJSON) appears to be configured or declared.
- Parameters:
output_vcf_path (
Path|None) – VCF output path arg passed to annotate()output_pkl_path – optional path to PKL output
output_ndjson_path – optional path to NDJSON output
- Raises:
VCFAnnotatorArgsError – if no output args are given
- Return type:
None
-
vrs_object_registration_batcher:
VrsObjectRegistrationBatcher[source]
- class anyvar.vcf.ingest.VrsObjectRegistrationBatcher(anyvar_instance)[source]
Handles bulk registration of a large number of VrsObjects in batches
- __init__(anyvar_instance)[source]
Initialize batch collection list and AnyVar instance to use for registration
- Parameters:
anyvar_instance (
AnyVar) – The AnyVar instance to use for registration- Returns:
None
- anyvar.vcf.ingest.register_existing_annotations(av, file_path, assembly, require_validation=False)[source]
Extract VRS allele parameters from a previously-annotated VCF and register them.
- Parameters:
av (
AnyVar) – AnyVar instancefile_path (
Path) – path to VCFassembly (
str) – assembly used during VCF writing and annotation. Probably one of{"GRCh37", "GRCh38"}require_validation (
bool) – whether to check that annotated ID is correct
- Return type:
Path|None- Returns:
Path to ID conflict file, if requested, or None otherwise
- Raise:
ValueError if input VCF lacks required annotations