Skip to content

refactor: remove if check #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion v03_pipeline/lib/model/dataset_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def variant_frequency_annotation_fns(self) -> list[Callable[..., hl.Expression]]
DatasetType.SV: [
sv.gt_stats,
],
}.get(self, [])
}[self]

@property
def should_send_to_allele_registry(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,53 +71,52 @@ def update_table(self, ht: hl.Table) -> hl.Table:

# Union with the new variants table and annotate with the lookup table.
ht = ht.union(new_variants_ht, unify=True)
if self.dataset_type.variant_frequency_annotation_fns:
callset_ht = get_callset_ht(
callset_ht = get_callset_ht(
self.reference_genome,
self.dataset_type,
self.callset_path,
self.project_guids,
)
lookup_ht = None
if self.dataset_type.has_lookup_table:
lookup_ht = hl.read_table(
lookup_table_path(
self.reference_genome,
self.dataset_type,
),
)
# Variants may have fallen out of the callset and
# have been removed from the lookup table during modification.
# Ensure we don't proceed with those variants.
ht = ht.semi_join(lookup_ht)
elif self.dataset_type.gt_stats_from_hl_call_stats:
callset_mt = get_callset_mt(
self.reference_genome,
self.dataset_type,
self.callset_path,
self.project_guids,
)
lookup_ht = None
if self.dataset_type.has_lookup_table:
lookup_ht = hl.read_table(
lookup_table_path(
self.reference_genome,
self.dataset_type,
),
)
# Variants may have fallen out of the callset and
# have been removed from the lookup table during modification.
# Ensure we don't proceed with those variants.
ht = ht.semi_join(lookup_ht)
elif self.dataset_type.gt_stats_from_hl_call_stats:
callset_mt = get_callset_mt(
self.reference_genome,
self.dataset_type,
self.callset_path,
self.project_guids,
)
callset_mt = callset_mt.annotate_rows(
gt_stats=hl.agg.call_stats(callset_mt.GT, callset_mt.alleles),
)
callset_ht = callset_mt.rows()

# new_variants_ht consists of variants present in the new callset, fully annotated,
# but NOT present in the existing annotations table.
# callset_variants_ht consists of variants present in the new callset, fully annotated,
# and either present or not present in the existing annotations table.
callset_variants_ht = ht.semi_join(callset_ht)
non_callset_variants_ht = ht.anti_join(callset_ht)
callset_variants_ht = callset_variants_ht.annotate(
**get_fields(
callset_variants_ht,
self.dataset_type.variant_frequency_annotation_fns,
lookup_ht=lookup_ht,
callset_ht=callset_ht,
**self.param_kwargs,
),
callset_mt = callset_mt.annotate_rows(
gt_stats=hl.agg.call_stats(callset_mt.GT, callset_mt.alleles),
)
ht = non_callset_variants_ht.union(callset_variants_ht, unify=True)
callset_ht = callset_mt.rows()

# new_variants_ht consists of variants present in the new callset, fully annotated,
# but NOT present in the existing annotations table.
# callset_variants_ht consists of variants present in the new callset, fully annotated,
# and either present or not present in the existing annotations table.
callset_variants_ht = ht.semi_join(callset_ht)
non_callset_variants_ht = ht.anti_join(callset_ht)
callset_variants_ht = callset_variants_ht.annotate(
**get_fields(
callset_variants_ht,
self.dataset_type.variant_frequency_annotation_fns,
lookup_ht=lookup_ht,
callset_ht=callset_ht,
**self.param_kwargs,
),
)
ht = non_callset_variants_ht.union(callset_variants_ht, unify=True)
new_variants_ht_globals = new_variants_ht.index_globals()
return ht.select_globals(
versions=new_variants_ht_globals.versions,
Expand Down