sequenceserver 1.0.0.pre.5 → 1.0.0

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 (221) hide show
  1. checksums.yaml +4 -4
  2. data/.bootstrap/README.mkd +2 -0
  3. data/.bootstrap/config.json +416 -0
  4. data/.gitignore +56 -0
  5. data/.mailmap +5 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +51 -0
  8. data/.travis.yml +18 -0
  9. data/COPYRIGHT.txt +13 -0
  10. data/Gruntfile.js +133 -0
  11. data/LICENSE.txt +638 -46
  12. data/{LICENSE.Apache.txt → LICENSE/Apache.txt} +0 -0
  13. data/LICENSE/d3.txt +26 -0
  14. data/Rakefile +13 -0
  15. data/bin/sequenceserver +27 -4
  16. data/lib/sequenceserver.rb +26 -13
  17. data/lib/sequenceserver/database.rb +19 -8
  18. data/lib/sequenceserver/exceptions.rb +9 -1
  19. data/package.json +29 -0
  20. data/public/css/custom.css +10 -2
  21. data/public/dist/css/sequenceserver.min.css +1 -1
  22. data/public/dist/css/sequenceserver.min.css.gz +0 -0
  23. data/public/dist/js/sequenceserver.min.js +1 -1
  24. data/public/dist/js/sequenceserver.min.js.gz +0 -0
  25. data/public/js/jquery.t.js +2 -2
  26. data/public/js/sequence.js +4 -1
  27. data/public/js/sequenceserver.js +23 -20
  28. data/sequenceserver.gemspec +3 -6
  29. data/spec/blast_spec.rb +297 -0
  30. data/spec/capybara_spec.rb +51 -0
  31. data/spec/config_spec.rb +87 -0
  32. data/spec/database/funky_ids/funky_ids.fa +12 -0
  33. data/spec/database/funky_ids/funky_ids.fa.nhr +0 -0
  34. data/spec/database/funky_ids/funky_ids.fa.nin +0 -0
  35. data/spec/database/funky_ids/funky_ids.fa.nog +0 -0
  36. data/spec/database/funky_ids/funky_ids.fa.nsd +11 -0
  37. data/spec/database/funky_ids/funky_ids.fa.nsi +0 -0
  38. data/spec/database/funky_ids/funky_ids.fa.nsq +0 -0
  39. data/spec/database/sample/links.rb +23 -0
  40. data/spec/database/sample/proteins/Solenopsis_invicta/Sinvicta2-2-3.prot.subset.fasta +6449 -0
  41. data/spec/database/sample/proteins/Solenopsis_invicta/Sinvicta2-2-3.prot.subset.fasta.phr +0 -0
  42. data/spec/database/sample/proteins/Solenopsis_invicta/Sinvicta2-2-3.prot.subset.fasta.pin +0 -0
  43. data/spec/database/sample/proteins/Solenopsis_invicta/Sinvicta2-2-3.prot.subset.fasta.pog +0 -0
  44. data/spec/database/sample/proteins/Solenopsis_invicta/Sinvicta2-2-3.prot.subset.fasta.psd +2378 -0
  45. data/spec/database/sample/proteins/Solenopsis_invicta/Sinvicta2-2-3.prot.subset.fasta.psi +0 -0
  46. data/spec/database/sample/proteins/Solenopsis_invicta/Sinvicta2-2-3.prot.subset.fasta.psq +0 -0
  47. data/spec/database/sample/si_uniprot_idmap.yml +14180 -0
  48. data/spec/database/sample/transcripts/Solenopsis_invicta/Sinvicta2-2-3.cdna.subset.fasta +5486 -0
  49. data/spec/database/sample/transcripts/Solenopsis_invicta/Sinvicta2-2-3.cdna.subset.fasta.nhr +0 -0
  50. data/spec/database/sample/transcripts/Solenopsis_invicta/Sinvicta2-2-3.cdna.subset.fasta.nin +0 -0
  51. data/spec/database/sample/transcripts/Solenopsis_invicta/Sinvicta2-2-3.cdna.subset.fasta.nog +0 -0
  52. data/spec/database/sample/transcripts/Solenopsis_invicta/Sinvicta2-2-3.cdna.subset.fasta.nsd +946 -0
  53. data/spec/database/sample/transcripts/Solenopsis_invicta/Sinvicta2-2-3.cdna.subset.fasta.nsi +0 -0
  54. data/spec/database/sample/transcripts/Solenopsis_invicta/Sinvicta2-2-3.cdna.subset.fasta.nsq +0 -0
  55. data/spec/database/unformatted/Cardiocondyla_obscurior/Cobs1.4.proteins.fa +148303 -0
  56. data/spec/database/without_parse_seqids/without_parse_seqids.fa +10 -0
  57. data/spec/database/without_parse_seqids/without_parse_seqids.fa.phr +0 -0
  58. data/spec/database/without_parse_seqids/without_parse_seqids.fa.pin +0 -0
  59. data/spec/database/without_parse_seqids/without_parse_seqids.fa.psq +0 -0
  60. data/spec/database_spec.rb +129 -0
  61. data/spec/empty_config.yml +0 -0
  62. data/spec/routes_spec.rb +103 -0
  63. data/spec/sample.conf +2 -0
  64. data/spec/sample_reports/blastn_sample.asn +144 -0
  65. data/spec/sample_reports/blastp_sample.asn +1187 -0
  66. data/spec/sample_reports/blastx_sample.asn +1191 -0
  67. data/spec/sample_reports/no_hits_sample.asn +130 -0
  68. data/spec/sample_reports/tblastn_sample.asn +1107 -0
  69. data/spec/sample_reports/tblastx_sample.asn +2422 -0
  70. data/spec/sample_reports/with_hits_sample.asn +1489 -0
  71. data/spec/sequence_spec.rb +100 -0
  72. data/spec/sequenceserver_spec.rb +108 -0
  73. data/spec/spec_helper.rb +11 -0
  74. data/views/result.erb +55 -33
  75. data/views/search.erb +28 -23
  76. metadata +63 -151
  77. data/public/dist/js/webshims/shims/FlashCanvas/canvas2png.js +0 -1
  78. data/public/dist/js/webshims/shims/FlashCanvas/flashcanvas.js +0 -1
  79. data/public/dist/js/webshims/shims/FlashCanvas/flashcanvas.swf +0 -0
  80. data/public/dist/js/webshims/shims/FlashCanvasPro/canvas2png.js +0 -1
  81. data/public/dist/js/webshims/shims/FlashCanvasPro/flash10canvas.swf +0 -0
  82. data/public/dist/js/webshims/shims/FlashCanvasPro/flash9canvas.swf +0 -0
  83. data/public/dist/js/webshims/shims/FlashCanvasPro/flashcanvas.js +0 -1
  84. data/public/dist/js/webshims/shims/canvas-blob.js +0 -1
  85. data/public/dist/js/webshims/shims/color-picker.js +0 -2
  86. data/public/dist/js/webshims/shims/combos/1.js +0 -6
  87. data/public/dist/js/webshims/shims/combos/10.js +0 -2
  88. data/public/dist/js/webshims/shims/combos/11.js +0 -2
  89. data/public/dist/js/webshims/shims/combos/12.js +0 -6
  90. data/public/dist/js/webshims/shims/combos/13.js +0 -1
  91. data/public/dist/js/webshims/shims/combos/14.js +0 -1
  92. data/public/dist/js/webshims/shims/combos/15.js +0 -2
  93. data/public/dist/js/webshims/shims/combos/16.js +0 -7
  94. data/public/dist/js/webshims/shims/combos/17.js +0 -2
  95. data/public/dist/js/webshims/shims/combos/18.js +0 -3
  96. data/public/dist/js/webshims/shims/combos/2.js +0 -7
  97. data/public/dist/js/webshims/shims/combos/21.js +0 -2
  98. data/public/dist/js/webshims/shims/combos/22.js +0 -1
  99. data/public/dist/js/webshims/shims/combos/23.js +0 -6
  100. data/public/dist/js/webshims/shims/combos/25.js +0 -2
  101. data/public/dist/js/webshims/shims/combos/27.js +0 -1
  102. data/public/dist/js/webshims/shims/combos/28.js +0 -1
  103. data/public/dist/js/webshims/shims/combos/29.js +0 -1
  104. data/public/dist/js/webshims/shims/combos/3.js +0 -1
  105. data/public/dist/js/webshims/shims/combos/30.js +0 -2
  106. data/public/dist/js/webshims/shims/combos/31.js +0 -1
  107. data/public/dist/js/webshims/shims/combos/33.js +0 -1
  108. data/public/dist/js/webshims/shims/combos/34.js +0 -1
  109. data/public/dist/js/webshims/shims/combos/4.js +0 -1
  110. data/public/dist/js/webshims/shims/combos/5.js +0 -2
  111. data/public/dist/js/webshims/shims/combos/6.js +0 -2
  112. data/public/dist/js/webshims/shims/combos/7.js +0 -7
  113. data/public/dist/js/webshims/shims/combos/8.js +0 -7
  114. data/public/dist/js/webshims/shims/combos/9.js +0 -2
  115. data/public/dist/js/webshims/shims/combos/97.js +0 -1
  116. data/public/dist/js/webshims/shims/combos/98.js +0 -1
  117. data/public/dist/js/webshims/shims/combos/99.js +0 -1
  118. data/public/dist/js/webshims/shims/details.js +0 -1
  119. data/public/dist/js/webshims/shims/dom-extend.js +0 -1
  120. data/public/dist/js/webshims/shims/es5.js +0 -1
  121. data/public/dist/js/webshims/shims/es6.js +0 -1
  122. data/public/dist/js/webshims/shims/excanvas.js +0 -1
  123. data/public/dist/js/webshims/shims/filereader-xhr.js +0 -1
  124. data/public/dist/js/webshims/shims/form-combat.js +0 -1
  125. data/public/dist/js/webshims/shims/form-core.js +0 -1
  126. data/public/dist/js/webshims/shims/form-datalist-lazy.js +0 -1
  127. data/public/dist/js/webshims/shims/form-datalist.js +0 -1
  128. data/public/dist/js/webshims/shims/form-fixrangechange.js +0 -1
  129. data/public/dist/js/webshims/shims/form-inputmode.js +0 -1
  130. data/public/dist/js/webshims/shims/form-message.js +0 -1
  131. data/public/dist/js/webshims/shims/form-native-extend.js +0 -1
  132. data/public/dist/js/webshims/shims/form-number-date-api.js +0 -1
  133. data/public/dist/js/webshims/shims/form-number-date-ui.js +0 -1
  134. data/public/dist/js/webshims/shims/form-shim-extend.js +0 -1
  135. data/public/dist/js/webshims/shims/form-shim-extend2.js +0 -1
  136. data/public/dist/js/webshims/shims/form-validation.js +0 -1
  137. data/public/dist/js/webshims/shims/form-validators.js +0 -1
  138. data/public/dist/js/webshims/shims/forms-picker.js +0 -1
  139. data/public/dist/js/webshims/shims/geolocation.js +0 -1
  140. data/public/dist/js/webshims/shims/i18n/formcfg-ar.js +0 -1
  141. data/public/dist/js/webshims/shims/i18n/formcfg-ch-CN.js +0 -1
  142. data/public/dist/js/webshims/shims/i18n/formcfg-cs.js +0 -1
  143. data/public/dist/js/webshims/shims/i18n/formcfg-de.js +0 -1
  144. data/public/dist/js/webshims/shims/i18n/formcfg-el.js +0 -1
  145. data/public/dist/js/webshims/shims/i18n/formcfg-en.js +0 -1
  146. data/public/dist/js/webshims/shims/i18n/formcfg-es.js +0 -1
  147. data/public/dist/js/webshims/shims/i18n/formcfg-fa.js +0 -1
  148. data/public/dist/js/webshims/shims/i18n/formcfg-fr.js +0 -1
  149. data/public/dist/js/webshims/shims/i18n/formcfg-he.js +0 -1
  150. data/public/dist/js/webshims/shims/i18n/formcfg-hi.js +0 -1
  151. data/public/dist/js/webshims/shims/i18n/formcfg-hu.js +0 -1
  152. data/public/dist/js/webshims/shims/i18n/formcfg-it.js +0 -1
  153. data/public/dist/js/webshims/shims/i18n/formcfg-ja.js +0 -1
  154. data/public/dist/js/webshims/shims/i18n/formcfg-lt.js +0 -1
  155. data/public/dist/js/webshims/shims/i18n/formcfg-nl.js +0 -1
  156. data/public/dist/js/webshims/shims/i18n/formcfg-pl.js +0 -1
  157. data/public/dist/js/webshims/shims/i18n/formcfg-pt-BR.js +0 -1
  158. data/public/dist/js/webshims/shims/i18n/formcfg-pt-PT.js +0 -1
  159. data/public/dist/js/webshims/shims/i18n/formcfg-pt.js +0 -1
  160. data/public/dist/js/webshims/shims/i18n/formcfg-ru.js +0 -1
  161. data/public/dist/js/webshims/shims/i18n/formcfg-sv.js +0 -1
  162. data/public/dist/js/webshims/shims/i18n/formcfg-zh-CN.js +0 -1
  163. data/public/dist/js/webshims/shims/i18n/formcfg-zh-TW.js +0 -1
  164. data/public/dist/js/webshims/shims/jme/alternate-media.js +0 -1
  165. data/public/dist/js/webshims/shims/jme/base.js +0 -1
  166. data/public/dist/js/webshims/shims/jme/controls.css +0 -1
  167. data/public/dist/js/webshims/shims/jme/jme.eot +0 -0
  168. data/public/dist/js/webshims/shims/jme/jme.svg +0 -36
  169. data/public/dist/js/webshims/shims/jme/jme.ttf +0 -0
  170. data/public/dist/js/webshims/shims/jme/jme.woff +0 -0
  171. data/public/dist/js/webshims/shims/jme/mediacontrols-lazy.js +0 -1
  172. data/public/dist/js/webshims/shims/jme/mediacontrols.js +0 -1
  173. data/public/dist/js/webshims/shims/jme/playlist.js +0 -1
  174. data/public/dist/js/webshims/shims/jpicker/images/AlphaBar.png +0 -0
  175. data/public/dist/js/webshims/shims/jpicker/images/Bars.png +0 -0
  176. data/public/dist/js/webshims/shims/jpicker/images/Maps.png +0 -0
  177. data/public/dist/js/webshims/shims/jpicker/images/NoColor.png +0 -0
  178. data/public/dist/js/webshims/shims/jpicker/images/bar-opacity.png +0 -0
  179. data/public/dist/js/webshims/shims/jpicker/images/map-opacity.png +0 -0
  180. data/public/dist/js/webshims/shims/jpicker/images/mappoint.gif +0 -0
  181. data/public/dist/js/webshims/shims/jpicker/images/picker.gif +0 -0
  182. data/public/dist/js/webshims/shims/jpicker/images/preview-opacity.png +0 -0
  183. data/public/dist/js/webshims/shims/jpicker/images/rangearrows.gif +0 -0
  184. data/public/dist/js/webshims/shims/jpicker/jpicker.css +0 -1
  185. data/public/dist/js/webshims/shims/matchMedia.js +0 -3
  186. data/public/dist/js/webshims/shims/mediacapture-picker.js +0 -1
  187. data/public/dist/js/webshims/shims/mediacapture.js +0 -1
  188. data/public/dist/js/webshims/shims/mediaelement-core.js +0 -1
  189. data/public/dist/js/webshims/shims/mediaelement-debug.js +0 -1
  190. data/public/dist/js/webshims/shims/mediaelement-jaris.js +0 -1
  191. data/public/dist/js/webshims/shims/mediaelement-native-fix.js +0 -1
  192. data/public/dist/js/webshims/shims/mediaelement-yt.js +0 -1
  193. data/public/dist/js/webshims/shims/moxie/flash/Moxie.cdn.swf +0 -0
  194. data/public/dist/js/webshims/shims/moxie/flash/Moxie.min.swf +0 -0
  195. data/public/dist/js/webshims/shims/moxie/js/moxie-html4.js +0 -3
  196. data/public/dist/js/webshims/shims/moxie/js/moxie-swf.js +0 -2
  197. data/public/dist/js/webshims/shims/picture.js +0 -1
  198. data/public/dist/js/webshims/shims/plugins/jquery.ui.position.js +0 -11
  199. data/public/dist/js/webshims/shims/range-ui.js +0 -1
  200. data/public/dist/js/webshims/shims/sizzle.js +0 -11
  201. data/public/dist/js/webshims/shims/sticky.js +0 -1
  202. data/public/dist/js/webshims/shims/styles/color-picker.png +0 -0
  203. data/public/dist/js/webshims/shims/styles/forms-ext.css +0 -1
  204. data/public/dist/js/webshims/shims/styles/forms-picker.css +0 -1
  205. data/public/dist/js/webshims/shims/styles/progress.gif +0 -0
  206. data/public/dist/js/webshims/shims/styles/progress.png +0 -0
  207. data/public/dist/js/webshims/shims/styles/shim-ext.css +0 -1
  208. data/public/dist/js/webshims/shims/styles/shim.css +0 -1
  209. data/public/dist/js/webshims/shims/styles/transparent.png +0 -0
  210. data/public/dist/js/webshims/shims/styles/widget.eot +0 -0
  211. data/public/dist/js/webshims/shims/styles/widget.svg +0 -12
  212. data/public/dist/js/webshims/shims/styles/widget.ttf +0 -0
  213. data/public/dist/js/webshims/shims/styles/widget.woff +0 -0
  214. data/public/dist/js/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
  215. data/public/dist/js/webshims/shims/swfmini-embed.js +0 -1
  216. data/public/dist/js/webshims/shims/swfmini.js +0 -6
  217. data/public/dist/js/webshims/shims/track-ui.js +0 -1
  218. data/public/dist/js/webshims/shims/track.js +0 -1
  219. data/public/dist/js/webshims/shims/url.js +0 -1
  220. data/public/dist/js/webshims/shims/usermedia-core.js +0 -1
  221. data/public/dist/js/webshims/shims/usermedia-shim.js +0 -1
