/
test_multilocus.rb
407 lines (313 loc) · 15.8 KB
/
test_multilocus.rb
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# coding: utf-8
load 'vidjil_browser.rb'
load 'browser_test.rb'
#browser test suite
class TestMultilocus < BrowserTest
def setup
super
if not defined? $b
set_browser("/doc/analysis-example.vidjil")
if $b.div(id: 'tip-container').present?
$b.div(:id => 'tip-container').div(:class => 'tip_1').element(:class => 'icon-cancel').click
end
end
end
def after_tests
end
def test_00_info_segmentation
assert ($b.div(:id => 'info_segmented').text.include? '742 377 (94.35%)'), ' Incorrect number of segmented reads'
end
def test_00_info_reads
assert ($b.div(:id => 'info_segmented').title.include? '786 861'), 'Incorrect number of reads'
end
def test_00_default_point_name
assert ($b.div(:id => 'info_point').text.include? 'helloworld'), 'Incorrect point name in info box'
end
def test_00_germline
assert ($b.div(:id => 'info').span(:class => 'systemBoxNameMenu', :index => 0).text.include? 'TRA'), 'missing system TRA'
end
def test_00_legend_scatterplot
assert ($b.scatterplot_x_legend(0).text == 'TRBV1'), "Bad legend for scatterplot"
assert ($b.scatterplot_x_legend(4).text == '?'), "Bad legend for scatterplot"
assert ($b.scatterplot_y_legend(0).text == 'TRBJ1-1'), "Bad legend for scatterplot"
assert ($b.scatterplot_y_legend(9).text == '?'), "Bad legend for scatterplot"
end
def test_00_info_point
assert (not $b.div(:id => 'info_timepoint').present?), "Info timepoint should not be present"
$b.info_point.i.click
assert ($b.div(:id => 'info_timepoint').present?), "After clicking info timepoint should be visible"
table = $b.div(:id => 'info_timepoint').table
assert (table[1][1].text == '786861'), "Incorrect number of reads in infopoint"
assert (table[2][1].text.include? '742377'), "Incorrect number of reads in infopoint"
$b.div(:class => 'data-container').span(:class => 'closeButton').click
assert (not $b.div(:id => 'info_timepoint').present?), "Info timepoint should not be present"
end
def test_01_init
assert ( $b.clone_in_list('25').exists?), ">>fail init : clone 0 missing in list"
assert ( $b.clone_in_scatterplot('25').exists?), ">>fail init : clone 0 missing in scatterplot"
#assert ( $b.clone_in_graph('25').exists?), ">>fail init : clone 0 missing in graph"
assert ( $b.clone_in_list('25').text.include? '0.129%' ) , ">>fail init : wrong clone size "
end
def test_02_fold_left_menu
assert ($b.div(:id => "left-container").present?), ">> fail : left menu should be visible"
$b.div(:id => "vertical-separator").click
assert (not $b.div(:id => "left-container").present?), ">> fail : left menu is still visible"
$b.div(:id => "vertical-separator").click
assert ($b.div(:id => "left-container").present?), ">> fail : left menu did not reappear"
end
def test_02_export_align_sequences
assert ( $b.menu_item_export_fasta_align(:class => 'disabledClass').exists?), ">> export align sequences is disable by default"
end
def test_03_rename_clone_by_clicking
clone_name = $b.clone_info('25')[:name]
assert (clone_name.title == 'TRBV29*01 -1/0/-0 TRBD1*01 -2/0/-5 TRBJ2-5*01'), " >> clone name is not correct : " + clone_name.title
assert (clone_name.text == 'TRBV29 1//0 D1 2//5 J2-5'), " >> clone short name is not correct : " + clone_name.text
clone_name.double_click
$b.clone_name_editor.set 'renamed_click'
$b.clone_name_saver.click
assert (clone_name.text == 'renamed_click'), " >> clone name (click) has not changed"
$b.unselect
end
def test_04_rename_clone_by_enter
sleep 1
clone_name = $b.clone_info('24')[:name]
clone_name.double_click
$b.clone_name_editor.set 'renamed_return'
$b.send_keys :return
assert (clone_name.text == 'renamed_return'), " >> clone name (return) has not changed"
$b.unselect
end
def check_when_list_or_scatterplot_focused
assert ( $b.clone_in_scatterplot('25', :class => 'circle_focus').exists?), ">> fail to focus correct plot after hovering a clone in the list"
assert ( $b.clone_in_graph('25', :class => "graph_focus").exists?), ">> fail to focus correct graphLine after hovering a clone in the list"
clone_name = $b.clone_info('25')[:name]
assert ( $b.infoline.inner_html == clone_name.title), ">> Clone name is not correct in focus div"
end
def test_05_focus_in_list
begin
$b.unselect
#test hover a clone in the list
$b.clone_in_scatterplot('25').wait_until(&:present?)
$b.clone_in_list('25').hover
check_when_list_or_scatterplot_focused
end
end
def test_05_focus_in_scatterplot
begin
$b.unselect
$b.clone_in_scatterplot('25').wait_until(&:present?)
$b.clone_in_scatterplot('25').hover
check_when_list_or_scatterplot_focused
end
end
def check_when_list_or_scatterplot_clicked
clone_name = $b.clone_info('25')[:name]
assert ( $b.infoline.inner_html == clone_name.title), ">> Clone name is not correct in focus div"
assert ( $b.clone_in_list('25').class_name.include? "list_select" ), ">> Incorrect class name, clone is not selected"
assert ( $b.clone_in_scatterplot('25', :class => "circle_select").exists?)
assert ( $b.clone_in_graph('25', :class=> "graph_select").exists?)
assert ( $b.clone_in_segmenter('25').exists? ), ">> fail to add clone to segmenter by clicking on the list or scatterplot"
stats = $b.statsline
assert (stats.text.include? '1 clone'), ">> Incorrect stats, should have one clone"
assert (stats.text.include? '962 reads'), ">> Incorrect stats, should have 962 reads"
assert (stats.text.include? '0.129%'), ">> Incorrect stats, should be at 0.129%"
end
def test_08_click_in_list
#test select a clone in the list
$b.clone_in_scatterplot('25').wait_until(&:present?)
$b.clone_info('25')[:name].click()
check_when_list_or_scatterplot_clicked
$b.unselect
assert (not $b.clone_in_list('25').class_name.include? "list_select"), ">> Incorrect class name, clone is not unselected'"
end
def test_08_click_in_scatterplot
$b.clone_in_scatterplot('25').wait_until(&:present?)
$b.clone_in_scatterplot('25').click
check_when_list_or_scatterplot_clicked
$b.unselect
assert (not $b.clone_in_list('25').class_name.include? "list_select"), ">> Incorrect class name, clone is not unselected'"
end
def test_09_normalize
$b.clone_info('25')[:star].click
$b.tag_selector_edit_normalisation.wait_until(&:present?)
$b.tag_selector_edit_normalisation.set('0.01')
$b.tag_selector_normalisation_validator.click
assert ( $b.clone_info('25')[:size].text == '1.000%' ) , ">> fail normalize on : wrong clone size "
$b.menu_settings.click
$b.radio(:id => 'reset_norm').click
assert ( $b.clone_info('25')[:size].text == '0.129%' ) , ">> fail normalize off : wrong clone size "
$b.unselect
end
def test_0a_shortcuts_numpad
$b.clone_in_scatterplot('25').wait_until(&:present?)
$b.clone_in_scatterplot('25').click
assert ($b.preset_selector.selected? "[0] V/J (genes)"), ">> preset selector badly set"
$b.send_keys :numpad2
assert ($b.preset_selector.selected? "[2] V/N length"), ">> preset selector not properly changed"
end
def test_12_tag
begin
$b.clone_info('25')[:star].click
name = $b.tag_item('0')[:name]
name.wait_until(&:present?)
name.click
name.wait_while(&:present?)
$b.until {$b.clone_info('25')[:name].style('color') == 'rgba(220, 50, 47, 1)' }
end
end
def test_13_export_fasta
$b.clone_in_scatterplot('77').click
$b.clone_in_scatterplot('25').click(:control)
$b.clone_in_scatterplot('88').click(:control)
$b.clone_in_scatterplot('90').click(:control)
$b.menu_item_export_fasta.click
assert ( $b.window(:url => /about:blank/ )) , ">> fail opening fasta export "
$b.window(:url => /about:blank/).use do
assert ($b.text.include? ">TRBV29*01 -1/0/-0 TRBD1*01 -2/0/-5 TRBJ2-5*01"), "header name: "+$b.text
assert ($b.text.include? "YYGGGYYACGYAYAGCGGYGYTTYYCCTYTYTGYTYTGCYAAAYAACYYYYTGTGYCTYTGTGCYGYGTTYCCCGGYYYAAACYCYCYYCCTYGG\nCYAGGYCYGG"), "sequence"
assert ($b.text.include? ">ERG-4F 0/TCT/0 ERG-Seq-R"), "header name locus ERG"
assert (not $b.text.include? ">ERG-4F\n"), "header name of segment should not exist (segment is not present in germline)"
end
end
def test_14_export_sample_report
if $b.driver.capabilities.browser_name == 'chrome'
skip "Issue #3699 must be solved first"
end
assert ($b.scatterplot_x_legend(0).text.include? 'TRB'), "Current system should be TRB"
# Select a clone
$b.clone_in_scatterplot('43').click
$b.menu_item_export('export_sample_report').click
assert ($b.window(:title => "analysis-example.vidjil – helloworld").exists?), ">> Report didn't show up"
$b.window(:title => "analysis-example.vidjil – helloworld").use do
# Check that all loci are there
assert ($b.element(:id => 'segmentation-report').text.include? "TRA"), "TRA should be present"
assert ($b.element(:id => 'segmentation-report').text.include? "TRB"), "TRB should be present"
assert ($b.element(:id => 'segmentation-report').text.include? "TRD"), "TRD should be present"
assert ($b.element(:id => 'segmentation-report').text.include? "IGH"), "IGH should be present"
assert (not $b.element(:id => 'segmentation-report').text.include? "TRG"), "TRG should not be present"
assert (not $b.element(:id => 'segmentation-report').text.include? "IGH+"), "IGH+ should not be present"
assert ($b.element(:class => 'clone_name').text.include? "TRBV13-1*02 -0/1/-0 TRBD1*01 -6/0/-0 TRBJ1-3*01"), "segmentation should be the one provided in the .vidjil file"
n_gene = $b.element(:class => 'n_gene', :index => 0)
# This is true with a 0-based index, which is the case for the vidjil
# JSON version used
assert (n_gene.text == 'A'), ("N1 should be A, it is '" + n_gene.text + "'")
n_gene = $b.element(:class => 'n_gene', :index => 1)
assert (n_gene.text == ''), ("N2 should be empty, it is '" + n_gene.text + "'")
assert($b.element(:class => 'j_gene').text == 'YYGYYTYYAATGTYCYYCCYAG')
assert($b.element(:class => 'v_gene').text == 'YTYTYAYTGGTGCTGGYACCTYAAAYGYYTGYCCTYTGGGYYAGGCYCYYAYACGYAYAYCTYTYCYCTGCTGYATTGGCTYYCCYYAYYYTTTGYCTYTGTGCYGYGTYTGCGGYYTYTGYAAYCGCYYTTTTGYYAGYAGCCGGCY')
end
$b.window(:title => "analysis-example.vidjil – helloworld").close
$b.window(:title => "analysis-example").use
assert ($b.scatterplot_x_legend(0).text.include? 'TRB'), "Current system should not have changed"
assert (not $b.element(:class => 'waiting_msg').present?), "The ``generating report'' message should not be present anymore"
end
def test_15_smaller_clones
for i in 0..3
smaller = $b.list.li(:index => i)
assert (smaller.text.include?("smaller clones")), "We should have smaller clones at index %d of the list, instead we have %s " % [i, smaller.text]
assert (smaller.present?), "Smaller clones #%d should be visible, it is not" % [i]
smaller.hover
assert (smaller.present?), "Smaller clones #%d should still be visible after hovering it" % [i]
assert (not $b.clone_in_scatterplot(smaller.id).present?), "Smaller clone %d should not be visible in scatterplot" % [i]
end
end
def test_16_select_unsegmented
clone_id = '10'
$b.clone_in_scatterplot(clone_id).click
assert ($b.clone_in_segmenter(clone_id).exists?), "Clone %s is not in segmenter" % clone_id
end
def test_17_select_clustered
$b.clone_in_scatterplot('1').click
$b.clone_in_scatterplot('37').click(:control)
$b.clone_in_scatterplot('90').click(:control)
$b.merge.click
assert ($b.clone_in_scatterplot('90').exists?), "Main clone of the cluster should be clone 90"
assert ($b.clone_in_scatterplot('90', :class => "circle_select").exists?), "Clone should be selected"
$b.clone_info('90')[:cluster].click
$b.until { $b.clone_in_scatterplot('1', :class => "circle_select").exists?}
assert ( $b.clone_in_graph('1', :class=> "graph_select").exists?)
assert ( $b.clone_in_segmenter('1').exists? ), ">> fail to add clone to segmenter by clicking on the list or scatterplot"
assert ( $b.clone_in_scatterplot('37', :class => "circle_select").exists?)
assert ( $b.clone_in_graph('37', :class=> "graph_select").exists?)
assert ( $b.clone_in_segmenter('37').exists? ), ">> fail to add clone to segmenter by clicking on the list or scatterplot"
assert ( $b.clone_in_scatterplot('90', :class => "circle_select").exists?)
assert ( $b.clone_in_graph('90', :class=> "graph_select").exists?)
assert ( $b.clone_in_segmenter('90').exists? ), ">> fail to add clone to segmenter by clicking on the list or scatterplot"
$b.clone_in_cluster('90', '1')[:delete].click
$b.clone_in_cluster('90', '37')[:delete].click
$b.unselect
assert ($b.clone_in_scatterplot('1').exists?)
assert ($b.clone_in_scatterplot('37').exists?)
assert ($b.clone_in_scatterplot('90').exists?)
end
def test_18_empty_clone_invisible
assert ( $b.execute_script("return m.clones[66].reads[0]") == 0), "Clone should have no read"
assert (not $b.clone_in_scatterplot('66').present?), "Clone should not be visible"
end
def TODO_test_14_edit_tag
begin
## rename Tag 0
$b.clone_info('25')[:star].click
edit = $b.tag_item('0')[:edit]
edit.wait_until(&:present?)
edit.click
$b.tag_selector_edit_name.set 'renamed_click'
$b.tag_selector_name_validator.click
$b.tag_selector_close.click
$b.tag_selector.wait_while_present
## rename Tag 1 (on another clone)
$b.clone_info('24')[:star].click
edit = $b.tag_item('1')[:edit]
edit.wait_until(&:present?)
edit.click
$b.tag_selector_edit_name.set 'renamed_return'
$b.send_keys :return
$b.tag_selector_close.click
$b.tag_selector.wait_while_present
## check renames (on again another clone)
$b.clone_info('23')[:star].click
edit = $b.tag_item('1')[:edit]
edit.wait_until(&:present?)
assert ($b.tag_selector.text.include? 'renamed_click'), "fail edit tag with mouse : tag name in tag selector hasn't changed"
assert ($b.tag_selector.text.include? 'renamed_return'), "fail edit tag with keyboard : tag name in tag selector hasn't changed"
$b.tag_selector_close.click
$b.tag_selector.wait_while_present
end
end
def test_19_edit_tag
begin
$b.clone_in_scatterplot('77').click
$b.clone_in_scatterplot('25').click(:control)
$b.clone_in_scatterplot('88').click(:control)
$b.clone_in_scatterplot('90').click(:control)
## Test tag selection for one clone
$b.clone_info('25')[:star].click
$b.element(:id => 'tagElem_0').click
$b.until {$b.clone_info('25')[:name].style('color') == 'rgba(220, 50, 47, 1)' } # clone 25 should have changed color
assert ( not $b.clone_info('88')[:name].style('color') == 'rgba(220, 50, 47, 1)' ) , "clone 88 (second of the selection) haven't chaged color "
## Test tag selection for multiple clone
$b.element(:id => "tag_icon__multiple").click
$b.element(:id => 'tagElem_6').click
assert ($b.clone_info('25')[:name].style('color') == 'rgba(211, 54, 130, 1)' ) , "clone 25 have also changed color"
assert ($b.clone_info('77')[:name].style('color') == 'rgba(211, 54, 130, 1)' ) , "clone 77 have also changed color"
assert ($b.clone_info('88')[:name].style('color') == 'rgba(211, 54, 130, 1)' ) , "clone 88 have also changed color"
end
end
# Not really a test
def test_zz_close
close_everything
end
end
=begin
TODO
save_analysis
clipboard
edit tag
change axis scatterplot
edit name
change color method
change color palette
change scatterplot/graph size
check x/y clone position on scatterplot
check clone path
=end