-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_viewers.py
More file actions
110 lines (89 loc) · 2.71 KB
/
test_viewers.py
File metadata and controls
110 lines (89 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import io
import os
import hpotk
import pytest
from gpsea.analysis.pcats import HpoTermAnalysisResult
from gpsea.model import Cohort, ProteinMetadata
from gpsea.view import (
CohortViewer,
CohortVariantViewer,
GpseaReport,
MtcStatsViewer,
)
from gpsea.view._viewers import ProteinVariantViewer
@pytest.mark.skip("Just for manual testing and debugging")
class TestCohortViewer:
@pytest.fixture
def cohort_viewer(
self,
hpo: hpotk.MinimalOntology,
) -> CohortViewer:
return CohortViewer(
hpo=hpo,
)
def test_process_suox_cohort(
self,
cohort_viewer: CohortViewer,
suox_cohort: Cohort,
suox_mane_tx_id: str,
):
report = cohort_viewer.process(
cohort=suox_cohort,
transcript_id=suox_mane_tx_id,
)
with open(os.path.join("dev", "SUOX.cohort.html"), "w") as fh:
report.write(fh)
def test_process_cyp21a2_cohort(
self,
cohort_viewer: CohortViewer,
cyp21a2_cohort: Cohort,
cyp21a2_mane_tx_id: str,
):
report = cohort_viewer.process(
cohort=cyp21a2_cohort,
transcript_id=cyp21a2_mane_tx_id,
)
with open(os.path.join("dev", "CYP21A2.cohort.html"), "w") as fh:
report.write(fh)
@pytest.mark.skip("Just for manual testing and debugging")
def test_viewer(
suox_mane_tx_id: str,
suox_cohort: Cohort,
):
viewer = CohortVariantViewer(tx_id=suox_mane_tx_id)
html = viewer.process(suox_cohort)
with open("all_variants.html", "w") as fh:
html.write(fh)
class TestMtcStatsViewer:
@pytest.fixture
def stats_viewer(self) -> MtcStatsViewer:
return MtcStatsViewer()
@pytest.mark.skip("Just for manual testing and debugging")
def test_process(
self,
stats_viewer: MtcStatsViewer,
hpo_term_analysis_result: HpoTermAnalysisResult,
):
report = stats_viewer.process(result=hpo_term_analysis_result)
with open("mtc_stats.html", "w") as fh:
report.write(fh)
class TestProteinVariantViewer:
@pytest.fixture(scope="class")
def protein_variant_viewer(
self,
suox_protein_metadata: ProteinMetadata,
) -> ProteinVariantViewer:
return ProteinVariantViewer(
protein_metadata=suox_protein_metadata,
)
def test_process(
self,
suox_cohort: Cohort,
protein_variant_viewer: ProteinVariantViewer,
):
report = protein_variant_viewer.process(suox_cohort)
assert isinstance(report, GpseaReport)
buf = io.StringIO()
report.write(buf)
val = buf.getvalue()
assert "gpsea-body" in val