@@ -0,0 +1,297 @@
1
+ require 'spec_helper'
2
+
3
+ # Test BLAST module.
4
+ module SequenceServer
5
+ sample_reports = File.join(SequenceServer.root, 'spec', 'sample_reports')
6
+
7
+ with_hits = File.join(sample_reports, 'with_hits_sample.asn')
8
+ no_hits = File.join(sample_reports, 'no_hits_sample.asn')
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(18)
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
+
136
+ it 'have correct pretty printing' do
137
+ hsp = hits_report.queries.last.hits.last.hsps.first
138
+ pp = hsp.pp
139
+
140
+ pp.should_not be_empty
141
+ pp.should be_a_kind_of(String)
142
+ (pp.lines.count % 3).should eql(0)
143
+
144
+ pp.should match(/^Query/)
145
+ pp.should match(/Subject/)
146
+ end
147
+
148
+ it 'have relevant stats' do
149
+ hsp = hits_report.queries.last.hits.last.hsps.last
150
+ stats = hsp.stats
151
+
152
+ stats.size.should be >= 4
153
+ stats.should include('Score', 'E value', 'Identities', 'Gaps')
154
+
155
+ stats['Score'].should be_a Array
156
+ stats['Identities'].should be_a Array
157
+ stats['Gaps'].should be_a Array
158
+ end
159
+ end
160
+
161
+ # Individually test different BLAST+ algorithms
162
+ #
163
+ describe 'BLASTN' do
164
+ let 'hsp' do
165
+ report = BLAST::Report.new(File.join(sample_reports,
166
+ 'blastn_sample.asn'))
167
+ report.queries.first.hits.last.hsps.first
168
+ end
169
+
170
+ it 'have correct query and subject frame' do
171
+ [1, -1].should include(hsp.qframe)
172
+ [1, -1].should include(hsp.sframe)
173
+
174
+ hsp.qframe_unit.should eq(1)
175
+ hsp.sframe_unit.should eq(1)
176
+ end
177
+
178
+ it 'have correct qstart, qend, sstart, send' do
179
+ if hsp.sframe > 0
180
+ hsp.sstart.should be <= hsp.send
181
+ else
182
+ hsp.sstart.should be >= hsp.send
183
+ end
184
+ end
185
+
186
+ it 'have relevant stats' do
187
+ hsp.stats.size.should eq(5)
188
+ hsp.stats.should include('Strand')
189
+ end
190
+ end
191
+
192
+ describe 'BLASTP' do
193
+ let 'hsp' do
194
+ report = BLAST::Report.new(File.join(sample_reports,
195
+ 'blastp_sample.asn'))
196
+ report.queries.first.hits.last.hsps.first
197
+ end
198
+
199
+ it 'have correct query and subject frame' do
200
+ hsp.qframe.should eql(0)
201
+ hsp.sframe.should eql(0)
202
+
203
+ hsp.qframe_unit.should eq(1)
204
+ hsp.sframe_unit.should eq(1)
205
+ end
206
+
207
+ it 'have correct qstart, qend, sstart, send values' do
208
+ hsp.qstart.should be <= hsp.qend
209
+ hsp.sstart.should be <= hsp.send
210
+ end
211
+
212
+ it 'have relevant stats' do
213
+ hsp.stats.size.should eq(5)
214
+ hsp.stats.should include('Positives')
215
+ end
216
+ end
217
+
218
+ describe 'BLASTX' do
219
+ let 'hsp' do
220
+ report = BLAST::Report.new(File.join(sample_reports,
221
+ 'blastx_sample.asn'))
222
+
223
+ report.queries.first.hits.last.hsps.first
224
+ end
225
+
226
+ it 'have correct query and subject frame' do
227
+ hsp.qframe.should_not eql(0)
228
+ hsp.sframe.should eql(0)
229
+
230
+ hsp.qframe_unit.should eq(3)
231
+ hsp.sframe_unit.should eq(1)
232
+ end
233
+
234
+ it 'have correct qstart, qend, sstart, send' do
235
+ hsp.qstart.should be <= hsp.qend
236
+ hsp.sstart.should be <= hsp.send
237
+ end
238
+
239
+ it 'have relevant stats' do
240
+ hsp.stats.size.should eq(5)
241
+ hsp.stats.should include('Query frame')
242
+ end
243
+ end
244
+
245
+ describe 'TBLASTX' do
246
+ let 'hsp' do
247
+ report = BLAST::Report.new(File.join(sample_reports,
248
+ 'tblastx_sample.asn'))
249
+ report.queries.first.hits.last.hsps.first
250
+ end
251
+
252
+ it 'have correct query and subject frame' do
253
+ hsp.qframe.should_not eql(0)
254
+ hsp.sframe.should_not eql(0)
255
+
256
+ hsp.qframe_unit.should eq(3)
257
+ hsp.sframe_unit.should eq(3)
258
+ end
259
+
260
+ it 'have correct qstart, qend, sstart, send' do
261
+ hsp.qstart.should be <= hsp.qend
262
+ hsp.sstart.should be <= hsp.send
263
+ end
264
+
265
+ it 'have relevant stats' do
266
+ hsp.stats.size.should eq(6)
267
+ hsp.stats.should include('Frame')
268
+ hsp.stats.should include('Positives')
269
+ end
270
+ end
271
+
272
+ describe 'TBLASTN' do
273
+ let 'hsp' do
274
+ report = BLAST::Report.new(File.join(sample_reports,
275
+ 'tblastn_sample.asn'))
276
+ report.queries.first.hits.last.hsps.first
277
+ end
278
+
279
+ it 'have correct query and subject frame' do
280
+ hsp.qframe.should eql(0)
281
+ hsp.sframe.should_not eql(0)
282
+
283
+ hsp.qframe_unit.should eq(1)
284
+ hsp.sframe_unit.should eq(3)
285
+ end
286
+
287
+ it 'have correct qstart, qend, sstart, send' do
288
+ hsp.qstart.should be <= hsp.qend
289
+ hsp.sstart.should be <= hsp.send
290
+ end
291
+
292
+ it 'have relevant stats' do
293
+ hsp.stats.size.should eq(5)
294
+ hsp.stats.should include('Hit frame')
295
+ end
296
+ end
297
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+ require 'capybara/rspec'
3
+ require 'capybara-webkit'
4
+
5
+ describe 'a browser', :js => true do
6
+ sequence = 'ATCGATCAGCTACGATCAGCATCGACTAGCATCGACTACGA'
7
+ sample_nucl_db = 'Sinvicta2-2-3.cdna.subset.fasta'
8
+ # sample_prot_db = 'Sinvicta2-2-3.prot'
9
+
10
+ before(:all) do
11
+ Capybara.javascript_driver = :webkit
12
+ Capybara.default_wait_time = 5
13
+
14
+ options = { :database_dir => SequenceServer.root }
15
+ Capybara.app = SequenceServer.init(options)
16
+ end
17
+
18
+ it 'runs a simple blastn search' do
19
+ visit '/'
20
+ fill_in('sequence', :with => sequence)
21
+ check(sample_nucl_db)
22
+ click_button('method')
23
+ page.should have_content('Query')
24
+ end
25
+
26
+ it 'properly controls blast button' do
27
+ visit '/'
28
+
29
+ fill_in('sequence', :with => sequence)
30
+ page.evaluate_script("$('#method').is(':disabled')").should eq(true)
31
+
32
+ check(sample_nucl_db)
33
+ page.evaluate_script("$('#method').is(':disabled')").should eq(false)
34
+ end
35
+
36
+ it 'properly controls interaction with database listing' do
37
+ visit '/'
38
+ fill_in('sequence', :with => sequence)
39
+ check(sample_nucl_db)
40
+ page.evaluate_script("$('.protein .checkbox').first().hasClass('disabled')")
41
+ .should eq(true)
42
+ end
43
+
44
+ it 'shows a dropdown menu when other blast methods are available' do
45
+ visit '/'
46
+ fill_in('sequence', :with => sequence)
47
+ check(sample_nucl_db)
48
+ page.save_screenshot('screenshot.png')
49
+ page.has_css?('button.dropdown-toggle').should eq(true)
50
+ end
51
+ end
@@ -0,0 +1,87 @@
1
+ require 'spec_helper'
2
+ require 'sequenceserver/config'
3
+
4
+ # Test Config class.
5
+ module SequenceServer
6
+ describe 'Config' do
7
+ let 'sample_config_file' do
8
+ File.join(SequenceServer.root, 'spec', 'sample.conf')
9
+ end
10
+
11
+ it 'behaves like a Hash' do
12
+ config = Config.new
13
+
14
+ config.should respond_to :[]
15
+ config.should respond_to :[]=
16
+ config.should respond_to :include?
17
+
18
+ config[:key] = 'value'
19
+ config[:key].should eq 'value'
20
+ config.include?(:key).should be_truthy
21
+ end
22
+
23
+ it 'has reasonable defaults' do
24
+ config = Config.new
25
+ config[:num_threads].should eq 1
26
+ config[:host].should eq '0.0.0.0'
27
+ config[:port].should eq 4567
28
+ config.config_file.should eq File.expand_path('~/.sequenceserver.conf')
29
+ end
30
+
31
+ it 'symbolizes keys' do
32
+ config = Config.new('key' => 'value')
33
+ config.include?('key').should be_falsey
34
+ config.include?(:key).should be_truthy
35
+ config[:key].should eq 'value'
36
+
37
+ config = Config.new(:config_file => sample_config_file)
38
+ config.include?('num_threads').should be_falsey
39
+ config.include?(:num_threads).should be_truthy
40
+ end
41
+
42
+ it 'changes database key, if present, to database_dir' do
43
+ # Does so for data Hash passed to Config.new.
44
+ config = Config.new(:database => 'database_dir')
45
+ config.include?(:database).should be_falsey
46
+ config[:database_dir].should eq 'database_dir'
47
+
48
+ # Does so for data parsed from config_file.
49
+ config = Config.new(:config_file => sample_config_file)
50
+ config.include?(:database).should be_falsey
51
+ config[:database_dir].should eq 'database_dir'
52
+
53
+ # If both database and database_dir key are present, database key is
54
+ # removed and database_dir key takes preecedence.
55
+ config = Config.new(:database => 'database',
56
+ :database_dir => 'database_dir')
57
+ config.include?(:database).should be_falsey
58
+ config[:database_dir].should eq 'database_dir'
59
+ end
60
+
61
+ it 'parses config_file and merges with defaults, values from config_file' \
62
+ 'taking preecedence' do
63
+ config = Config.new(:config_file => sample_config_file)
64
+
65
+ # config_file key becomes config.config_file
66
+ config.include?(:config_file).should be_falsey
67
+ config.config_file.should eq sample_config_file
68
+
69
+ # First check that a default value is present. Then check that a value
70
+ # from config file is present.
71
+ #
72
+ # We use num_threads key from config_file to test. The default value of
73
+ # num_threads is 1, but is set to 10 in config_file. If the final value
74
+ # is 10, we have ensured that config_file takes preecedence over
75
+ # default values.
76
+ config[:port].should eq 4567
77
+ config[:num_threads].should eq 10
78
+ end
79
+
80
+ it 'merges arguments with defaults and values from config_file,' \
81
+ 'arguments taking preecedence' do
82
+ config = Config.new(:config_file => sample_config_file,
83
+ :num_threads => 20)
84
+ config[:num_threads].should eq 20
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,12 @@
1
+ >abc|def
2
+ GATGAACGCTGGCGGCGTGCCTAATACATGCAAGTCGAG
3
+ >abcdef#
4
+ GATGAACGCTGGCGGCGTGCCTAATACATGCAAGTCGAG
5
+ >abc#def
6
+ GATGAACGCTGGCGGCGTGCCTAATACATGCAAGTCGAG
7
+ >123#456
8
+ GATGAACGCTGGCGGCGTGCCTAATACATGCAAGTCGAG
9
+ >123456#
10
+ GATGAACGCTGGCGGCGTGCCTAATACATGCAAGTCGAG
11
+ >123456
12
+ GATGAACGCTGGCGGCGTGCCTAATACATGCAAGTCGAG