sequenceserver 2.0.0.beta3 → 2.0.0.beta4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/.eslintrc.json +36 -0
  3. data/.rubocop.yml +1 -1
  4. data/.travis.yml +53 -20
  5. data/AppImage/recipe.yml +15 -0
  6. data/AppImage/sequenceserver.desktop +8 -0
  7. data/AppImage/sequenceserver.png +0 -0
  8. data/AppImage/sequenceserver.sh +11 -0
  9. data/README.md +79 -46
  10. data/bin/sequenceserver +4 -4
  11. data/lib/sequenceserver/version.rb +1 -1
  12. data/package.json +2 -0
  13. data/public/css/grapher.css +3 -0
  14. data/public/css/sequenceserver.css +17 -6
  15. data/public/css/sequenceserver.min.css +3 -3
  16. data/public/js/circos.js +515 -491
  17. data/public/js/grapher.js +12 -6
  18. data/public/js/hits_overview.js +321 -308
  19. data/public/js/hsp.js +12 -7
  20. data/public/js/length_distribution.js +241 -234
  21. data/public/js/report.js +196 -174
  22. data/public/js/search.js +3 -3
  23. data/public/js/sequenceserver.js +9 -9
  24. data/public/js/utils.js +17 -10
  25. data/public/js/visualisation_helpers.js +77 -77
  26. data/public/sequenceserver-report.min.js +17 -17
  27. data/public/sequenceserver-search.min.js +1 -1
  28. data/public/vendor/github/nicgirault/circosJs@1.7.0/dist/circosJS.js +1 -5
  29. data/sequenceserver.gemspec +1 -2
  30. data/spec/blast_versions/blast_2.2.30/blast_2.2.30_spec.rb +13 -13
  31. data/spec/blast_versions/blast_2.2.30/import_spec_capybara_local_2.2.30.rb +555 -25
  32. data/spec/blast_versions/blast_2.2.31/blast_2.2.31_spec.rb +13 -13
  33. data/spec/blast_versions/blast_2.2.31/import_spec_capybara_local_2.2.31.rb +558 -24
  34. data/spec/blast_versions/blast_2.3.0/blast_2.3.0_spec.rb +13 -13
  35. data/spec/blast_versions/blast_2.3.0/import_spec_capybara_local_2.3.0.rb +561 -26
  36. data/spec/blast_versions/blast_2.4.0/blast_2.4.0_spec.rb +13 -13
  37. data/spec/blast_versions/blast_2.4.0/import_spec_capybara_local_2.4.0.rb +561 -25
  38. data/spec/blast_versions/blast_2.5.0/blast_2.5.0_spec.rb +13 -13
  39. data/spec/blast_versions/blast_2.5.0/import_spec_capybara_local_2.5.0.rb +558 -24
  40. data/spec/blast_versions/blast_2.6.0/blast_2.6.0_spec.rb +13 -13
  41. data/spec/blast_versions/blast_2.6.0/import_spec_capybara_local_2.6.0.rb +559 -24
  42. data/spec/blast_versions/blast_2.7.1/blast_2.7.1_spec.rb +13 -13
  43. data/spec/blast_versions/blast_2.7.1/import_spec_capybara_local_2.7.1.rb +559 -28
  44. data/spec/blast_versions/blast_2.8.1/blast_2.8.1_spec.rb +13 -13
  45. data/spec/blast_versions/blast_2.8.1/import_spec_capybara_local_2.8.1.rb +559 -27
  46. data/spec/blast_versions/blast_2.9.0/blast_2.9.0_spec.rb +13 -13
  47. data/spec/blast_versions/blast_2.9.0/import_spec_capybara_local_2.9.0.rb +557 -25
  48. data/spec/blast_versions/diamond_0.9.24/diamond_0.9.24_spec.rb +13 -13
  49. data/spec/blast_versions/diamond_0.9.24/import_spec_capybara_local_0.9.24.rb +219 -21
  50. data/spec/capybara_spec.rb +25 -28
  51. data/spec/download_helper.rb +6 -3
  52. data/spec/sequences/MH011443_1_gi_1486783306_gb_MH011443_1.txt +6 -0
  53. data/spec/sequences/MH011443_1_gi_1486783307_gb_AYF55702_1.txt +6 -0
  54. data/spec/sequences/MH011443_1_gi_1528997474_gb_MH447967_1.txt +30 -0
  55. data/spec/sequences/MH011443_1_sp_P04637_P53_HUMAN.txt +6 -0
  56. data/spec/sequences/alignment-35_hits_diamond_blastp.txt +210 -0
  57. data/spec/sequences/alignment-35_hits_diamond_blastx.txt +210 -0
  58. data/spec/sequences/alignment-3_hits.txt +18 -0
  59. data/spec/sequences/alignment-40_hits_blastn.txt +246 -0
  60. data/spec/sequences/alignment-40_hits_blastp.txt +240 -0
  61. data/spec/sequences/alignment-40_hits_blastp_2.2.30.txt +240 -0
  62. data/spec/sequences/alignment-40_hits_blastx.txt +240 -0
  63. data/spec/sequences/alignment-40_hits_tblastn.txt +240 -0
  64. data/spec/sequences/alignment-40_hits_tblastn_2.2.30.txt +240 -0
  65. data/spec/sequences/alignment-40_hits_tblastx.txt +2664 -0
  66. data/spec/sequences/alignment-4_hits.txt +24 -0
  67. data/spec/sequences/alignment-4_hits_blastn.txt +24 -0
  68. data/spec/sequences/alignment-4_hits_blastp.txt +24 -0
  69. data/spec/sequences/alignment-4_hits_blastp_2.2.30.txt +24 -0
  70. data/spec/sequences/alignment-4_hits_blastx.txt +24 -0
  71. data/spec/sequences/alignment-4_hits_diamond_blastp.txt +24 -0
  72. data/spec/sequences/alignment-4_hits_diamond_blastx.txt +24 -0
  73. data/spec/sequences/alignment-4_hits_tblastn.txt +24 -0
  74. data/spec/sequences/alignment-4_hits_tblastn_2.2.30.txt +24 -0
  75. data/spec/sequences/alignment-4_hits_tblastx.txt +318 -0
  76. data/spec/sequences/sp_P04637_P53_HUMAN_gi_1099170394_ref_XP_018868681_1.txt +6 -0
  77. data/spec/sequences/sp_P04637_P53_HUMAN_gi_120407068_ref_NP_000537_3.txt +6 -0
  78. data/spec/sequences/sp_P04637_P53_HUMAN_gi_1484127324_gb_MG595988_1.txt +6 -0
  79. data/spec/sequences/sp_P04637_P53_HUMAN_gi_395440626_gb_JQ694049_1.txt +6 -0
  80. data/spec/sequences/sp_P04637_P53_HUMAN_sp_P04637_P53_HUMAN.txt +6 -0
  81. data/spec/spec_helper.rb +3 -3
  82. metadata +67 -57
  83. data/.eslintrc +0 -213
  84. data/Rakefile +0 -8
  85. data/spec/dotdir/blast_2.4.0/blastn/TBLASTN_XML_2.4.0.xml +0 -1181
  86. data/spec/dotdir/blast_2.5.0/blastn/BLASTN_LONG_XML_2.5.0.xml +0 -18813
  87. data/spec/import_spec_capybara_local.rb +0 -61
