From 0b3a872150b494384fb271d2f1841226f30bc7f9 Mon Sep 17 00:00:00 2001 From: Hana Snow Date: Tue, 13 Feb 2024 17:10:25 -0500 Subject: [PATCH] add tests and fix bugs --- hail_search/queries/sv.py | 2 +- hail_search/test_search.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hail_search/queries/sv.py b/hail_search/queries/sv.py index 526cc52319..bc887410f6 100644 --- a/hail_search/queries/sv.py +++ b/hail_search/queries/sv.py @@ -76,7 +76,7 @@ def _parse_annotations(self, annotations, *args, **kwargs): def _get_family_passes_quality_filter(self, quality_filter, parsed_annotations=None, **kwargs): passes_quality = super()._get_family_passes_quality_filter(quality_filter) - if not parsed_annotations[NEW_SV_FIELD]: + if not (parsed_annotations or {}).get(NEW_SV_FIELD): return passes_quality entries_has_new_call = lambda entries: entries.any(lambda x: x.concordance.new_call) diff --git a/hail_search/test_search.py b/hail_search/test_search.py index 2bc9337fbe..c02e1c0935 100644 --- a/hail_search/test_search.py +++ b/hail_search/test_search.py @@ -662,6 +662,11 @@ async def test_variant_lookup(self): resp_json = await resp.json() self.assertDictEqual(resp_json, {**SV_VARIANT4, 'familyGuids': [], 'genotypes': {}, 'genotypeFilters': ''}) + async with self.client.request('POST', '/lookup', json={**body, 'sample_data': SV_WGS_SAMPLE_DATA['SV_WGS']}) as resp: + self.assertEqual(resp.status, 200) + resp_json = await resp.json() + self.assertDictEqual(resp_json, SV_VARIANT4) + body.update({'variant_id': 'suffix_140608_DUP', 'data_type': 'SV_WES'}) async with self.client.request('POST', '/lookup', json=body) as resp: self.assertEqual(resp.status, 200) @@ -670,6 +675,16 @@ async def test_variant_lookup(self): **GCNV_VARIANT4, 'numExon': 8, 'end': 38736268, 'familyGuids': [], 'genotypes': {}, 'genotypeFilters': '', }) + async with self.client.request('POST', '/lookup', json={**body, 'sample_data': EXPECTED_SAMPLE_DATA['SV_WES']}) as resp: + self.assertEqual(resp.status, 200) + resp_json = await resp.json() + self.assertDictEqual(resp_json, { + **GCNV_VARIANT4, 'numExon': 8, 'end': 38736268, 'genotypes': { + individual: {k: v for k, v in genotype.items() if k not in {'start', 'end', 'numExon', 'geneIds'}} + for individual, genotype in GCNV_VARIANT4['genotypes'].items() + } + }) + async def test_frequency_filter(self): sv_callset_filter = {'sv_callset': {'af': 0.05}} await self._assert_expected_search(