Skip to content

Commit

Permalink
issue #1114 - setting to reject symbolic variants
Browse files Browse the repository at this point in the history
  • Loading branch information
davmlaw authored and TheMadBug committed Jul 13, 2024
1 parent d820ddc commit 0c460bd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions snpdb/models/models_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from django.urls.base import reverse
from django_extensions.db.models import TimeStampedModel
from model_utils.managers import InheritanceManager
from pydantic import field_validator

from flags.models import FlagCollection, flag_collection_extra_info_signal, FlagInfos
from flags.models.models import FlagsMixin, FlagTypeContext
Expand Down Expand Up @@ -228,6 +229,12 @@ class VariantCoordinate(FormerTuple, pydantic.BaseModel):
alt: str
svlen: Optional[int] = None

@field_validator('svlen')
def validate_svlen(cls, value):
if value is not None and settings.VARIANT_SYMBOLIC_ALT_ENABLED is False:
raise ValueError('Symbolic variants disabled via settings.')
return value

@property
def as_tuple(self) -> tuple:
return self.chrom, self.position, self.ref, self.alt, self.svlen
Expand Down
7 changes: 5 additions & 2 deletions upload/management/commands/vcf_clean_and_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ def handle(self, *args, **options):
if alt_standard_bases_pattern.sub("", alt):
skip_reason = None
if alt.startswith("<") and alt.endswith(">"):
if alt not in settings.VARIANT_SYMBOLIC_ALT_VALID_TYPES:
skip_reason = f"ALT = {alt}"
if settings.VARIANT_SYMBOLIC_ALT_ENABLED:
if alt not in settings.VARIANT_SYMBOLIC_ALT_VALID_TYPES:
skip_reason = f"ALT = {alt}"
else:
skip_reason = "Symbolic variants disabled via settings."
else:
skip_reason = "non-standard bases in ALT sequence"
if skip_reason:
Expand Down
1 change: 1 addition & 0 deletions variantgrid/settings/components/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@
VARIANT_MANUAL_CREATE_BY_NON_ADMIN = True
# Below this size, variants are stored with ref/alt sequences. Above this threshold, they become
# structural variants and use symbolic
VARIANT_SYMBOLIC_ALT_ENABLED = True
VARIANT_SYMBOLIC_ALT_SIZE = 1000
VARIANT_SYMBOLIC_ALT_VALID_TYPES = {VCFSymbolicAllele.CNV, VCFSymbolicAllele.DEL,
VCFSymbolicAllele.DUP, VCFSymbolicAllele.INV}
Expand Down
1 change: 1 addition & 0 deletions variantgrid/settings/env/shariantcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
VARIANT_DETAILS_SHOW_ANNOTATION = False
VARIANT_DETAILS_SHOW_SAMPLES = False
VARIANT_VCF_DB_PREFIX = "stv"
VARIANT_SYMBOLIC_ALT_ENABLED = False

VIEW_GENE_HOTSPOT_GRAPH_CLASSIFICATIONS = False
VIEW_GENE_WIKI = False
Expand Down

0 comments on commit 0c460bd

Please sign in to comment.