@@ -32,9 +32,9 @@ module SequenceServer
32
32
  no_hits_report = BLAST::Report.new(no_hits)
33
33
 
34
34
  it 'will return queries with valid length' do
35
- hits_report.queries.first.length.should be_a Fixnum
35
+ hits_report.queries.first.length.should be_a Integer
36
36
  hits_report.queries.first.length.should satisfy { |n| n > 0 }
37
- no_hits_report.queries.first.length.should be_a Fixnum
37
+ no_hits_report.queries.first.length.should be_a Integer
38
38
  no_hits_report.queries.first.length.should satisfy { |n| n > 0 }
39
39
  end
40
40
 
@@ -79,45 +79,45 @@ module SequenceServer
79
79
  # Test Random HSPs to ensure that all the values from HSP struct are valid.
80
80
  it 'have correct alignment values' do
81
81
  hits_report.queries.last.hits.first.hsps.last.bit_score.should be_a Float
82
- hits_report.queries.last.hits.first.hsps.last.score.should be_a Fixnum
82
+ hits_report.queries.last.hits.first.hsps.last.score.should be_a Integer
83
83
 
84
84
  hits_report.queries.first.hits.first.hsps.first.evalue.should be_a Float
85
85
  hits_report.queries.first.hits.first.hsps.first.evalue
86
86
  .should_not satisfy { |n| n < 0 }
87
87
 
88
- hits_report.queries.first.hits.last.hsps.first.qstart.should be_a Fixnum
88
+ hits_report.queries.first.hits.last.hsps.first.qstart.should be_a Integer
89
89
  hits_report.queries.first.hits.last.hsps.first.qstart
90
90
  .should_not satisfy { |n| n < 0 }
91
91
 
92
- hits_report.queries.first.hits.last.hsps.first.qend.should be_a Fixnum
92
+ hits_report.queries.first.hits.last.hsps.first.qend.should be_a Integer
93
93
  hits_report.queries.first.hits.last.hsps.first.qend
94
94
  .should_not satisfy { |n| n < 0 }
95
95
 
