1
- import pytest
2
1
from cattrs import structure , structure_attrs_fromdict
3
2
import hail as hl
4
3
import json
5
4
6
- from data_pipeline . pipelines . gnomad_v4_variants import (
7
- pipeline as gnomad_v4_variant_pipeline ,
8
- )
5
+ from loguru import logger
6
+
7
+ from data_pipeline . pipeline import Pipeline
9
8
10
9
from data_pipeline .datasets .gnomad_v4 .types .initial_globals import Globals
11
10
from data_pipeline .datasets .gnomad_v4 .types .initial_variant import InitialVariant
12
11
from data_pipeline .datasets .gnomad_v4 .types .prepare_variants_step1 import Variant as Step1Variant
13
12
from data_pipeline .datasets .gnomad_v4 .types .prepare_variants_step2 import Variant as Step2Variant
14
13
from data_pipeline .datasets .gnomad_v4 .types .prepare_variants_step3 import Variant as Step3Variant
15
14
16
- step1_task = gnomad_v4_variant_pipeline .get_task ("prepare_gnomad_v4_exome_variants" )
17
-
18
15
19
16
def ht_to_json (ht : hl .Table , field : str = "row" ):
20
17
if field == "row" :
@@ -32,45 +29,43 @@ def ht_to_json(ht: hl.Table, field: str = "row"):
32
29
return objs
33
30
34
31
35
- @pytest .mark .mock_data
36
- def test_globals_input_validation ():
37
- input_path = gnomad_v4_variant_pipeline .get_task ("prepare_gnomad_v4_exome_variants" ).get_inputs ()["input_path" ]
32
+ def validate_globals_input (pipeline : Pipeline ):
33
+ input_path = pipeline .get_task ("prepare_gnomad_v4_exome_variants" ).get_inputs ()["input_path" ]
38
34
ht = hl .read_table (input_path )
39
35
result = ht_to_json (ht , "globals" )[0 ]
40
36
# logger.info(result)
41
37
structure (result , Globals )
38
+ logger .info ("Validated prepare_gnomad_v4_exome_variants input globals" )
42
39
43
40
44
- @pytest .mark .mock_data
45
- def test_validate_variant_input ():
46
- input_path = gnomad_v4_variant_pipeline .get_task ("prepare_gnomad_v4_exome_variants" ).get_inputs ()["input_path" ]
41
+ def validate_variant_input (pipeline : Pipeline ):
42
+ input_path = pipeline .get_task ("prepare_gnomad_v4_exome_variants" ).get_inputs ()["input_path" ]
47
43
ht = hl .read_table (input_path )
48
44
result = ht_to_json (ht )
49
45
[structure_attrs_fromdict (variant , InitialVariant ) for variant in result ]
46
+ logger .info ("Validated prepare_gnomad_v4_exome_variants input variants" )
50
47
51
48
52
- @pytest .mark .mock_data
53
- def test_validate_step1_output ():
54
- output_path = gnomad_v4_variant_pipeline .get_task ("prepare_gnomad_v4_exome_variants" ).get_output_path ()
49
+ def validate_step1_output (pipeline : Pipeline ):
50
+ output_path = pipeline .get_task ("prepare_gnomad_v4_exome_variants" ).get_output_path ()
55
51
ht = hl .read_table (output_path )
56
52
# ht = ht.sample(0.1, seed=1234)
57
53
result = ht_to_json (ht )
58
54
[structure_attrs_fromdict (variant , Step1Variant ) for variant in result ]
55
+ logger .info ("Validated prepare_gnomad_v4_exome_variants (step 1) output" )
59
56
60
57
61
- @pytest .mark .mock_data
62
- def test_validate_step2_output ():
63
- output_path = gnomad_v4_variant_pipeline .get_task ("annotate_gnomad_v4_exome_variants" ).get_output_path ()
58
+ def validate_step2_output (pipeline : Pipeline ):
59
+ output_path = pipeline .get_task ("annotate_gnomad_v4_exome_variants" ).get_output_path ()
64
60
ht = hl .read_table (output_path )
65
61
result = ht_to_json (ht )
66
62
[structure_attrs_fromdict (variant , Step2Variant ) for variant in result ]
63
+ logger .info ("Validated annotate_gnomad_v4_exome_variants (step 2) output" )
67
64
68
65
69
- @pytest .mark .mock_data
70
- def test_validate_step3_output ():
71
- output_path = gnomad_v4_variant_pipeline .get_task (
72
- "annotate_gnomad_v4_exome_transcript_consequences"
73
- ).get_output_path ()
66
+ def validate_step3_output (pipeline : Pipeline ):
67
+ output_path = pipeline .get_task ("annotate_gnomad_v4_exome_transcript_consequences" ).get_output_path ()
74
68
ht = hl .read_table (output_path )
75
69
result = ht_to_json (ht )
76
70
[structure_attrs_fromdict (variant , Step3Variant ) for variant in result ]
71
+ logger .info ("Validated annotate_gnomad_v4_exome_transcript_consequences (step 3) output" )
0 commit comments