Skip to content

Commit

Permalink
add tests and fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
hanars committed Feb 13, 2024
1 parent 03332b0 commit 0b3a872
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hail_search/queries/sv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions hail_search/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down

0 comments on commit 0b3a872

Please sign in to comment.