96
- hits_report.queries.last.hits.last.hsps.last.sstart.should be_a Fixnum
96
+ hits_report.queries.last.hits.last.hsps.last.sstart.should be_a Integer
97
97
  hits_report.queries.last.hits.last.hsps.last.sstart
98
98
  .should_not satisfy { |n| n < 0 }
99
99
 
100
- hits_report.queries.first.hits.first.hsps.last.send.should be_a Fixnum
100
+ hits_report.queries.first.hits.first.hsps.last.send.should be_a Integer
101
101
  hits_report.queries.first.hits.first.hsps.last.send
102
102
  .should_not satisfy { |n| n < 0 }
103
103
 
104
- hits_report.queries.first.hits.first.hsps.last.qframe.should be_a Fixnum
105
- hits_report.queries.first.hits.first.hsps.last.sframe.should be_a Fixnum
104
+ hits_report.queries.first.hits.first.hsps.last.qframe.should be_a Integer
105
+ hits_report.queries.first.hits.first.hsps.last.sframe.should be_a Integer
106
106
 
107
- hits_report.queries.first.hits.first.hsps.last.identity.should be_a Fixnum
107
+ hits_report.queries.first.hits.first.hsps.last.identity.should be_a Integer
108
108
  hits_report.queries.first.hits.first.hsps.last.identity
109
109
  .should_not satisfy { |n| n < 0 }
110
110
 
111
- hits_report.queries.first.hits.first.hsps.last.gaps.should be_a Fixnum
111
+ hits_report.queries.first.hits.first.hsps.last.gaps.should be_a Integer
112
112
  hits_report.queries.first.hits.first.hsps.last.gaps
113
113
  .should_not satisfy { |n| n < 0 }
114
114
 
115
115
  hits_report.queries.first.hits.first.hsps.last.positives
116
- .should be_a Fixnum
116
+ .should be_a Integer
117
117
  hits_report.queries.first.hits.first.hsps.last.positives
118
118
  .should_not satisfy { |n| n < 0 }
119
119
 
120
- hits_report.queries.first.hits.first.hsps.last.length.should be_a Fixnum
120
+ hits_report.queries.first.hits.first.hsps.last.length.should be_a Integer
121
121
  hits_report.queries.first.hits.first.hsps.last.length
122
122
  .should satisfy { |n| n > 0 }
123
123
 
@@ -1,51 +1,587 @@
1
- require 'spec_helper'
2
- require 'sauce_whisk'
3
- require 'capybara/rspec'
4
- require 'selenium-webdriver'
1
+ describe 'report generated from imported XML', type: :feature, js: true do
2
+ # Test suite to test features of imported XML report. Fasta files used for
3
+ # testing consist of TP53 and COX41 protein/nucleotide sequences for
4
+ # reproducibility. Each query was limited to 20 hits to not to overload the
5
+ # test suite.
5
6
 
6
- RSpec.configure do |config|
7
- config.include Capybara::DSL
8
- end
7
+ # BLASTP test scenarios
8
+ it 'loads BLASTP XML and tests hit alignment and sidebar Alignment download' do
9
+ access_by_uuid('blast_2.4.0/blastp')
10
+ # Click on the first hit Alignment download button on the page and wait for
11
+ # the download to finish.
12
+
13
+ page.execute_script("$('.download-aln:eq(0)').click()")
14
+ wait_for_download
15
+
16
+ expect(File.basename(downloaded_file)).to eq('sp_P04637_P53_HUMAN_gi_1099170394_ref_XP_018868681_1.txt')
17
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/sp_P04637_P53_HUMAN_gi_1099170394_ref_XP_018868681_1.txt'))
18
+
19
+ clear_downloads
20
+
21
+ # Click on the Alignment of all hits download and compare the downloaded
22
+ # content
23
+
24
+ page.click_link('Alignment of all hits')
25
+ wait_for_download
26
+
27
+ expect(File.basename(downloaded_file)).to eq('alignment-40_hits.txt')
28
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-40_hits_blastp.txt'))
29
+ clear_downloads
30
+
31
+ # Check the cheboxes of indicted hits and click on the download of Alignment
32
+ # of selected hits and compare the downloaded content
33
+
34
+ page.check('Query_1_hit_1_checkbox')
35
+ page.check('Query_1_hit_2_checkbox')
36
+ page.check('Query_2_hit_1_checkbox')
37
+ page.check('Query_2_hit_2_checkbox')
38
+ page.click_link('Alignment of 4 selected hit(s)')
39
+ wait_for_download
40
+
41
+ expect(File.basename(downloaded_file)).to eq('alignment-4_hits.txt')
42
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-4_hits_blastp.txt'))
43
+ end
44
+
45
+ it 'loads BLASTP XML and tests alignment overview and hit PNG/SVG download' do
46
+ access_by_uuid('blast_2.4.0/blastp')
47
+
48
+ # Click on the PNG/SVG download button of the alignment overview and compare
49
+ # the downloaded content.
50
+
51
+ page.execute_script("$('.export-to-png:eq(0)').click()")
52
+ wait_for_download
53
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-sp_P04637_P53_HUMAN.png')
54
+
55
+ clear_downloads
9
56
 
