Skip to content

Commit

Permalink
Make abstract class an ABC. Add type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
davmlaw committed Jan 31, 2025
1 parent 09a4bca commit 9a6691b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion upload/vcf/abstract_bulk_vcf_processor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import abc
import os

import cyvcf2
Expand All @@ -10,7 +11,7 @@
from upload.vcf.sql_copy_files import write_sql_copy_csv


class AbstractBulkVCFProcessor:
class AbstractBulkVCFProcessor(abc.ABC):
""" The minimum a VCF processor needs to do is
set max_variant_id and insert multi-allelics so we know what was normalised """

Expand All @@ -29,6 +30,14 @@ def __init__(self, upload_step, preprocess_vcf_import_info, batch_size=settings.
self.modified_imported_variants = []
self.variant_pk_lookup = VariantPKLookup(upload_step.genome_build)

@abc.abstractmethod
def process_entry(self, variant: cyvcf2.Variant):
pass

@abc.abstractmethod
def finish(self):
pass

@property
def genome_build(self):
return self.upload_pipeline.genome_build
Expand Down
2 changes: 1 addition & 1 deletion upload/vcf/bulk_minimal_vcf_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_vcf_importer_version():
code_git_hash=Git(settings.BASE_DIR).hash)
return vcf_importer

def process_entry(self, variant):
def process_entry(self, variant: cyvcf2.Variant):
ref, alt, svlen = vcf_get_ref_alt_svlen(variant)
variant_coordinate = VariantCoordinate(chrom=variant.CHROM, position=variant.POS, ref=ref, alt=alt, svlen=svlen)
variant_hash = self.variant_pk_lookup.get_variant_coordinate_hash(variant_coordinate)
Expand Down

0 comments on commit 9a6691b

Please sign in to comment.