Skip to content

Commit 3cd656b

Browse files
committed
add env vars too!
1 parent e5b446d commit 3cd656b

10 files changed

+35
-32
lines changed

v03_pipeline/lib/model/environment.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
ACCESS_PRIVATE_REFERENCE_DATASETS = (
2929
os.environ.get('ACCESS_PRIVATE_REFERENCE_DATASETS') == '1'
3030
)
31+
CHECK_SEX_AND_RELATEDNESS = os.environ.get('CHECK_SEX_AND_RELATEDNESS') == '1'
32+
EXPECT_WES_FILTERS = os.environ.get('EXPECT_WES_FILTERS') == '1'
3133
REFERENCE_DATA_AUTO_UPDATE = os.environ.get('REFERENCE_DATA_AUTO_UPDATE') == '1'
3234
SHOULD_REGISTER_ALLELES = os.environ.get('SHOULD_REGISTER_ALLELES') == '1'
3335

@@ -36,6 +38,8 @@
3638
class Env:
3739
ACCESS_PRIVATE_REFERENCE_DATASETS: bool = ACCESS_PRIVATE_REFERENCE_DATASETS
3840
ALLELE_REGISTRY_SECRET_NAME: str | None = ALLELE_REGISTRY_SECRET_NAME
41+
CHECK_SEX_AND_RELATEDNESS: bool = CHECK_SEX_AND_RELATEDNESS
42+
EXPECT_WES_FILTERS: bool = EXPECT_WES_FILTERS
3943
HAIL_TMPDIR: str = HAIL_TMPDIR
4044
HAIL_SEARCH_DATA: str = HAIL_SEARCH_DATA
4145
LIFTOVER_REF_PATH: str = LIFTOVER_REF_PATH

v03_pipeline/lib/paths.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def valid_filters_path(
222222
callset_path: str,
223223
) -> str | None:
224224
if (
225+
not Env.EXPECT_WES_FILTERS or
225226
not dataset_type.expect_filters(sample_type)
226227
or 'part_one_outputs' not in callset_path
227228
):
@@ -240,7 +241,7 @@ def valid_reference_dataset_collection_path(
240241
) -> str | None:
241242
if (
242243
not Env.ACCESS_PRIVATE_REFERENCE_DATASETS
243-
and reference_dataset_collection.access_control == AccessControl.PRIVATE
244+
or reference_dataset_collection.access_control == AccessControl.PUBLIC
244245
):
245246
return None
246247
return os.path.join(

v03_pipeline/lib/paths_test.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,16 @@ def test_valid_filters_path(self) -> None:
6666
),
6767
None,
6868
)
69-
self.assertEqual(
70-
valid_filters_path(
71-
DatasetType.SNV_INDEL,
72-
SampleType.WES,
73-
'gs://bucket/RDG_Broad_WES_Internal_Oct2023/part_one_outputs/chr*/*.vcf.gz',
74-
),
75-
'gs://bucket/RDG_Broad_WES_Internal_Oct2023/part_two_outputs/*.filtered.*.vcf.gz',
76-
)
69+
with patch('v03_pipeline.lib.paths.Env') as mock_env:
70+
mock_env.EXPECT_WES_FILTERS = True
71+
self.assertEqual(
72+
valid_filters_path(
73+
DatasetType.SNV_INDEL,
74+
SampleType.WES,
75+
'gs://bucket/RDG_Broad_WES_Internal_Oct2023/part_one_outputs/chr*/*.vcf.gz',
76+
),
77+
'gs://bucket/RDG_Broad_WES_Internal_Oct2023/part_two_outputs/*.filtered.*.vcf.gz',
78+
)
7779

7880
def test_project_table_path(self) -> None:
7981
self.assertEqual(

v03_pipeline/lib/tasks/update_lookup_table_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def test_skip_update_lookup_table_task(self) -> None:
2626
project_remap_paths=[TEST_REMAP],
2727
project_pedigree_paths=[TEST_PEDIGREE_3],
2828
skip_validation=True,
29-
skip_check_sex_and_relatedness=True,
3029
)
3130
worker.add(uslt_task)
3231
worker.run()
@@ -58,7 +57,6 @@ def test_update_lookup_table_task(self) -> None:
5857
project_remap_paths=[TEST_REMAP],
5958
project_pedigree_paths=[TEST_PEDIGREE_3],
6059
skip_validation=True,
61-
skip_check_sex_and_relatedness=True,
6260
)
6361
worker.add(uslt_task)
6462
worker.run()

