Skip to content

Commit 7252597

Browse files
committed
Partially fix #5310 - allow loading of mixed cases with some fully wts sample individuals
1 parent f32e6cc commit 7252597

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

scout/adapter/mongo/variant_loader.py

+17-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pymongo.errors import BulkWriteError, DuplicateKeyError
1313

1414
from scout.build import build_variant
15-
from scout.constants import CHROMOSOMES, ORDERED_FILE_TYPE_MAP
15+
from scout.constants import CHROMOSOMES, INVALID_SAMPLE_TYPES, ORDERED_FILE_TYPE_MAP
1616
from scout.exceptions import IntegrityError
1717
from scout.parse.variant import parse_variant
1818
from scout.parse.variant.clnsig import is_pathogenic
@@ -621,16 +621,16 @@ def _has_variants_in_file(self, variant_file: str) -> bool:
621621

622622
def load_variants(
623623
self,
624-
case_obj,
625-
variant_type="clinical",
626-
category="snv",
627-
rank_threshold=None,
628-
chrom=None,
629-
start=None,
630-
end=None,
631-
gene_obj=None,
632-
custom_images=None,
633-
build="37",
624+
case_obj: dict,
625+
variant_type: str = "clinical",
626+
category: str = "snv",
627+
rank_threshold: float = None,
628+
chrom: str = None,
629+
start: int = None,
630+
end: int = None,
631+
gene_obj: dict = None,
632+
custom_images: list = None,
633+
build: str = "37",
634634
):
635635
"""Load variants for a case into scout.
636636
@@ -675,7 +675,7 @@ def load_variants(
675675
)
676676

677677
gene_to_panels = self.gene_to_panels(case_obj)
678-
genes = [gene_obj for gene_obj in self.all_genes(build=build)]
678+
genes = list(self.all_genes(build=build))
679679
hgncid_to_gene = self.hgncid_to_gene(genes=genes, build=build)
680680
genomic_intervals = self.get_coding_intervals(genes=genes, build=build)
681681

@@ -695,7 +695,11 @@ def load_variants(
695695
LOG.debug("Found VEP header %s", "|".join(vep_header))
696696

697697
# This is a dictionary to tell where ind are in vcf
698-
individual_positions = {ind: i for i, ind in enumerate(vcf_obj.samples)}
698+
individual_positions = {
699+
ind: i
700+
for i, ind in enumerate(vcf_obj.samples)
701+
if vcf_obj.samples[i].analysis_type not in INVALID_SAMPLE_TYPES[category]
702+
}
699703

700704
# Dictionary for cancer analysis
701705
sample_info = {}

scout/constants/file_types.py

+12
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
]
2424
)
2525

26+
INVALID_SAMPLE_TYPES = {
27+
"snv": ["wts"],
28+
"sv": ["wts"],
29+
"mei": ["wts"],
30+
"str": ["wts"],
31+
"vcf_snv_mt": ["wts"],
32+
"vcf_snv_research_mt": ["wts"],
33+
"vcf_snv_research": ["wts"],
34+
"vcf_sv_research_mt": ["wts"],
35+
"vcf_sv_research": ["wts"],
36+
"vcf_mei_research": ["wts"],
37+
}
2638

2739
ORDERED_OMICS_FILE_TYPE_MAP = OrderedDict(
2840
[

0 commit comments

Comments
 (0)