10
- describe 'report generated from imported XML', :js => true do
11
- before do |scenario|
12
- Capybara.app = SequenceServer.init
13
- Capybara.server = :webrick
14
- Capybara.javascript_driver = :selenium
15
- Capybara.default_max_wait_time = 220
57
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
58
+ wait_for_download
59
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-sp_P04637_P53_HUMAN.svg')
16
60
 
17
- Capybara.register_driver :selenium do |app|
18
- options = ::Selenium::WebDriver::Firefox::Options.new
19
- options.args << '--headless'
20
- Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
21
- end
61
+ clear_downloads
62
+
63
+ # Click on the PNG/SVG download button of the first hit available and
64
+ # compare the downloaded content.
65
+ page.execute_script("$('.export-to-png:eq(1)').click()")
66
+ wait_for_download
67
+
68
+ expect(File.basename(downloaded_file)).to eq('Kablammo-sp_P04637_P53_HUMAN-gi_1099170394_ref_XP_018868681_1.png')
69
+ clear_downloads
70
+
71
+ page.execute_script("$('.export-to-svg:eq(1)').click()")
72
+ wait_for_download
73
+
74
+ expect(File.basename(downloaded_file)).to eq('Kablammo-sp_P04637_P53_HUMAN-gi_1099170394_ref_XP_018868681_1.svg')
75
+ page.should have_content('BLASTP')
22
76
  end
23
77
 
24
- # Fasta files used for testing consist of TP53 and COX41 protein/nucleotide sequences for reproducibility.
25
- it 'loads BLASTP xml output' do
78
+ it 'loads BLASTP XML and tests Circos download' do
26
79
  access_by_uuid('blast_2.4.0/blastp')
80
+
81
+ # Click on the Circos expanding button, wait for animation, click on the
82
+ # download of PNG/SVG file and test that it initiated a file download in a
83
+ # right format.
84
+ page.should have_content('Chord diagram: queries and their top hits')
85
+ page.execute_script("$('.circos > .grapher-header > h5').click()")
86
+ sleep 1
87
+
88
+ page.execute_script("$('.export-to-png:eq(0)').click()")
89
+ wait_for_download
90
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.png')
91
+ clear_downloads
92
+
93
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
94
+ wait_for_download
95
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.svg')
96
+ end
97
+
98
+ it 'loads BLASTP XML and tests Length distribution download' do
99
+ access_by_uuid('blast_2.4.0/blastp')
100
+
101
+ # Click on the Length distribution expanding button, wait for animation,
102
+ # click on the download of PNG/SVG file and test that it initiated a file
103
+ # download in a right format.
104
+ page.should have_content('Length distribution of hits')
105
+ page.execute_script("$('.length-distribution > .grapher-header > h5').click()")
106
+ sleep 1
107
+
108
+ page.execute_script("$('.export-to-png:eq(1)').click()")
109
+ wait_for_download
110
+ expect(File.basename(downloaded_file)).to eq('length-distribution-sp_P04637_P53_HUMAN.png')
111
+ clear_downloads
112
+
113
+ page.execute_script("$('.export-to-svg:eq(1)').click()")
114
+ wait_for_download
115
+ expect(File.basename(downloaded_file)).to eq('length-distribution-sp_P04637_P53_HUMAN.svg')
116
+ end
117
+
118
+ # BLASTX test scenarios
119
+
120
+ it 'loads BLASTX XML and tests hit alignment and sidebar Alignment download' do
121
+ access_by_uuid('blast_2.4.0/blastx')
122
+
123
+ # Click on the first Alignment download button on the page and wait for the
124
+ # download to finish.
125
+ page.execute_script("$('.download-aln:eq(0)').click()")
126
+ wait_for_download
127
+
128
+ expect(File.basename(downloaded_file)).to eq('MH011443_1_gi_1486783307_gb_AYF55702_1.txt')
129
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/MH011443_1_gi_1486783307_gb_AYF55702_1.txt'))
130
+
131
+ clear_downloads
132
+
133
+ # Click on the Alignment of all hits download and compare the downloaded
134
+ # content
135
+
136
+ page.click_link('Alignment of all hits')
137
+ wait_for_download
138
+
139
+ expect(File.basename(downloaded_file)).to eq('alignment-40_hits.txt')
140
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-40_hits_blastx.txt'))
141
+ clear_downloads
142
+
143
+ # Select four hit checkboxes and click on the Alignment of selected hits.
144
+ # Compare the downloaded content.
145
+ page.check('Query_1_hit_3_checkbox')
146
+ page.check('Query_1_hit_4_checkbox')
147
+ page.check('Query_2_hit_3_checkbox')
148
+ page.check('Query_2_hit_4_checkbox')
149
+ page.click_link('Alignment of 4 selected hit(s)')
150
+ wait_for_download
151
+
152
+ expect(File.basename(downloaded_file)).to eq('alignment-4_hits.txt')
153
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-4_hits_blastx.txt'))
154
+
155
+ page.should have_content('BLASTX')
27
156
  end
