Skip to content

Commit ec656fb

Browse files
authored
Missing type empty entries (#667)
* Missing type empty entries * Lint
1 parent 4155dbb commit ec656fb

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

v03_pipeline/lib/misc/sample_entries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def globalize_sample_ids(ht: hl.Table) -> hl.Table:
88
# NB: normal python expression here because the row is localized.
99
# I had an easier time with this than hl.agg.take(1), which was an
1010
# alternative implementation.
11-
[e.s for e in row[0].entries] if len(row) > 0 else hl.empty_array(hl.tstr)
11+
[e.s for e in row[0].entries] if (row and len(row[0].entries) > 0) else hl.empty_array(hl.tstr)
1212
),
1313
)
1414
return ht.annotate(entries=ht.entries.map(lambda s: s.drop('s')))

v03_pipeline/lib/misc/sample_entries_test.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,49 @@ def test_filter_callset_entries(self) -> None:
326326
),
327327
],
328328
)
329+
330+
331+
def test_filter_all_callset_entries(self) -> None:
332+
entries_ht = hl.Table.parallelize(
333+
[
334+
{
335+
'id': 0,
336+
'filters': {'HIGH_SR_BACKGROUND'},
337+
'entries': [
338+
hl.Struct(a=1),
339+
hl.Struct(a=2),
340+
hl.Struct(a=1),
341+
hl.Struct(a=2),
342+
],
343+
},
344+
{
345+
'id': 1,
346+
'filters': {'HIGH_SR_BACKGROUND'},
347+
'entries': [
348+
hl.Struct(a=2),
349+
hl.Struct(a=3),
350+
hl.Struct(a=4),
351+
hl.Struct(a=5),
352+
],
353+
},
354+
],
355+
hl.tstruct(
356+
id=hl.tint32,
357+
filters=hl.tset(hl.tstr),
358+
entries=hl.tarray(hl.tstruct(a=hl.tint32)),
359+
),
360+
key='id',
361+
globals=hl.Struct(sample_ids=['a', 'c', 'e', 'f']),
362+
)
363+
sample_subset_ht = hl.Table.parallelize(
364+
[{'s': 'a'}, {'s': 'c'}, {'s': 'd'}, {'s': 'e'}, {'s': 'f'}],
365+
hl.tstruct(
366+
s=hl.dtype('str'),
367+
),
368+
key='s',
369+
)
370+
ht = filter_callset_entries(entries_ht, sample_subset_ht)
371+
self.assertCountEqual(
372+
ht.globals.collect(),
373+
[hl.Struct(sample_ids=[])],
374+
)

0 commit comments

Comments
 (0)