Skip to content
Merged

Dev #5466

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
169677d
first pass format manual variants for response
hanars May 4, 2026
0b7cc43
clean up
hanars May 4, 2026
1d82f81
clean up setting saved variant json
hanars May 4, 2026
c86a123
drop saved variant json
hanars May 4, 2026
b63feed
update test fixtures
hanars May 4, 2026
0ed1912
update test fixtures
hanars May 4, 2026
437ccb6
update matchmaker saved variant json usage
hanars May 4, 2026
ca4c0d6
test clean up
hanars May 4, 2026
3d84ad6
test clean up
hanars May 4, 2026
fa0bf2c
fix saved variant tests
hanars May 4, 2026
98fe671
fix test
hanars May 4, 2026
6a03abb
update set key command
hanars May 4, 2026
e81dfd7
correctly return end for manual SVs
hanars May 5, 2026
17dd63c
fix manual sv response
hanars May 5, 2026
ae10fb1
genome version difff cleanup
hanars May 5, 2026
bac2004
loftee cleanup
hanars May 5, 2026
8abbcf5
remiove callset pop support
hanars May 5, 2026
9c9ff44
pathogenicity clean up
hanars May 5, 2026
1d6f55d
predictor clean up
hanars May 5, 2026
96431c7
sort export cleanup
hanars May 5, 2026
4576018
clean up genotype
hanars May 5, 2026
b296883
clean up
hanars May 6, 2026
1a06aa7
fix linting
hanars May 6, 2026
e94aaf4
caid test coverage
hanars May 8, 2026
c99964d
relaod clinvar type sepcific helper function
hanars May 8, 2026
30e51d5
manager clean up
hanars May 8, 2026
6eadb02
caid error handling clean up
hanars May 8, 2026
0ccc1e8
caid error handling clean up
hanars May 8, 2026
afe878a
search coverage
hanars May 8, 2026
f309583
panel app cleanup
hanars May 8, 2026
a42533c
debug
hanars May 8, 2026
a69144b
clean up export
hanars May 8, 2026
03475e8
fix test
hanars May 8, 2026
fe4c30b
debug
hanars May 8, 2026
85b68f9
reference data prase gene record cleanup
hanars May 8, 2026
af19142
fix error
hanars May 8, 2026
7d30d30
debug
hanars May 8, 2026
68e0fe0
fix multi dt bug
hanars May 8, 2026
b9cc8a3
add coverage
hanars May 8, 2026
c1f6bff
clean up parent hpo mapping
hanars May 8, 2026
df837d6
fix hpo update
hanars May 11, 2026
c7c70b7
debug
hanars May 11, 2026
26ab1f9
fix test
hanars May 11, 2026
1627ea1
sample cleanup
hanars May 11, 2026
b722fb9
debug
hanars May 11, 2026
5012fc9
remove deprecated family structure notation
hanars May 11, 2026
dadf38d
fix hpo update
hanars May 11, 2026
4efd973
fix search error
hanars May 11, 2026
6d0aeea
test csv file iter
hanars May 11, 2026
a8b190b
clean up
hanars May 11, 2026
a09ec58
clean up usage
hanars May 11, 2026
dc5e1ff
fix typo
hanars May 11, 2026
4189a60
fix typo
hanars May 11, 2026
6eff66e
clean up
hanars May 11, 2026
887734c
Merge branch 'dev' of https://github.com/broadinstitute/seqr into cov…
hanars May 11, 2026
19872c8
fix genotype sorting
hanars May 11, 2026
5fa15ed
Merge branch 'dev' of https://github.com/broadinstitute/seqr into cov…
hanars May 12, 2026
afdf810
Merge branch 'dev' of https://github.com/broadinstitute/seqr into cov…
hanars May 13, 2026
115de32
test split pdo warning
hanars May 13, 2026
7dfe8a2
update qc coverage
hanars May 13, 2026
8348e3e
clean up
hanars May 13, 2026
6dc86d9
test error handling for failed email send
hanars May 13, 2026
2102647
dont over mock social auth logging
hanars May 13, 2026
ed7cf13
better mocking
hanars May 13, 2026
1ec8227
test success validating other data types
hanars May 13, 2026
7af90da
test successful wait for service account grant
hanars May 13, 2026
67d91ad
add edge case test
hanars May 13, 2026
2d7911a
update fixture
hanars May 13, 2026
975e230
gregor paternal id mapping
hanars May 13, 2026
e91de03
remove phenotips json upload support
hanars May 13, 2026
23a86eb
fix project test mock
hanars May 13, 2026
6bc9269
test edge case
hanars May 13, 2026
5aa8754
report edge case test
hanars May 14, 2026
2ddb7a2
cleaner logic
hanars May 14, 2026
5beec21
Merge branch 'dev' of https://github.com/broadinstitute/seqr into cov…
hanars May 14, 2026
20a1dee
clean up
hanars May 14, 2026
9c98219
test alerting when fetch for patch fails
hanars May 14, 2026
be9a14b
pedigee util cleanup
hanars May 14, 2026
723c579
first pass new postgres dicts
hanars May 14, 2026
5581acc
allow additional genotype fields
hanars May 14, 2026
4ff7eff
fix dictionary defs
hanars May 14, 2026
1de880c
load individual metadata from clickhouse
hanars May 14, 2026
75e740c
add contact info to metadata
hanars May 14, 2026
51f033b
use clickhosue metadata instead of postgres
hanars May 14, 2026
cb51890
fix metadata for other sv lookup
hanars May 14, 2026
fd846e6
Merge pull request #5438 from broadinstitute/clivar-no-update-slack
hanars May 15, 2026
ca6c425
shared helper for cached variant formatting
hanars May 15, 2026
9e6254d
no access missing indiv
hanars May 15, 2026
183b818
add reload to migration
hanars May 15, 2026
2c1ebd3
pr feedback
hanars May 15, 2026
b64895e
add discovery tags to snv indel variants
hanars May 15, 2026
966c0f7
Merge branch 'dev' of https://github.com/broadinstitute/seqr into vlm…
hanars May 15, 2026
b65fb97
fix variant tables
hanars May 15, 2026
1a5441a
Merge pull request #5426 from broadinstitute/saved-variant-ui-cleanup
hanars May 15, 2026
92a0c9a
Merge pull request #5429 from broadinstitute/coverage-cleanup
hanars May 15, 2026
4c1e1f4
Merge branch 'dev' of https://github.com/broadinstitute/seqr into sav…
hanars May 15, 2026
478d6d8
Merge branch 'saved-variant-json-cleanup' of https://github.com/broad…
hanars May 15, 2026
613fb7c
Merge branch 'vlm-clickhouse-views' of https://github.com/broadinstit…
hanars May 15, 2026
57924a4
use dataset tpe for varant dict get key
hanars May 15, 2026
c8a6282
Merge pull request #5424 from broadinstitute/saved-variant-json-cleanup
hanars May 15, 2026
23a28e3
Merge branch 'dev' of https://github.com/broadinstitute/seqr into vlm…
hanars May 15, 2026
1e5f1bd
Merge branch 'vlm-clickhouse-views' of https://github.com/broadinstit…
hanars May 15, 2026
0892033
add sv discovery families
hanars May 15, 2026
f8a1815
handle other data types
hanars May 15, 2026
7147e6d
add replace missing import
hanars May 15, 2026
f974aaf
update discovery tests
hanars May 15, 2026
85d6e34
fix dataset type key conflicts
hanars May 15, 2026
0208cca
fix anvil call test
hanars May 15, 2026
6711ed3
test fix
hanars May 15, 2026
c6e8609
todo
hanars May 15, 2026
661661c
fix tests
hanars May 18, 2026
dbed324
fix no access project bug
hanars May 18, 2026
5901b35
test search context
hanars May 18, 2026
557efd7
return discovery family mapping in lookup
hanars May 18, 2026
895bda5
fix flappy test
hanars May 18, 2026
8a3fe70
clean up
hanars May 18, 2026
df65987
test discovery fixtures
hanars May 18, 2026
02be7cb
update lookup discovery fixtures
hanars May 18, 2026
6d128f0
discovery lookup test fixture
hanars May 19, 2026
3c3cc8c
cached variant formatting
hanars May 19, 2026
128b738
cached variant formatting
hanars May 19, 2026
9778412
fix test order
hanars May 19, 2026
aa4e819
clean up global tags
hanars May 19, 2026
6b3ca8a
debug
hanars May 19, 2026
764c94c
split fixture data
hanars May 19, 2026
322b90d
more fixture fixes
hanars May 19, 2026
ab3cb05
more fixture fixes
hanars May 19, 2026
5ceefe4
new fixture updates
hanars May 19, 2026
3bfeaa7
fix fixture data
hanars May 19, 2026
093a725
shared helper
hanars May 19, 2026
1fc1cf1
handle exclude tags
hanars May 19, 2026
a52eee1
use actual db query for context discovery tags
hanars May 19, 2026
7be5139
show no access discovery families
hanars May 19, 2026
f571915
restructure lookup tags response
hanars May 19, 2026
8720ebf
display lookup tags
hanars May 19, 2026
12b35b0
better ui linitng
hanars May 19, 2026
78b9ab9
Merge pull request #5440 from broadinstitute/vlm-clickhouse-views
hanars May 19, 2026
78335a3
Merge branch 'dev' of https://github.com/broadinstitute/seqr into dis…
hanars May 19, 2026
ea3954c
return additional metadata lookup fields
hanars May 19, 2026
0d0da24
display additional fields
hanars May 19, 2026
7032c5e
fix tag display
hanars May 19, 2026
3e2d9f1
Apply suggestions from code review
hanars May 20, 2026
bbddc6a
Merge branch 'discovery-families-all-projects' of https://github.com/…
hanars May 20, 2026
826dd37
fix varianst with multiple discovery tags in same family
hanars May 20, 2026
b99e784
correctly test all project family filters
hanars May 20, 2026
a7dab1c
fixture updates
hanars May 20, 2026
6ee0b81
specify correct data type in metadata tuple
hanars May 20, 2026
c1387b6
add instructions for running old npm on new macs
hanars May 20, 2026
7b89e69
Merge pull request #5446 from broadinstitute/node-install-instructions
hanars May 20, 2026
6d45ef5
accordian display for fq
hanars May 20, 2026
7e27449
add processing assitance q to faq
hanars May 20, 2026
645d368
use pyliftover
hanars May 20, 2026
2917f4d
remove hail validation
hanars May 20, 2026
90a0dea
fix typo
hanars May 20, 2026
0eb5ce3
debug
hanars May 20, 2026
9806d7a
fix test
hanars May 20, 2026
1f69b6b
coverage report
hanars May 20, 2026
24f2f45
real requiment files
hanars May 20, 2026
f8c4e7f
no hail dockerfile
hanars May 20, 2026
6f5483d
update test image;
hanars May 20, 2026
a979ec8
fix requiremnts
hanars May 20, 2026
d645344
fix dependency install path
hanars May 20, 2026
6ee1583
add dependency
hanars May 20, 2026
5718fb9
correct jwt package
hanars May 20, 2026
79365c4
clean up
hanars May 20, 2026
91aa892
pr feedback
hanars May 20, 2026
56c6b67
only initialize liftover once
hanars May 20, 2026
1800d58
fix
hanars May 20, 2026
69fd265
Bump qs and express in /ui
dependabot[bot] May 22, 2026
1428a3c
Merge pull request #5450 from broadinstitute/vlm-no-hail
hanars May 26, 2026
9c2e220
Merge pull request #5453 from broadinstitute/dependabot/npm_and_yarn/…
hanars May 26, 2026
ba586c7
Merge pull request #5447 from broadinstitute/faq-update
hanars May 27, 2026
17c3fb3
Bump tmp from 0.2.5 to 0.2.7 in /ui
dependabot[bot] May 28, 2026
8d2314e
Merge pull request #5457 from broadinstitute/dependabot/npm_and_yarn/…
hanars May 28, 2026
42ea2e3
fix igv reference file urls
hanars May 28, 2026
6d166ab
Add missing eigen reference dataset refresh (#5463)
bpblanken May 28, 2026
a083b9f
Merge pull request #5444 from broadinstitute/lookup-analalysis-status…
hanars May 29, 2026
d627cff
Merge pull request #5459 from broadinstitute/igv-fasta
hanars May 29, 2026
a45feb9
Merge pull request #5442 from broadinstitute/discovery-families-all-p…
hanars May 29, 2026
8186ee6
fix test merge conflict
hanars May 29, 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
5 changes: 3 additions & 2 deletions .github/workflows/vlm-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
jobs:
vlm_clickhouse:
runs-on: ubuntu-latest
container: hailgenetics/hail:0.2.128
container: python:3.11-slim-bullseye

services:
clickhouse:
Expand All @@ -44,6 +44,7 @@ jobs:
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip wheel
pip install -r vlm/requirements.txt
pip install -r vlm/requirements-test.txt
- name: Set up Clickhouse Settings and Data
run: python3 vlm/setup_clickhouse_test_data.py clickhouse 8123 clickhouse_test_user clickhouse_test_password
Expand All @@ -57,5 +58,5 @@ jobs:
export CLICKHOUSE_VLM_PASSWORD=vlm_test_password
export CLICKHOUSE_DATABASE=test_seqr
coverage run --source="./vlm" --omit="./vlm/__main__.py","./vlm/setup_clickhouse_test_data.py" -m pytest vlm/
coverage report --fail-under=95
coverage report -m --fail-under=95

382 changes: 298 additions & 84 deletions clickhouse_search/all_search_tests.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions clickhouse_search/backend/table_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def base_fields(cls):
return [(field.db_column or field.name, field) for field in cls._meta.local_fields if field.name != 'key']

@classmethod
def dict_get_expression(cls, *expressions, field_names=None, force_tuple=False, **kwargs):
def dict_get_expression(cls, *expressions, key_template='%(expressions)s', field_names=None, force_tuple=False, **kwargs):
base_fields = cls.base_fields()
if field_names:
base_fields = [f for f in base_fields if f[0] in field_names]
output_field = base_fields[0][1] if len(base_fields) == 1 and not force_tuple else NamedTupleField(base_fields)
dict_get_func = Func(*expressions, output_field=output_field)
dict_get_func.template = cls.dict_get_sql('%(expressions)s', [field_name for field_name, _ in base_fields], **kwargs)
dict_get_func.template = cls.dict_get_sql(key_template, [field_name for field_name, _ in base_fields], **kwargs)
if force_tuple and len(base_fields) == 1:
dict_get_func.template = f'tuple({dict_get_func.template})'
return dict_get_func
Expand Down
88 changes: 88 additions & 0 deletions clickhouse_search/fixtures/clickhouse_discovery_variants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
[{
"model": "clickhouse_search.entriessnvindel",
"pk": 100,
"fields": {
"key": 100,
"project_guid": "R0001_1kg",
"family_guid": "F000002_2",
"sample_type": "WGS",
"xpos": 1248367227,
"is_gnomad_gt_5_percent": false,
"is_annotated_in_any_gene": true,
"geneId_ids": [6, 48],
"filters": [],
"sign": 1,
"calls": [
["HG00733", 1, 99, 0.6530612111091614, 49],
["HG00731", 0, 48, 1, 16]
]
}
}, {
"model": "clickhouse_search.keylookupsnvindel",
"pk": 100,
"fields": {
"key": 100,
"variant_id": "1-248367227-TC-T"
}
}, {
"model": "clickhouse_search.variantssnvindel",
"pk": 100,
"fields": {
"key": 100,
"sorted_motif_feature_consequences": [],
"sorted_regulatory_feature_consequences": [],
"sorted_transcript_consequences": []
}
},{
"model": "clickhouse_search.variantdetailssnvindel",
"pk": 100,
"fields": {
"key": 100,
"variant_id": "1-248367227-TC-T",
"rsid": null,
"caid": "CA1501729",
"lifted_over_chrom": "1",
"lifted_over_pos": null,
"transcripts": [],
"sorted_motif_feature_consequences": [],
"sorted_regulatory_feature_consequences": []
}
}, {
"model": "clickhouse_search.entriessnvindel",
"pk": 100,
"fields": {
"key": 100,
"project_guid": "R0004_non_analyst_project",
"family_guid": "F000014_14",
"sample_type": "WGS",
"xpos": 1248367227,
"is_gnomad_gt_5_percent": false,
"is_annotated_in_any_gene": false,
"geneId_ids": [],
"filters": [],
"sign": 1,
"calls": [
["NA21234", 2, 99, 0, 49]
]
}
}, {
"model": "clickhouse_search.entriessnvindel",
"pk": 100,
"fields": {
"key": 100,
"project_guid": "R0003_test",
"family_guid": "F000012_12",
"sample_type": "WGS",
"xpos": 1248367227,
"is_gnomad_gt_5_percent": false,
"is_annotated_in_any_gene": false,
"geneId_ids": [],
"filters": [],
"sign": 1,
"calls": [
["NA20889", 1, 99, 0.0, 71],
["NA20888", 1, 99, 0.5555556, 9]
]
}
}
]
39 changes: 0 additions & 39 deletions clickhouse_search/fixtures/clickhouse_saved_variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,45 +172,6 @@
"sift": null,
"vest": null
}
}, {
"model": "clickhouse_search.keylookupsnvindel",
"pk": 100,
"fields": {
"key": 100,
"variant_id": "1-248367227-TC-T"
}
}, {
"model": "clickhouse_search.variantdetailssnvindel",
"pk": 100,
"fields": {
"key": 100,
"variant_id": "1-248367227-TC-T",
"rsid": null,
"caid": "CA1501729",
"lifted_over_chrom": "1",
"lifted_over_pos": null,
"transcripts": [],
"sorted_motif_feature_consequences": [],
"sorted_regulatory_feature_consequences": []
}
}, {
"model": "clickhouse_search.entriessnvindel",
"pk": 100,
"fields": {
"key": 100,
"project_guid": "R0004_non_analyst_project",
"family_guid": "F000014_14",
"sample_type": "WGS",
"xpos": 1248367227,
"is_gnomad_gt_5_percent": false,
"is_annotated_in_any_gene": false,
"geneId_ids": [],
"filters": [],
"sign": 1,
"calls": [
["NA21234", 2, 99, 0, 49]
]
}
}, {
"model": "clickhouse_search.keylookupsv",
"pk": 101,
Expand Down
8 changes: 5 additions & 3 deletions clickhouse_search/management/commands/register_caids.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class AlleleRegistryError:
def from_api_response(cls, response: dict):
return cls(
error_type=response["errorType"],
description=response["description"],
message=response["message"],
description=response.get("description"),
message=response.get("message"),
input_line=response.get("inputLine"),
)

Expand Down Expand Up @@ -154,8 +154,10 @@ def handle_api_response(
genome_version: Literal[GENOME_VERSION_GRCh37, GENOME_VERSION_GRCh38],
response: requests.Response,
) -> dict[str, str]:
if not response.ok:
raise HTTPError(f"Unexpected AR response code: {response.status_code}")
response_json = response.json()
if not response.ok or "errorType" in response_json:
if "errorType" in response_json:
error = AlleleRegistryError.from_api_response(response_json)
logger.error(error)
raise HTTPError(error.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,19 @@

logger = logging.getLogger(__name__)

def replace_underscores_with_spaces(value: Union[str, list[str]]) -> Union[str, list[str]]:
if isinstance(value, str):
return value.replace('_', ' ')
elif isinstance(value, list):
return [s.replace('_', ' ') for s in value]
raise TypeError("Expected str or list[str]")
def replace_underscores_with_spaces(value: list[str]) -> list[str]:
return [s.replace('_', ' ') for s in value]

def replace_spaces_with_underscores(value: Union[str, list[str], list[tuple[str, int]]]) -> Union[str, list[str]]:
if isinstance(value, str):
return value.replace(' ', '_')
elif isinstance(value, list):
if len(value) > 0 and isinstance(value[0], tuple):
return [(t[0].replace(' ', '_'), t[1]) for t in value]
return [s.replace(' ', '_') for s in value]
raise TypeError("Expected str or list[str]")
def replace_spaces_with_underscores(value: Union[list[str], list[tuple[str, int]]]) -> list[str]:
if len(value) > 0 and isinstance(value[0], tuple):
return [(t[0].replace(' ', '_'), t[1]) for t in value]
return [s.replace(' ', '_') for s in value]

BATCH_SIZE = 1000
CLINVAR_ASSERTIONS = replace_underscores_with_spaces(ClinvarAllVariantsSnvIndel.CLINVAR_ASSERTIONS)
CLINVAR_CONFLICTING_CLASSICATIONS_OF_PATHOGENICITY = replace_underscores_with_spaces(ClinvarAllVariantsSnvIndel.CLINVAR_CONFLICTING_CLASSICATIONS_OF_PATHOGENICITY)
CLINVAR_CONFLICTING_CLASSICATIONS_OF_PATHOGENICITY = replace_underscores_with_spaces([ClinvarAllVariantsSnvIndel.CLINVAR_CONFLICTING_CLASSICATIONS_OF_PATHOGENICITY])[0]
CLINVAR_CONFLICTING_DATA_FROM_SUBMITTERS = 'conflicting data from submitters'
CLINVAR_DEFAULT_PATHOGENICITY = replace_underscores_with_spaces(ClinvarAllVariantsSnvIndel.CLINVAR_DEFAULT_PATHOGENICITY)
CLINVAR_DEFAULT_PATHOGENICITY = replace_underscores_with_spaces([ClinvarAllVariantsSnvIndel.CLINVAR_DEFAULT_PATHOGENICITY])[0]
CLINVAR_PATHOGENICITIES = replace_underscores_with_spaces(ClinvarAllVariantsSnvIndel.CLINVAR_PATHOGENICITIES)
CLINVAR_GOLD_STARS_LOOKUP = {
'no classification for the single variant': 0,
Expand Down Expand Up @@ -228,7 +220,7 @@ def extract_variant_info(elem: xml.etree.ElementTree.Element, new_version: str,
props = {
'version': new_version,
'allele_id': allele_id,
'pathogenicity': replace_spaces_with_underscores(pathogenicity),
'pathogenicity': replace_spaces_with_underscores([pathogenicity])[0],
'assertions': replace_spaces_with_underscores(assertions),
'conflicting_pathogenicities': replace_spaces_with_underscores(conflicting_pathogenicities),
'gold_stars': gold_stars,
Expand Down Expand Up @@ -261,7 +253,7 @@ def parse_clinvar_file(gzipped_file, existing_version_obj, model_to_batch, unenu
if existing_version_obj:
if existing_version_obj.version == new_version:
logger.info(f'Clinvar ClickHouse tables already successfully updated to {new_version}, gracefully exiting.')
return new_version
return None
logger.info( f'Updating Clinvar ClickHouse tables to {new_version} from {existing_version_obj and existing_version_obj.version}.')
# Drop any currently existing variants in the table that may exist due to a
# previously failed partial run. Note that we validate that the Postgresql existing version
Expand Down Expand Up @@ -306,6 +298,9 @@ def handle(self, *args, **options):
with gzip.open(tmpfile.name, 'rb') as gzipped_file:
new_version = parse_clinvar_file(gzipped_file, existing_version_obj, model_to_batch, unenumerated_value_alerts)

if not new_version:
return

for model, batch in model_to_batch.items():
if batch:
model.objects.using('clickhouse_write').bulk_create(batch)
Expand Down
26 changes: 10 additions & 16 deletions clickhouse_search/management/commands/set_saved_variant_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Command(BaseCommand):
def handle(self, *args, **options):
variant_ids = SavedVariant.objects.filter(
key__isnull=True, family__project__genome_version=GENOME_VERSION_GRCh38,
saved_variant_json__populations__isnull=False, # Omit manual variants
).values_list('variant_id', flat=True).distinct()
ids_by_dataset_type = {
Dataset.DATASET_TYPE_VARIANT_CALLS: [], Dataset.DATASET_TYPE_MITO_CALLS: [], Dataset.DATASET_TYPE_SV_CALLS: [],
Expand Down Expand Up @@ -59,11 +58,6 @@ def handle(self, *args, **options):
if no_keys_37:
self._resolve_missing_variants(no_keys_37, GENOME_VERSION_GRCh37)

num_updated = SavedVariant.objects.filter(key__isnull=False).exclude(saved_variant_json={}).update(
saved_variant_json={},
)
logger.info(f'Cleared saved json for {num_updated} variants with keys')

logger.info('Done')

@staticmethod
Expand Down Expand Up @@ -98,32 +92,32 @@ def _set_variant_keys(variants_ids, dataset_type, genome_version=GENOME_VERSION_
return no_key

@classmethod
def _query_missing_variants(cls, variant_ids, variant_fields, genome_version=GENOME_VERSION_GRCh38):
def _query_missing_variants(cls, variant_ids, variant_fields=None, genome_version=GENOME_VERSION_GRCh38):
missing_variants = SavedVariant.objects.filter(
variant_id__in=variant_ids, family__project__genome_version=genome_version,
)
num_missing = missing_variants.count()
missing_with_data_qs = missing_variants.filter(family__individual__active_datasets__isnull=False).distinct()
missing_with_search_data = missing_with_data_qs.values(
'variant_id', *variant_fields,
'variant_id', *(variant_fields or []),
).annotate(family_ids=ArrayAgg('family__family_id', distinct=True)).order_by('variant_id')
return missing_with_search_data, num_missing

@classmethod
def _resolve_missing_variants(cls, variant_ids, genome_version):
missing_with_search_data, num_missing = cls._query_missing_variants(
variant_ids, ['saved_variant_json__populations__seqr__ac'], genome_version,
variant_ids, genome_version=genome_version,
)
num_data= len(missing_with_search_data)
in_backend = [
f"{var['variant_id']} - {'; '.join(var['family_ids'])}"
for var in missing_with_search_data if var['saved_variant_json__populations__seqr__ac']
]

logger.info(
f'{num_missing} variants have no key, {num_missing - num_data} of which have no search data, {num_data - len(in_backend)} of which are absent from the hail backend.'
f'{num_missing} variants have no key, {num_missing - num_data} of which have no search data.'
)
if in_backend:
logger.info(f'{len(in_backend)} remaining variants: {", ".join(in_backend)}')
if missing_with_search_data:
summary = [
f"{var['variant_id']} - {'; '.join(var['family_ids'])}" for var in missing_with_search_data
]
logger.info(f'{len(missing_with_search_data)} remaining variants: {", ".join(summary)}')

@classmethod
def _resolve_reloaded_svs(cls, variant_ids):
Expand Down
37 changes: 36 additions & 1 deletion clickhouse_search/management/tests/register_caids_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@
},
],
},
{
'@id': 'http://reg.genome.network/allele/CA16716504',
'genomicAlleles': [
{
'chromosome': '1',
'coordinates': [
{
'allele': 'C',
'end': 10131,
'referenceAllele': '', # ref allele is ''
'start': 10131,
},
],
'referenceGenome': 'GRCh38',
},
],
'externalRecords': {
'gnomAD_4': [{'id': '1-91511686-91511734'}], # has invalid gnomad ID
},
},
{
'@id': 'http://reg.genome.network/allele/CA997563845',
'genomicAlleles': [
Expand Down Expand Up @@ -135,6 +155,21 @@ def test_bad_responses(self, mock_safe_post_to_slack, mock_logger):
call_command("register_caids", batch_size=5)
mock_safe_post_to_slack.assert_not_called()

responses.add(
responses.PUT,
"https://reg.genome.network/alleles",
match=[
responses.matchers.query_param_matcher({
"file": "vcf",
"fields": "none @id genomicAlleles externalRecords.gnomAD_4.id",
}, strict_match=False),
],
status=400,
)
with self.assertRaisesMessage(CommandError, 'Failed in 38/ClingenAlleleRegistry curr_key: 3'):
call_command("register_caids", batch_size=5)
mock_safe_post_to_slack.assert_not_called()

responses.reset()
mock_safe_post_to_slack.reset_mock()
mock_logger.reset_mock()
Expand Down Expand Up @@ -224,7 +259,7 @@ def test_register_caids(self, mock_safe_post_to_slack, mock_logger):
dv_38 = DataVersions.objects.get(data_model_name='38/ClingenAlleleRegistry')
self.assertEqual(dv_38.version, '10')
mock_logger.info.assert_called_with(
"2 registered variant(s) cannot be mapped back to ours. \n"
"3 registered variant(s) cannot be mapped back to ours. \n"
"First unmappable variant:\n{'@id': 'http://reg.genome.network/allele/CA16716503', 'genomicAlleles': [{'chromosome': '1', 'coordinates': [{'allele': 'C', 'end': 10131, 'referenceAllele': '', 'start': 10131}], 'referenceGenome': 'GRCh38'}]}"
)
mock_logger.warning.assert_called_with(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def test_new_version_already_exists(self, mock_logger, mock_safe_post_to_slack):
responses.add(responses.GET, WEEKLY_XML_RELEASE, status=200, body=gzip.compress(WEEKLY_XML_RELEASE_DATA.encode()), stream=True)
call_command('reload_clinvar_all_variants')
mock_logger.assert_called_with('Clinvar ClickHouse tables already successfully updated to 2025-06-30, gracefully exiting.')
mock_safe_post_to_slack.assert_not_called()
self.assertEqual(DataVersions.objects.get(data_model_name='Clinvar').version, '2025-06-30')

@responses.activate
def test_parse_variants_all_types(self, mock_logger, mock_safe_post_to_slack):
Expand Down
Loading
Loading