28
157
 
29
- it 'loads BLASTX xml output' do
158
+ it 'loads BLASTX XML and tests hit PNG/SVG download' do
30
159
  access_by_uuid('blast_2.4.0/blastx')
160
+
161
+ # Click on the PNG/SVG download button of the alignment overview and compare
162
+ # the downloaded content.
163
+ page.execute_script("$('.export-to-png:eq(0)').click()")
164
+ wait_for_download
165
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-MH011443_1.png')
166
+
167
+ clear_downloads
168
+
169
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
170
+ wait_for_download
171
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-MH011443_1.svg')
172
+
173
+ clear_downloads
174
+ # Click on the PNG/SVG download button of the first hit available and
175
+ # compare the downloaded content.
176
+ page.execute_script("$('.export-to-png:eq(1)').click()")
177
+
178
+ wait_for_download
179
+ expect(File.basename(downloaded_file)).to eq('Kablammo-MH011443_1-gi_1486783307_gb_AYF55702_1.png')
180
+ clear_downloads
181
+
182
+ page.execute_script("$('.export-to-svg:eq(1)').click()")
183
+ wait_for_download
184
+
185
+ expect(File.basename(downloaded_file)).to eq('Kablammo-MH011443_1-gi_1486783307_gb_AYF55702_1.svg')
186
+ page.should have_content('BLASTX')
187
+ end
188
+
189
+ it 'loads BLASTX XML and tests Circos download' do
190
+ access_by_uuid('blast_2.4.0/blastx')
191
+ # Click on the Circos expanding button, wait for animation, click on the
192
+ # download of PNG/SVG file and test that it initiated a file download in a
193
+ # right format.
194
+
195
+ page.should have_content('Chord diagram: queries and their top hits')
196
+ page.execute_script("$('.circos > .grapher-header > h5').click()")
197
+ sleep 1
198
+
199
+ page.execute_script("$('.export-to-png:eq(0)').click()")
200
+ wait_for_download
201
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.png')
202
+ clear_downloads
203
+
204
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
205
+ wait_for_download
206
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.svg')
207
+ end
208
+
209
+ it 'loads BLASTX XML and tests Length distribution download' do
210
+ access_by_uuid('blast_2.4.0/blastx')
211
+ # Click on the Length distribution expanding button, wait for animation,
212
+ # click on the download of PNG/SVG file and test that it initiated a file
213
+ # download in a right format.
214
+
215
+ page.should have_content('Length distribution of hits')
216
+ page.execute_script("$('.length-distribution > .grapher-header > h5').click()")
217
+ sleep 1
218
+
219
+ page.execute_script("$('.export-to-png:eq(1)').click()")
220
+ wait_for_download
221
+ expect(File.basename(downloaded_file)).to eq('length-distribution-MH011443_1.png')
222
+
223
+ clear_downloads
224
+
225
+ page.execute_script("$('.export-to-svg:eq(1)').click()")
226
+ wait_for_download
227
+ expect(File.basename(downloaded_file)).to eq('length-distribution-MH011443_1.svg')
228
+ end
229
+
230
+ # BLASTN Test scenarios
231
+
232
+ it 'loads BLASTN XML and tests hit alignment and sidebar Alignment download' do
233
+ access_by_uuid('blast_2.4.0/blastn')
234
+ # Click on the first Alignment download button on the page and wait for the
235
+ # download to finish.
236
+
237
+ page.execute_script("$('.download-aln:eq(0)').click()")
238
+ wait_for_download
239
+
240
+ expect(File.basename(downloaded_file)).to eq('MH011443_1_gi_1486783306_gb_MH011443_1.txt')
241
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/MH011443_1_gi_1486783306_gb_MH011443_1.txt'))
242
+
243
+ clear_downloads
244
+
245
+ # Click on the Alignment of all hits download and compare the downloaded
246
+ # content
247
+
248
+ page.click_link('Alignment of all hits')
249
+ wait_for_download
250
+
251
+ expect(File.basename(downloaded_file)).to eq('alignment-40_hits.txt')
252
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-40_hits_blastn.txt'))
253
+
254
+ clear_downloads
255
+
256
+ # Select four hit checkboxes and click on the Alignment of selected hits.
257
+ # Compare the downloaded content.
258
+ page.check('Query_1_hit_5_checkbox')
259
+ page.check('Query_1_hit_6_checkbox')
260
+ page.check('Query_2_hit_5_checkbox')
261
+ page.check('Query_2_hit_6_checkbox')
262
+ page.click_link('Alignment of 4 selected hit(s)')
263
+ wait_for_download
264
+
265
+ expect(File.basename(downloaded_file)).to eq('alignment-4_hits.txt')
266
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-4_hits_blastn.txt'))
267
+ page.should have_content('BLASTN')
268
+ end
269
+
270
+ it 'loads BLASTN XML and tests hit PNG/SVG download' do
271
+ access_by_uuid('blast_2.4.0/blastn')
272
+
273
+ # Click on the PNG/SVG download button of the alignment overview and compare
274
+ # the downloaded content.
275
+ page.execute_script("$('.export-to-png:eq(0)').click()")
276
+ wait_for_download
277
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-MH011443_1.png')
278
+
279
+ clear_downloads
280
+
281
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
282
+ wait_for_download
283
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-MH011443_1.svg')
284
+
285
+ clear_downloads
286
+ # Click on the PNG download button of the first hit available and compare
287
+ # the downloaded content.
288
+
289
+ page.execute_script("$('.export-to-png:eq(2)').click()")
290
+
291
+ wait_for_download
292
+ expect(File.basename(downloaded_file)).to eq('Kablammo-MH011443_1-gi_1528997474_gb_MH447967_1.png')
293
+
294
+ clear_downloads
295
+
296
+ # Click on the SVG download button of the first hit available and compare
297
+ # the downloaded content.
298
+
299
+ page.execute_script("$('.export-to-svg:eq(2)').click()")
300
+ wait_for_download
301
+
302
+ expect(File.basename(downloaded_file)).to eq('Kablammo-MH011443_1-gi_1528997474_gb_MH447967_1.svg')
303
+ page.should have_content('BLASTN')
31
304
  end
