-
Notifications
You must be signed in to change notification settings - Fork 199
/
volvox_biodb_test.py
146 lines (105 loc) · 5.25 KB
/
volvox_biodb_test.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
import time
import subprocess
from subprocess import check_call as call, PIPE;
import unittest
from jbrowse_selenium import JBrowseTest;
class AbstractVolvoxBiodbTest( JBrowseTest ):
data_dir = 'sample_data/json/volvox'
def setUp( self ):
call( "rm -rf sample_data/json/volvox/", shell=True )
call( "bin/prepare-refseqs.pl --fasta docs/tutorial/data_files/volvox.fa --out sample_data/json/volvox/", shell=True )
call( "bin/biodb-to-json.pl --conf docs/tutorial/conf_files/volvox.json --out sample_data/json/volvox/", shell=True )
call( "bin/wig-to-json.pl --out sample_data/json/volvox/ --wig docs/tutorial/data_files/volvox_microarray.wig", shell=True )
call( "bin/add-track-json.pl sample_data/raw/volvox/volvox_microarray.bw.conf sample_data/json/volvox/trackList.json", shell=True )
call( "bin/generate-names.pl --dir sample_data/json/volvox/", shell=True )
super( AbstractVolvoxBiodbTest, self ).setUp()
def test_volvox( self ):
# select "ctgA from the dropdown
self.select_refseq( 'ctgA' )
# check a good browser title
assert "ctgA" in self.browser.title, "browser title is actually %s" % self.browser.title
# do a test where we search for a certain gene using the search box
self.search_f15()
self.assert_no_js_errors()
# test scrolling, make sure we get no js errors
self.scroll()
# test context menus
self.context_menus()
# test dragging in and displaying the wiggle track
self.wiggle()
# test sequence track display
self.sequence()
# test that the frame usage track claims to have links to NCBI
self.turn_on_track( 'Frame usage' )
self.do_typed_query('ctgA:2,381..21,220')
self.assert_element("//div[@title='search at NCBI']")
# test bigwig
self.bigwig();
self.browser.close()
def bigwig( self ):
self.turn_on_track('volvox_microarray.bw')
self.assert_elements("//div[@id='track_volvox_microarray.bw']//canvas")
self.assert_no_js_errors()
def sequence( self ):
self.do_typed_query( '0..80' );
time.sleep(0.2);
sequence_div_xpath_templ = "/html//div[contains(@class,'sequence')][contains(.,'%s')]"
sequence_div_xpath_1 = sequence_div_xpath_templ % 'aacaACGG';
self.assert_element( sequence_div_xpath_1)
self.turn_off_track( 'DNA' );
self.assert_no_element( sequence_div_xpath_1 )
self.turn_on_track( 'DNA' );
self.assert_element( sequence_div_xpath_1 )
self.do_typed_query( '1..20000');
self.assert_no_element( sequence_div_xpath_1 )
self.do_typed_query( 'ctgA:19961..20047');
self.assert_element( sequence_div_xpath_templ % 'ccgcgtgtagtc' )
def context_menus( self ):
self.turn_on_track( 'Example alignments' )
self.do_typed_query( '20147..35574' );
# check that there is no dialog open
self.assert_no_element("//div[@class='dijitDialogTitleBar'][contains(@title,'snippet')]");
# get the example alignments features
feature_elements = self.assert_elements("//div[@id='track_Alignments']//div[contains(@class,'plus-feature4')]")
# right-click one of them
self.actionchains() \
.context_click(feature_elements[20]) \
.move_by_offset( 20, 55 ) \
.click() \
.perform()
# wait for the dialog to finish fading in
time.sleep(0.5)
# check that the proper HTML snippet popped up in the dialog
self.assert_element("//div[contains(@class,'dijitDialog')]//span[@class='amazingTestSnippet']")
# close the dialog
dialog_close = self.assert_element("//div[@class='dijitDialogTitleBar'][contains(@title,'Random XHR')]/span[contains(@class,'dijitDialogCloseIcon')]")
dialog_close.click()
time.sleep(0.5) # wait for it to finish fading out
# check that the dialog closed
self.assert_no_element("//div[@class='dijitDialogTitleBar'][contains(@title,'Random XHR')]");
def wiggle( self ):
self.turn_on_track( 'microarray' )
# see that we have an image track png in the DOM now
imagetrack_xpath = "//div[contains(@class,'track')]//img[@class='image-track']";
imagetrack_png = self.assert_element( imagetrack_xpath )
self.turn_off_track( 'microarray' )
# check that imagetrack png is not still in the DOM after the
# track is turned off
self.assert_no_element( imagetrack_xpath )
def search_f15( self ):
# check that a f15 feature label is not yet in the DOM
xpath = "//div[@class='feature-label'][contains(.,'f15')]"
# check that f15 is not already in the DOM at load time
self.assert_no_element( xpath )
self.do_typed_query( "f15" );
time.sleep(0.2);
# test that f15 appeared in the DOM (TODO: check that it's
# actually centered in the window), and that the protein-coding
# genes track is now selected
label = self.assert_element( xpath )
assert label.text == 'f15';
class VolvoxBiodbTest( AbstractVolvoxBiodbTest, unittest.TestCase ):
pass
if __name__ == '__main__':
import unittest
unittest.main()