Skip to content
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

Keep full comp-het where only half is new #360

Merged
merged 2 commits into from
Feb 19, 2024
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 .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.0.1
current_version = 3.0.2
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clinvar_runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
curl --fail --silent --show-error -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type:application/json" \
-d '{"output": "generate_clinvar_${{ steps.date.outputs.date }}", "dataset": "talos", "accessLevel": "full", "repo": "automated-interpretation-pipeline", "commit": "${{ github.sha }}", "cwd": "reanalysis", "script": ["./clinvar_runner.py"], "description": "Generate Latest Clinvar Summaries", "image": "australia-southeast1-docker.pkg.dev/cpg-common/images/cpg_aip:3.0.1", "config": {"workflow": {"sequencing_type": "genome"}, "cohorts": {"talos": {"clinvar_filter": ["victorian clinical genetics services, murdoch childrens research institute"]}}}, "wait": false}' \
-d '{"output": "generate_clinvar_${{ steps.date.outputs.date }}", "dataset": "talos", "accessLevel": "full", "repo": "automated-interpretation-pipeline", "commit": "${{ github.sha }}", "cwd": "reanalysis", "script": ["./clinvar_runner.py"], "description": "Generate Latest Clinvar Summaries", "image": "australia-southeast1-docker.pkg.dev/cpg-common/images/cpg_aip:3.0.2", "config": {"workflow": {"sequencing_type": "genome"}, "cohorts": {"talos": {"clinvar_filter": ["victorian clinical genetics services, murdoch childrens research institute"]}}}, "wait": false}' \
https://server-a2pko7ameq-ts.a.run.app
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:
contents: read

env:
VERSION: 3.0.1
VERSION: 3.0.2

jobs:
docker:
Expand Down
20 changes: 18 additions & 2 deletions reanalysis/html_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from argparse import ArgumentParser
from dataclasses import dataclass
from itertools import chain
from pathlib import Path
from typing import Any

Expand Down Expand Up @@ -469,6 +470,9 @@ def check_date_filter(
Check if there's a date filter in the config
if there is, load the results JSON and filter out variants

Extra consideration - if one part of a comp-het variant pair is new,
retain both sides in the report

Args:
results (str): path to the results file
filter_date (str | None): path to the results file
Expand All @@ -483,11 +487,23 @@ def check_date_filter(

# Filter out variants based on date
for content in results_dict.results.values():
# keep only this run's new variants
content.variants = [
# keep only this run's new variants, or partners thereof
vars_to_keep = [
variant for variant in content.variants if variant.first_seen == filter_date
]

pairs_to_keep = set(
chain.from_iterable(var.support_vars for var in vars_to_keep)
)
content.variants = [
variant
for variant in content.variants
if (
variant.first_seen == filter_date
or variant.var_data.coordinates.string_format in pairs_to_keep
)
]

# pop off all the samples with no variants
for sample_id in list(results_dict.results.keys()):
if not results_dict.results[sample_id].variants:
Expand Down
2 changes: 1 addition & 1 deletion reanalysis/reanalysis_global.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ default_memory = 'highmem'

[images]
gatk = 'australia-southeast1-docker.pkg.dev/cpg-common/images/gatk:4.2.6.1'
aip = 'australia-southeast1-docker.pkg.dev/cpg-common/images/cpg_aip:3.0.1'
aip = 'australia-southeast1-docker.pkg.dev/cpg-common/images/cpg_aip:3.0.2'
vep_110 = "australia-southeast1-docker.pkg.dev/cpg-common/images/vep_110:release_110.1"
cpg_workflows = "australia-southeast1-docker.pkg.dev/cpg-common/images/cpg_workflows:latest"

Expand Down
2 changes: 1 addition & 1 deletion reanalysis/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""

# Do not edit this file manually
__version__ = '3.0.1'
__version__ = '3.0.2'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def read_reqs(filename: str) -> list[str]:
name='automated-interpretation-pipeline',
description='CPG Variant Prioritisation',
long_description=readme,
version='3.0.1',
version='3.0.2',
author='Matthew Welland, CPG',
author_email=(
'[email protected], '
Expand Down
53 changes: 53 additions & 0 deletions test/test_html_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,59 @@ def test_check_date_filter(tmp_path):
)


def test_check_date_filter_pair(tmp_path):
"""
test for the case when a comp-het pair is both recovered by one meeting the
specified date and the other not
"""
# needs to be a valid ResultData
result_dict = ResultData(
**{
'metadata': {'categories': {'1': '1'}, 'run_datetime': '2021-01-01'},
'results': {
'sample1': {
'metadata': {'ext_id': 'sample1', 'family_id': 'sample1'},
'variants': [
{
'sample': 'sample1',
'first_seen': '2021-01-01',
'var_data': VAR_1,
'support_vars': {VAR_2.coordinates.string_format},
},
{
'sample': 'sample1',
'first_seen': '2023-03-03',
'var_data': VAR_2,
'support_vars': {VAR_1.coordinates.string_format},
},
],
},
'sample2': {
'metadata': {'ext_id': 'sample1', 'family_id': 'sample1'},
'variants': [
{
'sample': 'sample1',
'first_seen': '2022-02-02',
'var_data': VAR_2,
}
],
},
},
}
)
result_path = str(tmp_path / 'results.json')
with open(result_path, 'w', encoding='utf-8') as handle:
handle.write(ResultData.model_validate(result_dict).model_dump_json(indent=4))

filtered_results = check_date_filter(result_path, '2021-01-01')
assert 'sample1' in filtered_results.results
assert 'sample2' not in filtered_results.results
assert len(filtered_results.results['sample1'].variants) == 2
assert sorted(
var.first_seen for var in filtered_results.results['sample1'].variants
) == ['2021-01-01', '2023-03-03']


def test_check_date_filter_none_pass(tmp_path):
"""

Expand Down
Loading