v03_pipeline/lib/tasks/update_project_table_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def test_update_project_table_task(self) -> None:
2222
project_remap_path=TEST_REMAP,
2323
project_pedigree_path=TEST_PEDIGREE_3,
2424
skip_validation=True,
25-
skip_check_sex_and_relatedness=True,
2625
)
2726
worker.add(upt_task)
2827
worker.run()

v03_pipeline/lib/tasks/update_variant_annotations_table_with_new_samples_test.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def test_missing_pedigree(
163163
project_remap_paths=[TEST_REMAP],
164164
project_pedigree_paths=['bad_pedigree'],
165165
skip_validation=True,
166-
skip_check_sex_and_relatedness=True,
167166
run_id=TEST_RUN_ID,
168167
)
169168
worker = luigi.worker.Worker()
@@ -197,7 +196,6 @@ def test_missing_interval_reference(
197196
project_remap_paths=[TEST_REMAP],
198197
project_pedigree_paths=[TEST_PEDIGREE_3],
199198
skip_validation=True,
200-
skip_check_sex_and_relatedness=True,
201199
run_id=TEST_RUN_ID,
202200
)
203201
worker = luigi.worker.Worker()
@@ -366,7 +364,6 @@ def test_multiple_update_vat(
366364
project_remap_paths=[TEST_REMAP],
367365
project_pedigree_paths=[TEST_PEDIGREE_3],
368366
skip_validation=False,
369-
skip_check_sex_and_relatedness=True,
370367
run_id=TEST_RUN_ID,
371368
)
372369
worker.add(uvatwns_task_3)
@@ -418,7 +415,6 @@ def test_multiple_update_vat(
418415
project_remap_paths=[TEST_REMAP],
419416
project_pedigree_paths=[TEST_PEDIGREE_4],
420417
skip_validation=False,
421-
skip_check_sex_and_relatedness=True,
422418
run_id=TEST_RUN_ID,
423419
)
424420
worker.add(uvatwns_task_4)
@@ -689,7 +685,6 @@ def test_update_vat_grch37(
689685
project_remap_paths=[TEST_REMAP],
690686
project_pedigree_paths=[TEST_PEDIGREE_3],
691687
skip_validation=True,
692-
skip_check_sex_and_relatedness=True,
693688
run_id=TEST_RUN_ID,
694689
)
695690
worker.add(uvatwns_task)
@@ -769,7 +764,6 @@ def test_update_vat_without_accessing_private_datasets(
769764
project_remap_paths=[TEST_REMAP],
770765
project_pedigree_paths=[TEST_PEDIGREE_3],
771766
skip_validation=True,
772-
skip_check_sex_and_relatedness=True,
773767
run_id=TEST_RUN_ID,
774768
)
775769
worker.add(uvatwns_task)
@@ -827,7 +821,6 @@ def test_mito_update_vat(
827821
project_remap_paths=['not_a_real_file'],
828822
project_pedigree_paths=[TEST_PEDIGREE_5],
829823
skip_validation=True,
830-
skip_check_sex_and_relatedness=True,
831824
run_id=TEST_RUN_ID,
832825
)
833826
)
@@ -1092,7 +1085,6 @@ def test_sv_update_vat(
10921085
project_remap_paths=['not_a_real_file'],
10931086
project_pedigree_paths=[TEST_PEDIGREE_5],
10941087
skip_validation=True,
1095-
skip_check_sex_and_relatedness=True,
10961088
run_id=TEST_RUN_ID,
10971089
)
10981090
)
@@ -1654,7 +1646,6 @@ def test_gcnv_update_vat(
16541646
project_remap_paths=['not_a_real_file'],
16551647
project_pedigree_paths=[TEST_PEDIGREE_5],
16561648
skip_validation=True,
1657-
skip_check_sex_and_relatedness=True,
16581649
run_id=TEST_RUN_ID,
16591650
)
16601651
)