32
305
 
33
- it 'loads BLASTN xml output' do
306
+ it 'loads BLASTN XML and tests Circos download' do
34
307
  access_by_uuid('blast_2.4.0/blastn')
308
+ # Click on the Circos expanding button, wait for animation, click on the
309
+ # download of PNG/SVG file and test that it initiated a file download in a
310
+ # right format.
311
+
312
+ page.should have_content('Chord diagram: queries and their top hits')
313
+ page.execute_script("$('.circos > .grapher-header > h5').click()")
314
+ sleep 1
315
+
316
+ page.execute_script("$('.export-to-png:eq(0)').click()")
317
+ wait_for_download
318
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.png')
319
+ clear_downloads
320
+
321
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
322
+ wait_for_download
323
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.svg')
324
+ end
325
+
326
+ it 'loads BLASTN XML and tests Length distribution download' do
327
+ access_by_uuid('blast_2.4.0/blastn')
328
+ # Click on the Length distribution expanding button, wait for animation,
329
+ # click on the download of PNG/SVG file and test that it initiated a file
330
+ # download in a right format.
331
+
332
+ page.should have_content('Length distribution of hits')
333
+ page.execute_script("$('.length-distribution > .grapher-header > h5').click()")
334
+ sleep 1
335
+ page.execute_script("$('.export-to-png:eq(1)').click()")
336
+ wait_for_download
337
+ expect(File.basename(downloaded_file)).to eq('length-distribution-MH011443_1.png')
338
+ clear_downloads
339
+
340
+ page.execute_script("$('.export-to-svg:eq(1)').click()")
341
+ wait_for_download
342
+ expect(File.basename(downloaded_file)).to eq('length-distribution-MH011443_1.svg')
35
343
  end
36
344
 
37
- it 'loads TBLASTN xml output' do
345
+ # TBLASTN Test scenarios
346
+
347
+ it 'loads TBLASTN XML and tests hit alignment and sidebar Alignment download' do
38
348
  access_by_uuid('blast_2.4.0/tblastn')
349
+ # Click on the first Alignment download button on the page and wait for the
350
+ # download to finish.
351
+
352
+ page.execute_script("$('.download-aln:eq(0)').click()")
353
+ wait_for_download
354
+
355
+ expect(File.basename(downloaded_file)).to eq('sp_P04637_P53_HUMAN_gi_395440626_gb_JQ694049_1.txt')
356
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/sp_P04637_P53_HUMAN_gi_395440626_gb_JQ694049_1.txt'))
357
+
358
+ clear_downloads
359
+
360
+ # Click on the Alignment of all hits download and compare the downloaded
361
+ # content
362
+
363
+ page.click_link('Alignment of all hits')
364
+ wait_for_download
365
+
366
+ expect(File.basename(downloaded_file)).to eq('alignment-40_hits.txt')
367
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-40_hits_tblastn.txt'))
368
+
369
+ clear_downloads
370
+
371
+ # Select four hit checkboxes and click on the Alignment of selected hits.
372
+ # Compare the downloaded content.
373
+ page.check('Query_1_hit_7_checkbox')
374
+ page.check('Query_1_hit_8_checkbox')
375
+ page.check('Query_2_hit_7_checkbox')
376
+ page.check('Query_2_hit_8_checkbox')
377
+ page.click_link('Alignment of 4 selected hit(s)')
378
+ wait_for_download
379
+
380
+ expect(File.basename(downloaded_file)).to eq('alignment-4_hits.txt')
381
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-4_hits_tblastn.txt'))
382
+ page.should have_content('TBLASTN')
39
383
  end
