sequenceserver 1.1.0.beta12 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sequenceserver might be problematic. Click here for more details.

Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +5 -5
  4. data/README.md +86 -43
  5. data/bin/sequenceserver +29 -32
  6. data/lib/sequenceserver.rb +86 -123
  7. data/lib/sequenceserver/api_errors.rb +3 -1
  8. data/lib/sequenceserver/blast/hit.rb +48 -28
  9. data/lib/sequenceserver/blast/job.rb +28 -8
  10. data/lib/sequenceserver/blast/report.rb +52 -15
  11. data/lib/sequenceserver/database.rb +71 -0
  12. data/lib/sequenceserver/exceptions.rb +5 -10
  13. data/lib/sequenceserver/job.rb +8 -1
  14. data/lib/sequenceserver/links.rb +49 -17
  15. data/lib/sequenceserver/logger.rb +2 -2
  16. data/lib/sequenceserver/routes.rb +20 -14
  17. data/lib/sequenceserver/sys.rb +86 -0
  18. data/lib/sequenceserver/version.rb +1 -1
  19. data/public/css/sequenceserver.min.css +3 -3
  20. data/public/js/alignment_exporter.js +1 -1
  21. data/public/js/hsp.js +1 -1
  22. data/public/js/report.js +76 -63
  23. data/public/js/search.js +29 -6
  24. data/public/sequenceserver-report.min.js +4 -4
  25. data/public/sequenceserver-search.min.js +2 -2
  26. data/sequenceserver.gemspec +3 -2
  27. data/spec/blast_versions/blast_2.2.30/blast_2.2.30_spec.rb +228 -0
  28. data/spec/blast_versions/blast_2.2.30/import_spec_capybara_local_2.2.30.rb +53 -0
  29. data/spec/blast_versions/blast_2.2.31/blast_2.2.31_spec.rb +228 -0
  30. data/spec/blast_versions/blast_2.2.31/import_spec_capybara_local_2.2.31.rb +53 -0
  31. data/spec/{blast_spec.rb → blast_versions/blast_2.3.0/blast_2.3.0_spec.rb} +8 -37
  32. data/spec/blast_versions/blast_2.3.0/import_spec_capybara_local_2.3.0.rb +52 -0
  33. data/spec/blast_versions/blast_2.4.0/blast_2.4.0_spec.rb +228 -0
  34. data/spec/blast_versions/blast_2.4.0/import_spec_capybara_local_2.4.0.rb +52 -0
  35. data/spec/blast_versions/blast_2.5.0/blast_2.5.0_spec.rb +228 -0
  36. data/spec/blast_versions/blast_2.5.0/import_spec_capybara_local_2.5.0.rb +53 -0
  37. data/spec/blast_versions/blast_2.6.0/blast_2.6.0_spec.rb +228 -0
  38. data/spec/blast_versions/blast_2.6.0/import_spec_capybara_local_2.6.0.rb +52 -0
  39. data/spec/blast_versions/blast_2.7.1/blast_2.7.1_spec.rb +228 -0
  40. data/spec/blast_versions/blast_2.7.1/import_spec_capybara_local_2.7.1.rb +56 -0
  41. data/spec/blast_versions/blast_2.8.1/blast_2.8.1_spec.rb +228 -0
  42. data/spec/blast_versions/blast_2.8.1/import_spec_capybara_local_2.8.1.rb +55 -0
  43. data/spec/blast_versions/blast_2.9.0/blast_2.9.0_spec.rb +228 -0
  44. data/spec/blast_versions/blast_2.9.0/import_spec_capybara_local_2.9.0.rb +53 -0
  45. data/spec/blast_versions/diamond_0.9.24/diamond_0.9.24_spec.rb +176 -0
  46. data/spec/blast_versions/diamond_0.9.24/import_spec_capybara_local_0.9.24.rb +39 -0
  47. data/spec/capybara_spec.local.rb +190 -0
  48. data/spec/capybara_spec.rb +15 -13
  49. data/spec/config_spec.rb +1 -1
  50. data/spec/database/funky_ids/funky_ids.fa +2 -0
  51. data/spec/database/funky_ids/funky_ids.fa.nhd +8 -0
  52. data/spec/database/funky_ids/funky_ids.fa.nhi +0 -0
  53. data/spec/database/funky_ids/funky_ids.fa.nhr +0 -0
  54. data/spec/database/funky_ids/funky_ids.fa.nin +0 -0
  55. data/spec/database/funky_ids/funky_ids.fa.nog +0 -0
  56. data/spec/database/funky_ids/funky_ids.fa.nsd +15 -13
  57. data/spec/database/funky_ids/funky_ids.fa.nsi +0 -0
  58. data/spec/database/funky_ids/funky_ids.fa.nsq +0 -0
  59. data/spec/database_spec.rb +2 -2
  60. data/spec/dotdir/blast_2.2.30/blastn/BLASTN_XML_2.2.30.xml +1201 -0
  61. data/spec/dotdir/blast_2.2.30/blastn/job.yaml +8 -0
  62. data/spec/dotdir/blast_2.2.30/blastn_nohits/BLASTN_NO_HITS_XML_2.2.30.xml +866 -0
  63. data/spec/dotdir/blast_2.2.30/blastn_nohits/job.yaml +8 -0
  64. data/spec/dotdir/blast_2.2.30/blastp/BLASTP_XML_2.2.30.xml +1181 -0
  65. data/spec/dotdir/blast_2.2.30/blastp/job.yaml +8 -0
  66. data/spec/dotdir/blast_2.2.30/blastx/BLASTX_XML_2.2.30.xml +1181 -0
  67. data/spec/dotdir/blast_2.2.30/blastx/job.yaml +8 -0
  68. data/spec/dotdir/blast_2.2.30/tblastn/TBLASTN_XML_2.2.30.xml +1181 -0
  69. data/spec/dotdir/blast_2.2.30/tblastn/job.yaml +8 -0
  70. data/spec/dotdir/blast_2.2.30/tblastx/TBLASTX_XML_2.2.30.xml +8857 -0
  71. data/spec/dotdir/blast_2.2.30/tblastx/job.yaml +8 -0
  72. data/spec/dotdir/blast_2.2.31/blastn/BLASTN_XML_2.2.31.xml +1201 -0
  73. data/spec/dotdir/blast_2.2.31/blastn/job.yaml +8 -0
  74. data/spec/dotdir/blast_2.2.31/blastn_nohits/BLASTN_NO_HITS_XML_2.2.31.xml +866 -0
  75. data/spec/dotdir/blast_2.2.31/blastn_nohits/job.yaml +8 -0
  76. data/spec/dotdir/blast_2.2.31/blastp/BLASTP_XML_2.2.31.xml +1181 -0
  77. data/spec/dotdir/blast_2.2.31/blastp/job.yaml +8 -0
  78. data/spec/dotdir/blast_2.2.31/blastx/BLASTX_XML_2.2.31.xml +1181 -0
  79. data/spec/dotdir/blast_2.2.31/blastx/job.yaml +8 -0
  80. data/spec/dotdir/blast_2.2.31/tblastn/TBLASTN_XML_2.2.31.xml +1181 -0
  81. data/spec/dotdir/blast_2.2.31/tblastn/job.yaml +8 -0
  82. data/spec/dotdir/blast_2.2.31/tblastx/TBLASTX_XML_2.2.31.xml +8857 -0
  83. data/spec/dotdir/blast_2.2.31/tblastx/job.yaml +8 -0
  84. data/spec/dotdir/blast_2.3.0/blastn/BLASTN_XML_2.3.0.xml +1201 -0
  85. data/spec/dotdir/blast_2.3.0/blastn/job.yaml +8 -0
  86. data/spec/dotdir/blast_2.3.0/blastn_nohits/BLASTN_NO_HITS_XML_2.3.0.xml +866 -0
  87. data/spec/dotdir/blast_2.3.0/blastn_nohits/job.yaml +8 -0
  88. data/spec/dotdir/blast_2.3.0/blastp/BLASTP_XML_2.3.0.xml +1181 -0
  89. data/spec/dotdir/blast_2.3.0/blastp/job.yaml +8 -0
  90. data/spec/dotdir/blast_2.3.0/blastx/BLASTX_XML_2.3.0.xml +1181 -0
  91. data/spec/dotdir/blast_2.3.0/blastx/job.yaml +8 -0
  92. data/spec/dotdir/blast_2.3.0/tblastn/TBLASTN_XML_2.3.0.xml +1181 -0
  93. data/spec/dotdir/blast_2.3.0/tblastn/job.yaml +8 -0
  94. data/spec/dotdir/blast_2.3.0/tblastx/TBLASTX_XML_2.3.0.xml +8857 -0
  95. data/spec/dotdir/blast_2.3.0/tblastx/job.yaml +8 -0
  96. data/spec/dotdir/blast_2.4.0/blastn/BLASTN_XML_2.4.0.xml +1201 -0
  97. data/spec/dotdir/blast_2.4.0/blastn/TBLASTN_XML_2.4.0.xml +1181 -0
  98. data/spec/dotdir/blast_2.4.0/blastn/job.yaml +8 -0
  99. data/spec/dotdir/blast_2.4.0/blastn_nohits/BLASTN_NO_HITS_XML_2.4.0.xml +866 -0
  100. data/spec/dotdir/blast_2.4.0/blastn_nohits/job.yaml +8 -0
  101. data/spec/dotdir/blast_2.4.0/blastp/BLASTP_XML_2.4.0.xml +1181 -0
  102. data/spec/dotdir/blast_2.4.0/blastp/job.yaml +8 -0
  103. data/spec/dotdir/blast_2.4.0/blastx/BLASTX_XML_2.4.0.xml +1181 -0
  104. data/spec/dotdir/blast_2.4.0/blastx/job.yaml +8 -0
  105. data/spec/dotdir/blast_2.4.0/tblastn/TBLASTN_XML_2.4.0.xml +1181 -0
  106. data/spec/dotdir/blast_2.4.0/tblastn/job.yaml +8 -0
  107. data/spec/dotdir/blast_2.4.0/tblastx/TBLASTX_XML_2.4.0.xml +8857 -0
  108. data/spec/dotdir/blast_2.4.0/tblastx/job.yaml +8 -0
  109. data/spec/dotdir/blast_2.5.0/blastn/BLASTN_LONG_XML_2.5.0.xml +18813 -0
  110. data/spec/dotdir/blast_2.5.0/blastn/BLASTN_XML_2.5.0.xml +1201 -0
  111. data/spec/dotdir/blast_2.5.0/blastn/job.yaml +8 -0
  112. data/spec/dotdir/blast_2.5.0/blastn_nohits/BLASTN_NO_HITS_XML_2.5.0.xml +866 -0
  113. data/spec/dotdir/blast_2.5.0/blastn_nohits/job.yaml +8 -0
  114. data/spec/dotdir/blast_2.5.0/blastp/BLASTP +2161 -0
  115. data/spec/dotdir/blast_2.5.0/blastp/BLASTP_XML_2.5.0.xml +1181 -0
  116. data/spec/dotdir/blast_2.5.0/blastp/job.yaml +8 -0
  117. data/spec/dotdir/blast_2.5.0/blastx/BLASTX +28080 -0
  118. data/spec/dotdir/blast_2.5.0/blastx/BLASTX_XML_2.5.0.xml +1181 -0
  119. data/spec/dotdir/blast_2.5.0/blastx/job.yaml +8 -0
  120. data/spec/dotdir/blast_2.5.0/tblastn/TBLASTN +29486 -0
  121. data/spec/dotdir/blast_2.5.0/tblastn/TBLASTN_XML_2.5.0.xml +1181 -0
  122. data/spec/dotdir/blast_2.5.0/tblastn/job.yaml +8 -0
  123. data/spec/dotdir/blast_2.5.0/tblastx/TBLASTX +180859 -0
  124. data/spec/dotdir/blast_2.5.0/tblastx/TBLASTX_XML_2.5.0.xml +8857 -0
  125. data/spec/dotdir/blast_2.5.0/tblastx/job.yaml +8 -0
  126. data/spec/dotdir/blast_2.6.0/blastn/BLASTN_XML_2.6.0.xml +1201 -0
  127. data/spec/dotdir/blast_2.6.0/blastn/job.yaml +8 -0
  128. data/spec/dotdir/blast_2.6.0/blastn_nohits/BLASTN_NO_HITS_XML_2.6.0.xml +866 -0
  129. data/spec/dotdir/blast_2.6.0/blastn_nohits/job.yaml +8 -0
  130. data/spec/dotdir/blast_2.6.0/blastp/BLASTP_XML_2.6.0.xml +1181 -0
  131. data/spec/dotdir/blast_2.6.0/blastp/job.yaml +8 -0
  132. data/spec/dotdir/blast_2.6.0/blastx/BLASTX_XML_2.6.0.xml +1181 -0
  133. data/spec/dotdir/blast_2.6.0/blastx/job.yaml +8 -0
  134. data/spec/dotdir/blast_2.6.0/tblastn/TBLASTN_XML_2.6.0.xml +1181 -0
  135. data/spec/dotdir/blast_2.6.0/tblastn/job.yaml +8 -0
  136. data/spec/dotdir/blast_2.6.0/tblastx/TBLASTX_XML_2.6.0.xml +8857 -0
  137. data/spec/dotdir/blast_2.6.0/tblastx/job.yaml +8 -0
  138. data/spec/dotdir/blast_2.7.1/blastn/BLASTN_XML_2.7.1.xml +1201 -0
  139. data/spec/dotdir/blast_2.7.1/blastn/job.yaml +8 -0
  140. data/spec/dotdir/blast_2.7.1/blastn_nohits/BLASTN_NO_HITS_XML_2.7.1.xml +866 -0
  141. data/spec/dotdir/blast_2.7.1/blastn_nohits/job.yaml +8 -0
  142. data/spec/dotdir/blast_2.7.1/blastp/BLASTP_XML_2.7.1.xml +1181 -0
  143. data/spec/dotdir/blast_2.7.1/blastp/job.yaml +8 -0
  144. data/spec/dotdir/blast_2.7.1/blastx/BLASTX_XML_2.7.1.xml +1181 -0
  145. data/spec/dotdir/blast_2.7.1/blastx/job.yaml +8 -0
  146. data/spec/dotdir/blast_2.7.1/tblastn/TBLASTN_XML_2.7.1.xml +1181 -0
  147. data/spec/dotdir/blast_2.7.1/tblastn/job.yaml +8 -0
  148. data/spec/dotdir/blast_2.7.1/tblastx/TBLASTX_XML_2.7.1.xml +8857 -0
  149. data/spec/dotdir/blast_2.7.1/tblastx/job.yaml +8 -0
  150. data/spec/dotdir/blast_2.8.1/blastn/BLASTN_XML_2.8.1.xml +1201 -0
  151. data/spec/dotdir/blast_2.8.1/blastn/job.yaml +8 -0
  152. data/spec/dotdir/blast_2.8.1/blastn_nohits/BLASTN_NO_HITS_XML_2.8.1.xml +866 -0
  153. data/spec/dotdir/blast_2.8.1/blastn_nohits/job.yaml +8 -0
  154. data/spec/dotdir/blast_2.8.1/blastp/BLASTP_XML_2.8.1.xml +1181 -0
  155. data/spec/dotdir/blast_2.8.1/blastp/job.yaml +8 -0
  156. data/spec/dotdir/blast_2.8.1/blastx/BLASTX_XML_2.8.1.xml +1181 -0
  157. data/spec/dotdir/blast_2.8.1/blastx/job.yaml +8 -0
  158. data/spec/dotdir/blast_2.8.1/tblastn/TBLASTN_XML_2.8.1.xml +1181 -0
  159. data/spec/dotdir/blast_2.8.1/tblastn/job.yaml +8 -0
  160. data/spec/dotdir/blast_2.8.1/tblastx/TBLASTX_XML_2.8.1.xml +8857 -0
  161. data/spec/dotdir/blast_2.8.1/tblastx/job.yaml +8 -0
  162. data/spec/dotdir/blast_2.9.0/blastn/BLASTN_XML_2.9.0.xml +1201 -0
  163. data/spec/dotdir/blast_2.9.0/blastn/job.yaml +8 -0
  164. data/spec/dotdir/blast_2.9.0/blastn_nohits/BLASTN_NO_HITS_XML_2.9.0.xml +866 -0
  165. data/spec/dotdir/blast_2.9.0/blastn_nohits/job.yaml +8 -0
  166. data/spec/dotdir/blast_2.9.0/blastp/BLASTP_XML_2.9.0.xml +1181 -0
  167. data/spec/dotdir/blast_2.9.0/blastp/job.yaml +8 -0
  168. data/spec/dotdir/blast_2.9.0/blastx/BLASTX_XML_2.9.0.xml +1181 -0
  169. data/spec/dotdir/blast_2.9.0/blastx/job.yaml +8 -0
  170. data/spec/dotdir/blast_2.9.0/tblastn/TBLASTN_XML_2.9.0.xml +1181 -0
  171. data/spec/dotdir/blast_2.9.0/tblastn/job.yaml +8 -0
  172. data/spec/dotdir/blast_2.9.0/tblastx/TBLASTX_XML_2.9.0.xml +8857 -0
  173. data/spec/dotdir/blast_2.9.0/tblastx/job.yaml +8 -0
  174. data/spec/dotdir/diamond_0.9.24/blastp/DIAMOND_BLASTP_0.9.24.xml +1040 -0
  175. data/spec/dotdir/diamond_0.9.24/blastp/job.yaml +8 -0
  176. data/spec/dotdir/diamond_0.9.24/blastx/DIAMOND_BLASTX_0.9.24.xml +1040 -0
  177. data/spec/dotdir/diamond_0.9.24/blastx/job.yaml +8 -0
  178. data/spec/dotdir/diamond_0.9.24/blastx_nohits/DIAMOND_BLASTX_NOHITS_0.9.24.xml +41 -0
  179. data/spec/dotdir/diamond_0.9.24/blastx_nohits/job.yaml +8 -0
  180. data/spec/download_helper.rb +32 -0
  181. data/spec/import_spec_capybara_local.rb +61 -0
  182. data/spec/sequence_spec.rb +1 -2
  183. data/spec/sequences/Nucleotide_TP53_COX41.fasta +15 -0
  184. data/spec/sequences/Protein_TP53_COX41.fasta +12 -0
  185. data/spec/sequences/Query_1_SI2_2_0_06267.txt +6 -0
  186. data/spec/{nucleotide_query.fa → sequences/nucleotide_query.fa} +0 -0
  187. data/spec/sequences/problematic_query.fa +5 -0
  188. data/spec/sequences/protein_query.fa +9 -0
  189. data/spec/sequences/sample_query_fire_ant_obps.fa +44 -0
  190. data/spec/sequences/sequenceserver-SI2.2.0_06267.fa +5 -0
  191. data/spec/sequenceserver_spec.rb +3 -3
  192. data/spec/spec_helper.rb +59 -0
  193. metadata +185 -28
  194. data/spec/protein_query.fa +0 -21
  195. data/spec/sample_reports/blastn_sample/job.yaml +0 -10
  196. data/spec/sample_reports/blastn_sample/stdout +0 -144
  197. data/spec/sample_reports/blastp_sample/job.yaml +0 -10
  198. data/spec/sample_reports/blastp_sample/stdout +0 -1187
  199. data/spec/sample_reports/blastx_sample/job.yaml +0 -10
  200. data/spec/sample_reports/blastx_sample/stdout +0 -1191
  201. data/spec/sample_reports/no_hits_sample/job.yaml +0 -10
  202. data/spec/sample_reports/no_hits_sample/stdout +0 -130
  203. data/spec/sample_reports/tblastn_sample/job.yaml +0 -10
  204. data/spec/sample_reports/tblastn_sample/stdout +0 -1107
  205. data/spec/sample_reports/tblastx_sample/job.yaml +0 -10
  206. data/spec/sample_reports/tblastx_sample/stdout +0 -2422
  207. data/spec/sample_reports/with_hits_sample/job.yaml +0 -10
  208. data/spec/sample_reports/with_hits_sample/stdout +0 -1489
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'sauce_whisk'
3
+ require 'capybara/rspec'
4
+ require 'selenium-webdriver'
5
+
6
+ RSpec.configure do |config|
7
+ config.include Capybara::DSL
8
+ end
9
+
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
16
+
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
22
+ end
23
+
24
+ # Fasta files used for testing consist of TP53 and COX41 protein/nucleotide sequences for reproducibility.
25
+ it 'loads BLASTP xml output' do
26
+ access_by_uuid('blast_2.4.0/blastp')
27
+ end
28
+
29
+ it 'loads BLASTX xml output' do
30
+ access_by_uuid('blast_2.4.0/blastx')
31
+ end
32
+
33
+ it 'loads BLASTN xml output' do
34
+ access_by_uuid('blast_2.4.0/blastn')
35
+ end
36
+
37
+ it 'loads TBLASTN xml output' do
38
+ access_by_uuid('blast_2.4.0/tblastn')
39
+ end
40
+
41
+ it 'loads TBLASTX xml output' do
42
+ access_by_uuid('blast_2.4.0/tblastx')
43
+ end
44
+
45
+ ## Helpers ##
46
+
47
+ def access_by_uuid(id)
48
+ url= url_encode(id)
49
+ visit "/#{url}"
50
+ page.should have_content('Query')
51
+ end
52
+ end
@@ -0,0 +1,228 @@
1
+ require 'spec_helper'
2
+
3
+ # Test BLAST module.
4
+ module SequenceServer
5
+ with_hits = Job.fetch('blast_2.5.0/blastn')
6
+ no_hits = Job.fetch('blast_2.5.0/blastn_nohits')
7
+
8
+ init
9
+
10
+ describe 'Report' do
11
+ hits_report = BLAST::Report.new(with_hits)
12
+ no_hits_report = BLAST::Report.new(no_hits)
13
+
14
+ it 'will return an Array of queries' do
15
+ hits_report.queries.should be_a Array
16
+ no_hits_report.queries.should be_a Array
17
+ end
18
+
19
+ it 'will return a Hash of stats' do
20
+ hits_report.stats.should be_a Hash
21
+ no_hits_report.stats.should be_a Hash
22
+ end
23
+
24
+ it 'contains all the necessary stats' do
25
+ hits_report.stats.length.should eql(7)
26
+ no_hits_report.stats.length.should eql(7)
27
+ end
28
+ end
29
+
30
+ describe 'Query' do
31
+ hits_report = BLAST::Report.new(with_hits)
32
+ no_hits_report = BLAST::Report.new(no_hits)
33
+
34
+ it 'will return queries with valid length' do
35
+ hits_report.queries.first.length.should be_a Fixnum
36
+ hits_report.queries.first.length.should satisfy { |n| n > 0 }
37
+ no_hits_report.queries.first.length.should be_a Fixnum
38
+ no_hits_report.queries.first.length.should satisfy { |n| n > 0 }
39
+ end
40
+
41
+ it 'will return an Array of hits' do
42
+ hits_report.queries.first.hits.should be_a Array
43
+ no_hits_report.queries.first.hits.should be_a Array
44
+ end
45
+ end
46
+
47
+ describe 'Hits' do
48
+ hits_report = BLAST::Report.new(with_hits)
49
+ no_hits_report = BLAST::Report.new(no_hits)
50
+
51
+ it 'will have non zero length' do
52
+ hits_report.queries.last.hits.first.length.should satisfy { |n| n > 0 }
53
+ end
54
+
55
+ it 'will return an Array of HSPs' do
56
+ hits_report.queries.first.hits.first.hsps.should be_a Array
57
+ end
58
+
59
+ it 'will return an Array with atleast one HSP' do
60
+ hits_report.queries.first.hits.first.hsps.length.should be >= 1
61
+ end
62
+
63
+ it 'will contain no element if no hits were obtained' do
64
+ no_hits_report.queries.first.hits.length.should eql(0)
65
+ end
66
+ end
67
+
68
+ # Test general features of HSPs. Algorithm specific customizations are
69
+ # tested separetly.
70
+ describe 'HSPs' do
71
+ hits_report = BLAST::Report.new(with_hits)
72
+
73
+ # Currently using all 17 HSP parameters in BLAST Report + 1 to refer to the
74
+ # hit object it belongs to.
75
+ it 'have all the necessary values' do
76
+ hits_report.queries.last.hits.first.hsps.last.count.should eql(19)
77
+ end
78
+
79
+ # Test Random HSPs to ensure that all the values from HSP struct are valid.
80
+ it 'have correct alignment values' do
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
83
+
84
+ hits_report.queries.first.hits.first.hsps.first.evalue.should be_a Float
85
+ hits_report.queries.first.hits.first.hsps.first.evalue
86
+ .should_not satisfy { |n| n < 0 }
87
+
88
+ hits_report.queries.first.hits.last.hsps.first.qstart.should be_a Fixnum
89
+ hits_report.queries.first.hits.last.hsps.first.qstart
90
+ .should_not satisfy { |n| n < 0 }
91
+
92
+ hits_report.queries.first.hits.last.hsps.first.qend.should be_a Fixnum
93
+ hits_report.queries.first.hits.last.hsps.first.qend
94
+ .should_not satisfy { |n| n < 0 }
95
+
96
+ hits_report.queries.last.hits.last.hsps.last.sstart.should be_a Fixnum
97
+ hits_report.queries.last.hits.last.hsps.last.sstart
98
+ .should_not satisfy { |n| n < 0 }
99
+
100
+ hits_report.queries.first.hits.first.hsps.last.send.should be_a Fixnum
101
+ hits_report.queries.first.hits.first.hsps.last.send
102
+ .should_not satisfy { |n| n < 0 }
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
106
+
107
+ hits_report.queries.first.hits.first.hsps.last.identity.should be_a Fixnum
108
+ hits_report.queries.first.hits.first.hsps.last.identity
109
+ .should_not satisfy { |n| n < 0 }
110
+
111
+ hits_report.queries.first.hits.first.hsps.last.gaps.should be_a Fixnum
112
+ hits_report.queries.first.hits.first.hsps.last.gaps
113
+ .should_not satisfy { |n| n < 0 }
114
+
115
+ hits_report.queries.first.hits.first.hsps.last.positives
116
+ .should be_a Fixnum
117
+ hits_report.queries.first.hits.first.hsps.last.positives
118
+ .should_not satisfy { |n| n < 0 }
119
+
120
+ hits_report.queries.first.hits.first.hsps.last.length.should be_a Fixnum
121
+ hits_report.queries.first.hits.first.hsps.last.length
122
+ .should satisfy { |n| n > 0 }
123
+
124
+ hits_report.queries.last.hits.last.hsps.first.qseq.should be_a String
125
+ hits_report.queries.last.hits.last.hsps.first.sseq.should be_a String
126
+ hits_report.queries.last.hits.last.hsps.first.midline.should be_a String
127
+ end
128
+
129
+ it 'have correctly matched query, hit and midline alignments' do
130
+ hsp = hits_report.queries.last.hits.last.hsps.first
131
+ hsp.qseq.length.should eql(hsp.sseq.length)
132
+ hsp.sseq.length.should eql(hsp.midline.length)
133
+ hsp.midline.length.should eql(hsp.qseq.length)
134
+ end
135
+ end
136
+
137
+ # Individually test different BLAST+ algorithms
138
+ #
139
+ describe 'BLASTN' do
140
+ let 'hsp' do
141
+ report = BLAST::Report.new(Job.fetch('blast_2.5.0/blastn'))
142
+ report.queries.first.hits.last.hsps.first
143
+ end
144
+
145
+ it 'have correct query and subject frame' do
146
+ [1, -1].should include(hsp.qframe)
147
+ [1, -1].should include(hsp.sframe)
148
+ end
149
+
150
+ it 'have correct qstart, qend, sstart, send' do
151
+ if hsp.sframe > 0
152
+ hsp.sstart.should be <= hsp.send
153
+ else
154
+ hsp.sstart.should be >= hsp.send
155
+ end
156
+ end
157
+ end
158
+
159
+ describe 'BLASTP' do
160
+ let 'hsp' do
161
+ report = BLAST::Report.new(Job.fetch('blast_2.5.0/blastp'))
162
+ report.queries.first.hits.last.hsps.first
163
+ end
164
+
165
+ it 'have correct query and subject frame' do
166
+ hsp.qframe.should eql(0)
167
+ hsp.sframe.should eql(0)
168
+ end
169
+
170
+ it 'have correct qstart, qend, sstart, send values' do
171
+ hsp.qstart.should be <= hsp.qend
172
+ hsp.sstart.should be <= hsp.send
173
+ end
174
+
175
+ end
176
+
177
+ describe 'BLASTX' do
178
+ let 'hsp' do
179
+ report = BLAST::Report.new(Job.fetch('blast_2.5.0/blastx'))
180
+
181
+ report.queries.first.hits.last.hsps.first
182
+ end
183
+
184
+ it 'have correct query and subject frame' do
185
+ hsp.qframe.should_not eql(0)
186
+ hsp.sframe.should eql(0)
187
+ end
188
+
189
+ it 'have correct qstart, qend, sstart, send' do
190
+ hsp.qstart.should be <= hsp.qend
191
+ hsp.sstart.should be <= hsp.send
192
+ end
193
+ end
194
+
195
+ describe 'TBLASTX' do
196
+ let 'hsp' do
197
+ report = BLAST::Report.new(Job.fetch('blast_2.5.0/tblastx'))
198
+ report.queries.first.hits.last.hsps.first
199
+ end
200
+
201
+ it 'have correct query and subject frame' do
202
+ hsp.qframe.should_not eql(0)
203
+ hsp.sframe.should_not eql(0)
204
+ end
205
+
206
+ it 'have correct qstart, qend, sstart, send' do
207
+ hsp.qstart.should be <= hsp.qend
208
+ hsp.sstart.should be <= hsp.send
209
+ end
210
+ end
211
+
212
+ describe 'TBLASTN' do
213
+ let 'hsp' do
214
+ report = BLAST::Report.new(Job.fetch('blast_2.5.0/tblastn'))
215
+ report.queries.first.hits.last.hsps.first
216
+ end
217
+
218
+ it 'have correct query and subject frame' do
219
+ hsp.qframe.should eql(0)
220
+ hsp.sframe.should_not eql(0)
221
+ end
222
+
223
+ it 'have correct qstart, qend, sstart, send' do
224
+ hsp.qstart.should be <= hsp.qend
225
+ hsp.sstart.should be <= hsp.send
226
+ end
227
+ end
228
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ require 'sauce_whisk'
3
+ require 'capybara/rspec'
4
+ require 'selenium-webdriver'
5
+
6
+ RSpec.configure do |config|
7
+ config.include Capybara::DSL
8
+ end
9
+
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 = 20
16
+
17
+ options = ::Selenium::WebDriver::Firefox::Options.new
18
+ options.args << '--headless'
19
+ Capybara.register_driver :selenium do |app|
20
+ Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
21
+ end
22
+ end
23
+
24
+ # Fasta files used for testing consist of TP53 and COX41 protein/nucleotide sequences for reproducibility.
25
+ it 'loads BLASTP xml output' do
26
+ access_by_uuid('blast_2.5.0/blastp')
27
+ end
28
+
29
+ it 'loads BLASTX xml output' do
30
+ access_by_uuid('blast_2.5.0/blastx')
31
+ end
32
+
33
+ it 'loads BLASTN xml output' do
34
+ access_by_uuid('blast_2.5.0/blastn')
35
+ end
36
+
37
+ it 'loads TBLASTN xml output' do
38
+ access_by_uuid('blast_2.5.0/tblastn')
39
+ end
40
+
41
+ it 'loads TBLASTX xml output' do
42
+ access_by_uuid('blast_2.5.0/tblastx')
43
+ end
44
+
45
+
46
+ ## Helpers ##
47
+
48
+ def access_by_uuid(id)
49
+ url = url_encode(id)
50
+ visit "/#{url}"
51
+ page.should have_content('Query')
52
+ end
53
+ end
@@ -0,0 +1,228 @@
1
+ require 'spec_helper'
2
+
3
+ # Test BLAST module.
4
+ module SequenceServer
5
+ with_hits = Job.fetch('blast_2.6.0/blastn')
6
+ no_hits = Job.fetch('blast_2.6.0/blastn_nohits')
7
+
8
+ init
9
+
10
+ describe 'Report' do
11
+ hits_report = BLAST::Report.new(with_hits)
12
+ no_hits_report = BLAST::Report.new(no_hits)
13
+
14
+ it 'will return an Array of queries' do
15
+ hits_report.queries.should be_a Array
16
+ no_hits_report.queries.should be_a Array
17
+ end
18
+
19
+ it 'will return a Hash of stats' do
20
+ hits_report.stats.should be_a Hash
21
+ no_hits_report.stats.should be_a Hash
22
+ end
23
+
24
+ it 'contains all the necessary stats' do
25
+ hits_report.stats.length.should eql(7)
26
+ no_hits_report.stats.length.should eql(7)
27
+ end
28
+ end
29
+
30
+ describe 'Query' do
31
+ hits_report = BLAST::Report.new(with_hits)
32
+ no_hits_report = BLAST::Report.new(no_hits)
33
+
34
+ it 'will return queries with valid length' do
35
+ hits_report.queries.first.length.should be_a Fixnum
36
+ hits_report.queries.first.length.should satisfy { |n| n > 0 }
37
+ no_hits_report.queries.first.length.should be_a Fixnum
38
+ no_hits_report.queries.first.length.should satisfy { |n| n > 0 }
39
+ end
40
+
41
+ it 'will return an Array of hits' do
42
+ hits_report.queries.first.hits.should be_a Array
43
+ no_hits_report.queries.first.hits.should be_a Array
44
+ end
45
+ end
46
+
47
+ describe 'Hits' do
48
+ hits_report = BLAST::Report.new(with_hits)
49
+ no_hits_report = BLAST::Report.new(no_hits)
50
+
51
+ it 'will have non zero length' do
52
+ hits_report.queries.last.hits.first.length.should satisfy { |n| n > 0 }
53
+ end
54
+
55
+ it 'will return an Array of HSPs' do
56
+ hits_report.queries.first.hits.first.hsps.should be_a Array
57
+ end
58
+
59
+ it 'will return an Array with atleast one HSP' do
60
+ hits_report.queries.first.hits.first.hsps.length.should be >= 1
61
+ end
62
+
63
+ it 'will contain no element if no hits were obtained' do
64
+ no_hits_report.queries.first.hits.length.should eql(0)
65
+ end
66
+ end
67
+
68
+ # Test general features of HSPs. Algorithm specific customizations are
69
+ # tested separetly.
70
+ describe 'HSPs' do
71
+ hits_report = BLAST::Report.new(with_hits)
72
+
73
+ # Currently using all 17 HSP parameters in BLAST Report + 1 to refer to the
74
+ # hit object it belongs to.
75
+ it 'have all the necessary values' do
76
+ hits_report.queries.last.hits.first.hsps.last.count.should eql(19)
77
+ end
78
+
79
+ # Test Random HSPs to ensure that all the values from HSP struct are valid.
80
+ it 'have correct alignment values' do
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
83
+
84
+ hits_report.queries.first.hits.first.hsps.first.evalue.should be_a Float
85
+ hits_report.queries.first.hits.first.hsps.first.evalue
86
+ .should_not satisfy { |n| n < 0 }
87
+
88
+ hits_report.queries.first.hits.last.hsps.first.qstart.should be_a Fixnum
89
+ hits_report.queries.first.hits.last.hsps.first.qstart
90
+ .should_not satisfy { |n| n < 0 }
91
+
92
+ hits_report.queries.first.hits.last.hsps.first.qend.should be_a Fixnum
93
+ hits_report.queries.first.hits.last.hsps.first.qend
94
+ .should_not satisfy { |n| n < 0 }
95
+
96
+ hits_report.queries.last.hits.last.hsps.last.sstart.should be_a Fixnum
97
+ hits_report.queries.last.hits.last.hsps.last.sstart
98
+ .should_not satisfy { |n| n < 0 }
99
+
100
+ hits_report.queries.first.hits.first.hsps.last.send.should be_a Fixnum
101
+ hits_report.queries.first.hits.first.hsps.last.send
102
+ .should_not satisfy { |n| n < 0 }
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
106
+
107
+ hits_report.queries.first.hits.first.hsps.last.identity.should be_a Fixnum
108
+ hits_report.queries.first.hits.first.hsps.last.identity
109
+ .should_not satisfy { |n| n < 0 }
110
+
111
+ hits_report.queries.first.hits.first.hsps.last.gaps.should be_a Fixnum
112
+ hits_report.queries.first.hits.first.hsps.last.gaps
113
+ .should_not satisfy { |n| n < 0 }
114
+
115
+ hits_report.queries.first.hits.first.hsps.last.positives
116
+ .should be_a Fixnum
117
+ hits_report.queries.first.hits.first.hsps.last.positives
118
+ .should_not satisfy { |n| n < 0 }
119
+
120
+ hits_report.queries.first.hits.first.hsps.last.length.should be_a Fixnum
121
+ hits_report.queries.first.hits.first.hsps.last.length
122
+ .should satisfy { |n| n > 0 }
123
+
124
+ hits_report.queries.last.hits.last.hsps.first.qseq.should be_a String
125
+ hits_report.queries.last.hits.last.hsps.first.sseq.should be_a String
126
+ hits_report.queries.last.hits.last.hsps.first.midline.should be_a String
127
+ end
128
+
129
+ it 'have correctly matched query, hit and midline alignments' do
130
+ hsp = hits_report.queries.last.hits.last.hsps.first
131
+ hsp.qseq.length.should eql(hsp.sseq.length)
132
+ hsp.sseq.length.should eql(hsp.midline.length)
133
+ hsp.midline.length.should eql(hsp.qseq.length)
134
+ end
135
+ end
136
+
137
+ # Individually test different BLAST+ algorithms
138
+ #
139
+ describe 'BLASTN' do
140
+ let 'hsp' do
141
+ report = BLAST::Report.new(Job.fetch('blast_2.6.0/blastn'))
142
+ report.queries.first.hits.last.hsps.first
143
+ end
144
+
145
+ it 'have correct query and subject frame' do
146
+ [1, -1].should include(hsp.qframe)
147
+ [1, -1].should include(hsp.sframe)
148
+ end
149
+
150
+ it 'have correct qstart, qend, sstart, send' do
151
+ if hsp.sframe > 0
152
+ hsp.sstart.should be <= hsp.send
153
+ else
154
+ hsp.sstart.should be >= hsp.send
155
+ end
156
+ end
157
+ end
158
+
159
+ describe 'BLASTP' do
160
+ let 'hsp' do
161
+ report = BLAST::Report.new(Job.fetch('blast_2.6.0/blastp'))
162
+ report.queries.first.hits.last.hsps.first
163
+ end
164
+
165
+ it 'have correct query and subject frame' do
166
+ hsp.qframe.should eql(0)
167
+ hsp.sframe.should eql(0)
168
+ end
169
+
170
+ it 'have correct qstart, qend, sstart, send values' do
171
+ hsp.qstart.should be <= hsp.qend
172
+ hsp.sstart.should be <= hsp.send
173
+ end
174
+
175
+ end
176
+
177
+ describe 'BLASTX' do
178
+ let 'hsp' do
179
+ report = BLAST::Report.new(Job.fetch('blast_2.6.0/blastx'))
180
+
181
+ report.queries.first.hits.last.hsps.first
182
+ end
183
+
184
+ it 'have correct query and subject frame' do
185
+ hsp.qframe.should_not eql(0)
186
+ hsp.sframe.should eql(0)
187
+ end
188
+
189
+ it 'have correct qstart, qend, sstart, send' do
190
+ hsp.qstart.should be <= hsp.qend
191
+ hsp.sstart.should be <= hsp.send
192
+ end
193
+ end
194
+
195
+ describe 'TBLASTX' do
196
+ let 'hsp' do
197
+ report = BLAST::Report.new(Job.fetch('blast_2.6.0/tblastx'))
198
+ report.queries.first.hits.last.hsps.first
199
+ end
200
+
201
+ it 'have correct query and subject frame' do
202
+ hsp.qframe.should_not eql(0)
203
+ hsp.sframe.should_not eql(0)
204
+ end
205
+
206
+ it 'have correct qstart, qend, sstart, send' do
207
+ hsp.qstart.should be <= hsp.qend
208
+ hsp.sstart.should be <= hsp.send
209
+ end
210
+ end
211
+
212
+ describe 'TBLASTN' do
213
+ let 'hsp' do
214
+ report = BLAST::Report.new(Job.fetch('blast_2.6.0/tblastn'))
215
+ report.queries.first.hits.last.hsps.first
216
+ end
217
+
218
+ it 'have correct query and subject frame' do
219
+ hsp.qframe.should eql(0)
220
+ hsp.sframe.should_not eql(0)
221
+ end
222
+
223
+ it 'have correct qstart, qend, sstart, send' do
224
+ hsp.qstart.should be <= hsp.qend
225
+ hsp.sstart.should be <= hsp.send
226
+ end
227
+ end
228
+ end