v03_pipeline/lib/tasks/write_family_table_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def test_snv_write_family_table_task(self) -> None:
2626
project_pedigree_path=TEST_PEDIGREE_3,
2727
family_guid='abc_1',
2828
skip_validation=True,
29-
skip_check_sex_and_relatedness=True,
3029
)
3130
worker.add(wft_task)
3231
worker.run()
@@ -164,7 +163,6 @@ def test_sv_write_family_table_task(self) -> None:
164163
project_pedigree_path=TEST_PEDIGREE_5,
165164
family_guid='family_2_1',
166165
skip_validation=True,
167-
skip_check_sex_and_relatedness=True,
168166
)
169167
worker.add(write_family_table_task)
170168
worker.run()
@@ -417,7 +415,6 @@ def test_gcnv_write_family_table_task(self) -> None:
417415
project_pedigree_path=TEST_PEDIGREE_5,
418416
family_guid='family_2_1',
419417
skip_validation=True,
420-
skip_check_sex_and_relatedness=True,
421418
)
422419
worker.add(write_family_table_task)
423420
worker.run()

v03_pipeline/lib/tasks/write_imported_callset.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ def output(self) -> luigi.Target:
5555

5656
def requires(self) -> list[luigi.Task]:
5757
requirements = []
58-
if not self.skip_expect_filters and self.dataset_type.expect_filters(
59-
self.sample_type,
58+
if (
59+
Env.EXPECT_WES_FILTERS
60+
and not self.skip_expect_filters
61+
and self.dataset_type.expect_filters(
62+
self.sample_type,
63+
)
6064
):
6165
requirements = [
6266
*requirements,
@@ -87,7 +91,8 @@ def requires(self) -> list[luigi.Task]:
8791
),
8892
]
8993
if (
90-
not self.skip_check_sex_and_relatedness
94+
Env.CHECK_SEX_AND_RELATEDNESS
95+
and not self.skip_check_sex_and_relatedness
9196
and self.dataset_type.check_sex_and_relatedness
9297
):
9398
requirements = [
@@ -124,8 +129,12 @@ def create_table(self) -> hl.MatrixTable:
124129
self.dataset_type,
125130
)
126131
filters_path = None
127-
if not self.skip_expect_filters and self.dataset_type.expect_filters(
128-
self.sample_type,
132+
if (
133+
Env.EXPECT_WES_FILTERS
134+
and not self.skip_expect_filters
135+
and self.dataset_type.expect_filters(
136+
self.sample_type,
137+
)
129138
):
130139
filters_path = valid_filters_path(
131140
self.dataset_type,
@@ -178,7 +187,8 @@ def create_table(self) -> hl.MatrixTable:
178187
self.sample_type,
179188
)
180189
if (
181-
not self.skip_check_sex_and_relatedness
190+
Env.CHECK_SEX_AND_RELATEDNESS
191+
and not self.skip_check_sex_and_relatedness
182192
and self.dataset_type.check_sex_and_relatedness
183193
):
184194
sex_check_ht = hl.read_table(

v03_pipeline/lib/tasks/write_metadata_for_run_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def test_write_metadata_for_run_task(self) -> None:
2323
project_guids=['R0113_test_project', 'R0114_project4'],
2424
project_remap_paths=[TEST_REMAP_2, TEST_REMAP_2],
2525
project_pedigree_paths=[TEST_PEDIGREE_3, TEST_PEDIGREE_4],
26-
skip_check_sex_and_relatedness=True,
2726
skip_validation=True,
2827
run_id='run_123456',
2928
)

v03_pipeline/lib/tasks/write_remapped_and_subsetted_callset.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
)
1616
from v03_pipeline.lib.misc.pedigree import parse_pedigree_ht_to_families
1717
from v03_pipeline.lib.misc.sample_ids import remap_sample_ids, subset_samples
18+
from v03_pipeline.lib.model.environment import Env
1819
from v03_pipeline.lib.paths import remapped_and_subsetted_callset_path
1920
from v03_pipeline.lib.tasks.base.base_loading_run_params import BaseLoadingRunParams
2021
from v03_pipeline.lib.tasks.base.base_write import BaseWriteTask
@@ -88,7 +89,8 @@ def create_table(self) -> hl.MatrixTable:
8889
families_failed_relatedness_check = {}
8990
families_failed_sex_check = {}
9091
if (
91-
not self.skip_check_sex_and_relatedness
92+
Env.CHECK_SEX_AND_RELATEDNESS
93+
and not self.skip_check_sex_and_relatedness
9294
and self.dataset_type.check_sex_and_relatedness
9395
):
9496
relatedness_check_ht = hl.read_table(self.input()[2].path)

0 commit comments

Comments
 (0)