40
384
 
41
- it 'loads TBLASTX xml output' do
385
+ it 'loads TBLASTN XML and tests hit PNG/SVG download' do
386
+ access_by_uuid('blast_2.4.0/tblastn')
387
+
388
+ # Click on the PNG/SVG download button of the alignment overview and compare
389
+ # the downloaded content.
390
+ page.execute_script("$('.export-to-png:eq(0)').click()")
391
+ wait_for_download
392
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-sp_P04637_P53_HUMAN.png')
393
+
394
+ clear_downloads
395
+
396
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
397
+ wait_for_download
398
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-sp_P04637_P53_HUMAN.svg')
399
+
400
+ clear_downloads
401
+ # Click on the PNG download button of the first hit available and compare
402
+ # the downloaded content.
403
+
404
+ page.execute_script("$('.export-to-png:eq(1)').click()")
405
+
406
+ wait_for_download
407
+ expect(File.basename(downloaded_file)).to eq('Kablammo-sp_P04637_P53_HUMAN-gi_395440626_gb_JQ694049_1.png')
408
+ clear_downloads
409
+
410
+ # Click on the SVG download button of the first hit available and compare
411
+ # the downloaded content.
412
+
413
+ page.execute_script("$('.export-to-svg:eq(1)').click()")
414
+ wait_for_download
415
+
416
+ expect(File.basename(downloaded_file)).to eq('Kablammo-sp_P04637_P53_HUMAN-gi_395440626_gb_JQ694049_1.svg')
417
+ page.should have_content('TBLASTN')
418
+ end
419
+
420
+ it 'loads TBLASTN XML and tests Circos download' do
421
+ access_by_uuid('blast_2.4.0/tblastn')
422
+ # Click on the Circos expanding button, wait for animation, click on the
423
+ # download of PNG/SVG file and test that it initiated a file download in a
424
+ # right format.
425
+
426
+ page.should have_content('Chord diagram: queries and their top hits')
427
+ page.execute_script("$('.circos > .grapher-header > h5').click()")
428
+ sleep 1
429
+
430
+ page.execute_script("$('.export-to-png:eq(0)').click()")
431
+ wait_for_download
432
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.png')
433
+
434
+ clear_downloads
435
+
436
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
437
+ wait_for_download
438
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.svg')
439
+ end
440
+
441
+ it 'loads TBLASTN XML and tests Length distribution download' do
442
+ access_by_uuid('blast_2.4.0/tblastn')
443
+ # Click on the Length distribution expanding button, wait for animation,
444
+ # click on the download of PNG/SVG file and test that it initiated a file
445
+ # download in a right format.
446
+
447
+ page.should have_content('Length distribution of hits')
448
+ page.execute_script("$('.length-distribution > .grapher-header > h5').click()")
449
+ sleep 1
450
+
451
+ page.execute_script("$('.export-to-png:eq(1)').click()")
452
+ wait_for_download
453
+ expect(File.basename(downloaded_file)).to eq('length-distribution-sp_P04637_P53_HUMAN.png')
454
+
455
+ clear_downloads
456
+
457
+ page.execute_script("$('.export-to-svg:eq(1)').click()")
458
+ wait_for_download
459
+ expect(File.basename(downloaded_file)).to eq('length-distribution-sp_P04637_P53_HUMAN.svg')
460
+ end
461
+
462
+ # TBLASTX Test scenarios
463
+
464
+ it 'loads TBLASTX XML and tests hit alignment and sidebar Alignment download' do
465
+ access_by_uuid('blast_2.4.0/tblastx')
466
+ # Click on the first Alignment download button on the page and wait for the
467
+ # download to finish.
468
+
469
+ page.execute_script("$('.download-aln:eq(1)').click()")
470
+ wait_for_download
471
+
472
+ expect(File.basename(downloaded_file)).to eq('MH011443_1_gi_1528997474_gb_MH447967_1.txt')
473
+ expect(File.read(downloaded_file)). to eq(File.read('spec/sequences/MH011443_1_gi_1528997474_gb_MH447967_1.txt'))
474
+
475
+ clear_downloads
476
+
477
+ # Click on the Alignment of all hits download and compare the downloaded
478
+ # content
479
+
480
+ page.click_link('Alignment of all hits')
481
+ wait_for_download
482
+
483
+ expect(File.basename(downloaded_file)).to eq('alignment-40_hits.txt')
484
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-40_hits_tblastx.txt'))
485
+
486
+ clear_downloads
487
+
488
+ # Select four hit checkboxes and click on the Alignment of selected hits.
489
+ # Compare the downloaded content.
490
+ page.check('Query_1_hit_9_checkbox')
491
+ page.check('Query_1_hit_10_checkbox')
492
+ page.check('Query_2_hit_9_checkbox')
493
+ page.check('Query_2_hit_10_checkbox')
494
+ page.click_link('Alignment of 4 selected hit(s)')
495
+ wait_for_download
496
+
497
+ expect(File.basename(downloaded_file)).to eq('alignment-4_hits.txt')
498
+ expect(File.read(downloaded_file)).to eq(File.read('spec/sequences/alignment-4_hits_tblastx.txt'))
499
+ page.should have_content('TBLASTX')
500
+ end
501
+
502
+ it 'loads TBLASTX XML and tests hit PNG/SVG download' do
503
+ access_by_uuid('blast_2.4.0/tblastx')
504
+
505
+ # Click on the PNG/SVG download button of the alignment overview and compare
506
+ # the downloaded content.
507
+ page.execute_script("$('.export-to-png:eq(0)').click()")
508
+ wait_for_download
509
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-MH011443_1.png')
510
+
511
+ clear_downloads
512
+
513
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
514
+ wait_for_download
515
+ expect(File.basename(downloaded_file)).to eq('Alignment-Overview-MH011443_1.svg')
516
+
517
+ clear_downloads
518
+ # Click on the PNG download button of the first hit available and compare
519
+ # the downloaded content.
520
+
521
+ page.execute_script("$('.export-to-png:eq(1)').click()")
522
+
523
+ wait_for_download
524
+ expect(File.basename(downloaded_file)).to eq('Kablammo-MH011443_1-gi_1486783306_gb_MH011443_1.png')
525
+
526
+ clear_downloads
527
+
528
+ # Click on the SVG download button of the first hit available and compare
529
+ # the downloaded content.
530
+
531
+ page.execute_script("$('.export-to-svg:eq(1)').click()")
532
+ wait_for_download
533
+
534
+ expect(File.basename(downloaded_file)).to eq('Kablammo-MH011443_1-gi_1486783306_gb_MH011443_1.svg')
535
+ page.should have_content('TBLASTX')
536
+ end
537
+
538
+ it 'loads TBLASTX XML and tests Circos download' do
42
539
  access_by_uuid('blast_2.4.0/tblastx')
