-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathtest_igv.py
174 lines (145 loc) · 5.57 KB
/
test_igv.py
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import requests
import dash
import dash_bio
import dash_html_components as html
from common_features import simple_app_layout
from selenium.webdriver.support.ui import WebDriverWait
_COMPONENT_ID = 'myigv'
igvStyle = dict(
paddingTop='10px',
paddingBottom='10px',
margin='8px',
border='1px solid lightgray'
)
def test_dbigv001_ASM985889v3(dash_duo):
app = dash.Dash(__name__)
try:
requests.get('https://www.google.com/').status_code
data_path = 'https://s3.amazonaws.com/igv.org.genomes/'
except requests.exceptions.ConnectionError:
print("Running test with local datasets")
data_path = app.get_asset_url('')
app.layout = html.Div(simple_app_layout(
dash_bio.Igv(
id=_COMPONENT_ID,
reference={
"id": "ASM985889v3",
"name": "Sars-CoV-2 (ASM985889v3)",
"fastaURL": data_path + "covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.fna",
"indexURL": data_path +
"covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.fna.fai",
"order": 1000000,
"tracks": [
{
"name": "Annotations",
"url": data_path +
"covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.gff.gz",
"displayMode": "EXPANDED",
"nameField": "gene",
"height": 150
}
]
},
minimumBases=100,
style=igvStyle
),
))
dash_duo.start_server(app)
# Check that the genome loaded
dash_duo.wait_for_text_to_equal('.igv-current-genome', 'ASM985889v3')
# Check that track(s) loaded
tracks = dash_duo.find_elements('.igv-track-label')
assert len(tracks) == 1
assert tracks[0].text == 'Annotations'
def test_dbigv002_ASM985889v3_tracks(dash_duo):
app = dash.Dash(__name__)
try:
requests.get('https://www.google.com/').status_code
data_path = 'https://s3.amazonaws.com/igv.org.genomes/'
except requests.exceptions.ConnectionError:
print("Running test with local datasets")
data_path = app.get_asset_url('')
app.layout = html.Div(simple_app_layout(
dash_bio.Igv(
id=_COMPONENT_ID,
reference={
"id": "ASM985889v3",
"name": "Sars-CoV-2 (ASM985889v3)",
"fastaURL": data_path + "covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.fna",
"indexURL": data_path +
"covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.fna.fai",
"order": 1000000,
"tracks": [
{
"name": "Annotations",
"url": data_path +
"covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.gff.gz",
"displayMode": "EXPANDED",
"nameField": "gene",
"height": 150
}
]
},
tracks=[
{ # normally, tracks listed here would not duplicate those already present above
"name": "Genes",
"type": "annotation",
"url": data_path +
"covid_ASM985889v3/GCF_009858895.2_ASM985889v3_genomic.gff.gz",
"displayMode": "EXPANDED"
}],
minimumBases=100,
style=igvStyle
),
))
dash_duo.start_server(app)
# Check that the genome loaded
dash_duo.wait_for_text_to_equal('.igv-current-genome', 'ASM985889v3')
WebDriverWait(dash_duo.driver, 5).until(
lambda _:
len(dash_duo.find_elements('.igv-track-label')) >= 2,
"Can't find second track"
)
# Check that track(s) loaded
tracks = dash_duo.find_elements('.igv-track-label')
assert tracks[0].text == 'Annotations'
dash_duo.percy_snapshot('test-igv_tracks', convert_canvases=True)
def test_dbigv003_sacCer3(dash_duo):
app = dash.Dash(__name__)
try:
requests.get('https://www.google.com/').status_code
data_path = 'https://s3.dualstack.us-east-1.amazonaws.com/igv.org.genomes/'
except requests.exceptions.ConnectionError:
print("Running test with local datasets")
data_path = app.get_asset_url('')
app.layout = html.Div(simple_app_layout(
dash_bio.Igv(
id=_COMPONENT_ID,
reference={
"id": "sacCer3",
"name": "S. cerevisiae (sacCer3)",
"fastaURL": data_path + "sacCer3/sacCer3.fa",
"indexURL": data_path + "sacCer3/sacCer3.fa.fai",
"tracks": [
{
"name": "Ensembl Genes",
"type": "annotation",
"format": "ensgene",
"displayMode": "EXPANDED",
"url": data_path + "sacCer3/ensGene.txt.gz",
"indexed": False,
"supportsWholeGenome": False
}
]
},
minimumBases=100,
style=igvStyle
),
))
dash_duo.start_server(app)
# Check that the genome loaded
dash_duo.wait_for_text_to_equal('.igv-current-genome', 'sacCer3')
# Check that track(s) loaded
tracks = dash_duo.find_elements('.igv-track-label')
assert len(tracks) == 1
assert tracks[0].text == 'Ensembl Genes'