Skip to content

Commit e1628a3

Browse files
authored
refactor: remove if check (#1114)
1 parent bf08294 commit e1628a3

File tree

2 files changed

+41
-42
lines changed

2 files changed

+41
-42
lines changed

v03_pipeline/lib/model/dataset_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def variant_frequency_annotation_fns(self) -> list[Callable[..., hl.Expression]]
374374
DatasetType.SV: [
375375
sv.gt_stats,
376376
],
377-
}.get(self, [])
377+
}[self]
378378

379379
@property
380380
def should_send_to_allele_registry(self):

v03_pipeline/lib/tasks/update_variant_annotations_table_with_new_samples.py

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -71,53 +71,52 @@ def update_table(self, ht: hl.Table) -> hl.Table:
7171

7272
# Union with the new variants table and annotate with the lookup table.
7373
ht = ht.union(new_variants_ht, unify=True)
74-
if self.dataset_type.variant_frequency_annotation_fns:
75-
callset_ht = get_callset_ht(
74+
callset_ht = get_callset_ht(
75+
self.reference_genome,
76+
self.dataset_type,
77+
self.callset_path,
78+
self.project_guids,
79+
)
80+
lookup_ht = None
81+
if self.dataset_type.has_lookup_table:
82+
lookup_ht = hl.read_table(
83+
lookup_table_path(
84+
self.reference_genome,
85+
self.dataset_type,
86+
),
87+
)
88+
# Variants may have fallen out of the callset and
89+
# have been removed from the lookup table during modification.
90+
# Ensure we don't proceed with those variants.
91+
ht = ht.semi_join(lookup_ht)
92+
elif self.dataset_type.gt_stats_from_hl_call_stats:
93+
callset_mt = get_callset_mt(
7694
self.reference_genome,
7795
self.dataset_type,
7896
self.callset_path,
7997
self.project_guids,
8098
)
81-
lookup_ht = None
82-
if self.dataset_type.has_lookup_table:
83-
lookup_ht = hl.read_table(
84-
lookup_table_path(
85-
self.reference_genome,
86-
self.dataset_type,
87-
),
88-
)
89-
# Variants may have fallen out of the callset and
90-
# have been removed from the lookup table during modification.
91-
# Ensure we don't proceed with those variants.
92-
ht = ht.semi_join(lookup_ht)
93-
elif self.dataset_type.gt_stats_from_hl_call_stats:
94-
callset_mt = get_callset_mt(
95-
self.reference_genome,
96-
self.dataset_type,
97-
self.callset_path,
98-
self.project_guids,
99-
)
100-
callset_mt = callset_mt.annotate_rows(
101-
gt_stats=hl.agg.call_stats(callset_mt.GT, callset_mt.alleles),
102-
)
103-
callset_ht = callset_mt.rows()
104-
105-
# new_variants_ht consists of variants present in the new callset, fully annotated,
106-
# but NOT present in the existing annotations table.
107-
# callset_variants_ht consists of variants present in the new callset, fully annotated,
108-
# and either present or not present in the existing annotations table.
109-
callset_variants_ht = ht.semi_join(callset_ht)
110-
non_callset_variants_ht = ht.anti_join(callset_ht)
111-
callset_variants_ht = callset_variants_ht.annotate(
112-
**get_fields(
113-
callset_variants_ht,
114-
self.dataset_type.variant_frequency_annotation_fns,
115-
lookup_ht=lookup_ht,
116-
callset_ht=callset_ht,
117-
**self.param_kwargs,
118-
),
99+
callset_mt = callset_mt.annotate_rows(
100+
gt_stats=hl.agg.call_stats(callset_mt.GT, callset_mt.alleles),
119101
)
120-
ht = non_callset_variants_ht.union(callset_variants_ht, unify=True)
102+
callset_ht = callset_mt.rows()
103+
104+
# new_variants_ht consists of variants present in the new callset, fully annotated,
105+
# but NOT present in the existing annotations table.
106+
# callset_variants_ht consists of variants present in the new callset, fully annotated,
107+
# and either present or not present in the existing annotations table.
108+
callset_variants_ht = ht.semi_join(callset_ht)
109+
non_callset_variants_ht = ht.anti_join(callset_ht)
110+
callset_variants_ht = callset_variants_ht.annotate(
111+
**get_fields(
112+
callset_variants_ht,
113+
self.dataset_type.variant_frequency_annotation_fns,
114+
lookup_ht=lookup_ht,
115+
callset_ht=callset_ht,
116+
**self.param_kwargs,
117+
),
118+
)
119+
ht = non_callset_variants_ht.union(callset_variants_ht, unify=True)
121120
new_variants_ht_globals = new_variants_ht.index_globals()
122121
return ht.select_globals(
123122
versions=new_variants_ht_globals.versions,

0 commit comments

Comments
 (0)