540
+ # Click on the Circos expanding button, wait for animation, click on the
541
+ # download of PNG/SVG file and test that it initiated a file download in a
542
+ # right format.
543
+
544
+ page.should have_content('Chord diagram: queries and their top hits')
545
+ page.execute_script("$('.circos > .grapher-header > h5').click()")
546
+ sleep 1
547
+
548
+ page.execute_script("$('.export-to-png:eq(0)').click()")
549
+ wait_for_download
550
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.png')
551
+
552
+ clear_downloads
553
+
554
+ page.execute_script("$('.export-to-svg:eq(0)').click()")
555
+ wait_for_download
556
+ expect(File.basename(downloaded_file)).to eq('Circos-visualisation.svg')
557
+ end
558
+
559
+ it 'loads TBLASTX XML and tests Length distribution download' do
560
+ access_by_uuid('blast_2.4.0/tblastx')
561
+ # Click on the Length distribution expanding button, wait for animation,
562
+ # click on the download of PNG/SVG file and test that it initiated a file
563
+ # download in a right format.
564
+
565
+ page.should have_content('Length distribution of hits')
566
+ page.execute_script("$('.length-distribution > .grapher-header > h5').click()")
567
+ sleep 1
568
+
569
+ page.execute_script("$('.export-to-png:eq(1)').click()")
570
+ wait_for_download
571
+ expect(File.basename(downloaded_file)).to eq('length-distribution-MH011443_1.png')
572
+
573
+ clear_downloads
574
+
575
+ page.execute_script("$('.export-to-svg:eq(1)').click()")
576
+ wait_for_download
577
+ expect(File.basename(downloaded_file)).to eq('length-distribution-MH011443_1.svg')
43
578
  end
44
579
 
45
580
  ## Helpers ##
46
581
 
47
582
  def access_by_uuid(id)
48
- url= url_encode(id)
583
+ # Method to access the XML report in the browser
584
+ url = url_encode(id)
49
585
  visit "/#{url}"
50
586
  page.should have_content('Query')
51
587
  end