Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
6ab0c31
get variant annotations from clickhouse not hail
hanars Sep 11, 2026
36fcca9
export variant id
hanars Sep 11, 2026
cea6562
clean up export fields
hanars Sep 11, 2026
f58717b
write existing cleanup
hanars Sep 11, 2026
7dc09fb
correct table source;
hanars Sep 11, 2026
0d3f616
clean up
hanars Sep 11, 2026
f2d15ef
clean up
hanars Sep 11, 2026
a50cf6c
update diagram
hanars Sep 14, 2026
81f6a1e
Merge branch 'dev' of https://github.com/broadinstitute/seqr into joi…
hanars Sep 14, 2026
4c1737c
fix gz for parquet
hanars Sep 14, 2026
e3d9e95
update tests
hanars Sep 14, 2026
94046e4
fix path
hanars Sep 14, 2026
c608409
moc sleep t speed up tests
hanars Sep 14, 2026
8135f24
fix gcnv overrides
hanars Sep 14, 2026
96fac21
fix tests
hanars Sep 14, 2026
72b76be
use real gcnv ht fields
hanars Sep 14, 2026
70c6713
fix test load entries setup
hanars Sep 14, 2026
9fcf4cc
fix existing parquet test
hanars Sep 14, 2026
978fc3d
ruff
hanars Sep 14, 2026
4665067
update sleep patch
hanars Sep 15, 2026
c736a67
update fixture data
hanars Sep 15, 2026
180b57b
fix test setu
hanars Sep 15, 2026
127a143
gcnv call fields
hanars Sep 15, 2026
5ddc358
actually fix gcnv
hanars Sep 15, 2026
72b58fa
fix key handling for entries insert
hanars Sep 15, 2026
94eb9a3
fix test
hanars Sep 15, 2026
b06d2ca
correct funcs for gcnv overrides
hanars Sep 15, 2026
1f5a264
load entires test dependencies
hanars Sep 15, 2026
c2df84b
test existing variants parquets with hail
hanars Sep 15, 2026
cb048cb
ruff
hanars Sep 15, 2026
57a5c9d
fix test setup
hanars Sep 15, 2026
8ad4d87
revert gzipping chnge
hanars Sep 15, 2026
08244e4
properly keep override annotations
hanars Sep 15, 2026
7188bc6
fix clickhouse test fixtures
hanars Sep 15, 2026
8c526c6
unused import
hanars Sep 15, 2026
67cb75d
ruff
hanars Sep 15, 2026
6e3e720
Revert "test existing variants parquets with hail"
hanars Sep 15, 2026
014a449
Revert "fix existing parquet test"
hanars Sep 15, 2026
38a22d6
actual update existing variants test
hanars Sep 15, 2026
a711c16
Merge branch 'dev' of https://github.com/broadinstitute/seqr into joi…
hanars Sep 15, 2026
98ff344
fix gcnv annotations
hanars Sep 15, 2026
ef2e7e6
fixture test up[dates
hanars Sep 15, 2026
6ff864f
update gen id test fixtures
hanars Sep 15, 2026
7bd4fa4
better gcnv test
hanars Sep 15, 2026
eabfa8a
update test from fixture
hanars Sep 15, 2026
46a5cea
directly define gcnv entry overrides
hanars Sep 15, 2026
5f9aebd
clean up
hanars Sep 15, 2026
a1d15b0
unused import
hanars Sep 15, 2026
7739f66
debug tests
hanars Sep 15, 2026
7476efa
fix new entries test
hanars Sep 16, 2026
3c27bde
fix test
hanars Sep 16, 2026
61aa3d7
ruff
hanars Sep 16, 2026
bba268b
Merge branch 'dev' of https://github.com/broadinstitute/seqr into joi…
hanars Sep 16, 2026
ca9fe13
fix test
hanars Sep 16, 2026
90ea0ba
clean up gcnv sample overrides
hanars Sep 16, 2026
753e1dd
unambiguous key source
hanars Sep 16, 2026
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
51 changes: 26 additions & 25 deletions loading_pipeline/docs/Diagrams.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,33 @@
WriteRemappedAndSubsettedCallsetTask
|
v
WriteMetadataForRunTask WriteExistingVariantsParquetTask
|___________________________________________|
WriteMetadataForRunTask
|
v
WriteNewVariantsTableTask
|
______________________+_______________________
| | |
v v v
WriteNewEntries... WriteNewVariants... WriteNewVariantDetails...
ParquetTask ParquetTask ParquetTask
| | (optional)
|___________________________|_______________________|
|
v
RunPipelineTask
(all parquets ready)
|
v
WriteSuccessFileTask
|
v
LoadClickhouseVariants
|
v
LoadClickhouseEntries
_________________+__________ WriteExistingVariantsParquetTask
| | |
| |______________________|
| |
v v
WriteNewEntriesParquetTask WriteNewVariantsTableTask
| |
| ____________+____________
| | |
| v v
| WriteNewVariantsParquetTask WriteNewVariantDetailsParquetTask
| | (optional)
|__________________________|_______________________|
|
v
RunPipelineTask (all parquets ready)
|
v
WriteSuccessFileTask
|
v
LoadClickhouseVariants
|
v
LoadClickhouseEntries
```

ClickHouse LSM-Tree
Expand Down
22 changes: 4 additions & 18 deletions loading_pipeline/lib/annotations/gcnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
from loading_pipeline.lib.misc.gcnv import parse_gcnv_genes


def _start_and_end_equal(mt: hl.MatrixTable) -> hl.BooleanExpression:
return (mt.sample_start == mt.start) & (mt.sample_end == mt.end)


def CN(mt: hl.MatrixTable, **_: Any) -> hl.Expression: # noqa: N802
return mt.CN

Expand Down Expand Up @@ -104,29 +100,19 @@ def rg37_locus_end(


def sample_end(mt: hl.MatrixTable, **_: Any) -> hl.Expression:
return hl.or_missing(
~_start_and_end_equal(mt),
mt.sample_end,
)
return mt.sample_end


def sample_gene_ids(mt: hl.MatrixTable, **_: Any) -> hl.Expression:
parsed_genes = parse_gcnv_genes(mt.genes_any_overlap_Ensemble_ID)
return hl.or_missing(parsed_genes != mt.gene_ids, parsed_genes)
return parse_gcnv_genes(mt.genes_any_overlap_Ensemble_ID)


def sample_start(mt: hl.MatrixTable, **_: Any) -> hl.Expression:
return hl.or_missing(
~_start_and_end_equal(mt),
mt.sample_start,
)
return mt.sample_start


def sample_num_exon(mt: hl.MatrixTable, **_: Any) -> hl.Expression:
return hl.or_missing(
mt.genes_any_overlap_totalExons != mt.num_exon,
mt.genes_any_overlap_totalExons,
)
return mt.genes_any_overlap_totalExons


def sorted_gene_consequences(
Expand Down
37 changes: 28 additions & 9 deletions loading_pipeline/lib/misc/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,18 @@ def insert_new_entries(
)
]
common, overrides = [c for c in dst_cols if c in src_cols], {}
if 'geneId_ids' in dst_cols and 'geneIds' in src_cols:
common = [c for c in common if c not in ('geneId_ids', 'geneIds')]
common.insert(0, 'key')
if 'xpos' not in common:
common.append('xpos')
overrides['xpos'] = 'v.xpos'

if 'geneId_ids' in dst_cols:
common.append('geneId_ids')
gene_list_field = (
'sortedGeneConsequences'
if table_name_builder.dataset_type == DatasetType.SV
else 'sortedTranscriptConsequences'
)
overrides['geneId_ids'] = f"""
arrayFilter(
x -> x IS NOT NULL,
Expand All @@ -667,7 +676,7 @@ def insert_new_entries(
'seqrdb_id',
g
),
geneIds
arrayDistinct(v.{gene_list_field}.geneId)
)
)
"""
Expand All @@ -678,16 +687,25 @@ def insert_new_entries(
):
common.append('is_gnomad_gt_5_percent')
overrides['is_gnomad_gt_5_percent'] = f"""
dictGetOrDefault({ClickhouseReferenceDataset.GNOMAD_GENOMES.search_path(table_name_builder)}, 'filter_af', key, 0) > 0.05
dictGetOrDefault({ClickhouseReferenceDataset.GNOMAD_GENOMES.search_path(table_name_builder)}, 'filter_af', e.key, 0) > 0.05
"""

dst_list = ', '.join(common)
src_list = ', '.join([overrides.get(c, c) for c in common])
src_list = ', '.join([overrides.get(c, f'e.{c}') for c in common])
logged_query(
f"""
INSERT INTO {table_name_builder.staging_dst_table(ClickHouseTable.ENTRIES)} ({dst_list})
SELECT {src_list}
FROM {table_name_builder.src_table(ClickHouseTable.ENTRIES)}
FROM (
SELECT
dst.key,
COLUMNS('.*') EXCEPT(variantId, key)
FROM {table_name_builder.src_table(ClickHouseTable.ENTRIES)} src
INNER JOIN {table_name_builder.dst_table(ClickHouseTable.KEY_LOOKUP)} dst
ON {ClickHouseTable.KEY_LOOKUP.join_condition}
) e
INNER JOIN {table_name_builder.dst_table(ClickHouseTable.VARIANTS_MEMORY)} v
ON assumeNotNull(e.key) = v.key
Comment thread
hanars marked this conversation as resolved.
""", # nosec B608
)

Expand Down Expand Up @@ -952,15 +970,14 @@ def export_existing_variants_to_parquet(
reference_genome: ReferenceGenome,
dataset_type: DatasetType,
run_id: str,
export_select_fields: str,
) -> None:
table_name_builder = TableNameBuilder(
reference_genome,
dataset_type,
run_id,
)
variants_table = table_name_builder.dst_table(
ClickHouseTable.VARIANT_DETAILS
ClickHouseTable.KEY_LOOKUP
if dataset_type.should_write_new_variant_details
else ClickHouseTable.VARIANTS_MEMORY,
)
Expand All @@ -970,11 +987,13 @@ def export_existing_variants_to_parquet(
'/*.parquet',
'',
)
dt_fields = ', end, endChrom' if dataset_type == DatasetType.SV else ''
logged_query(
f"""
INSERT INTO FUNCTION {export_table}
SELECT {export_select_fields}
SELECT key AS key_, variantId AS variant_id {dt_fields}
FROM {variants_table}
SETTINGS output_format_parquet_use_custom_encoder=1
""", # nosec B608
)

Expand Down
Loading
Loading