quorum 0.1.0 → 0.2.0

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 (48) hide show
  1. data/Gemfile.lock +82 -74
  2. data/HISTORY.md +9 -0
  3. data/README.rdoc +101 -23
  4. data/app/assets/javascripts/quorum/jobs.js +45 -3
  5. data/app/controllers/quorum/jobs_controller.rb +47 -2
  6. data/app/models/quorum/job.rb +52 -9
  7. data/app/views/quorum/jobs/new.html.erb +7 -6
  8. data/app/views/quorum/jobs/show.html.erb +7 -118
  9. data/app/views/quorum/jobs/templates/_blast_detailed_report_template.html.erb +53 -0
  10. data/app/views/quorum/jobs/templates/_blast_template.html.erb +68 -0
  11. data/config/routes.rb +2 -0
  12. data/db/migrate/20120109232446_add_hit_display_id_to_blast_reports.rb +8 -0
  13. data/lib/generators/quorum/images_generator.rb +18 -0
  14. data/lib/generators/quorum/install_generator.rb +41 -13
  15. data/lib/generators/templates/README +1 -1
  16. data/lib/generators/templates/blast.rb +18 -7
  17. data/lib/generators/templates/blast_db.rb +106 -0
  18. data/lib/generators/templates/fetch +115 -0
  19. data/lib/generators/templates/quorum_initializer.rb +1 -1
  20. data/lib/generators/templates/quorum_settings.yml +4 -4
  21. data/lib/quorum/helpers.rb +71 -1
  22. data/lib/quorum/version.rb +1 -1
  23. data/lib/quorum.rb +15 -5
  24. data/lib/workers/quorum.rb +12 -2
  25. data/quorum.gemspec +4 -2
  26. data/spec/data/seqs_not_fa.txt +16 -16
  27. data/spec/dummy/config/initializers/quorum_initializer.rb +1 -1
  28. data/spec/dummy/config/initializers/resque.rb +4 -1
  29. data/spec/dummy/config/quorum_settings.yml +4 -4
  30. data/spec/dummy/db/schema.rb +8 -1
  31. data/spec/dummy/quorum/bin/fetch +115 -0
  32. data/spec/dummy/quorum/blastdb/test.nin +0 -0
  33. data/spec/dummy/quorum/blastdb/test.pin +0 -0
  34. data/spec/dummy/quorum/lib/fetch_tools/blast_db.rb +106 -0
  35. data/spec/dummy/quorum/lib/search_tools/blast.rb +18 -7
  36. data/spec/models/job_spec.rb +3 -4
  37. data/spec/quorum_installed_spec.rb +5 -0
  38. data/spec/requests/jobs_spec.rb +14 -1
  39. data/spec/spec_helper.rb +32 -1
  40. data/spec/support/streams.rb +16 -0
  41. data/spec/templates/blast_db_spec.rb +63 -0
  42. data/spec/templates/blast_spec.rb +108 -2
  43. metadata +64 -37
  44. /data/app/assets/images/quorum/{knight_rider.gif → loading.gif} +0 -0
  45. /data/app/views/quorum/jobs/{_blastn_form.html.erb → form/_blastn_form.html.erb} +0 -0
  46. /data/app/views/quorum/jobs/{_blastp_form.html.erb → form/_blastp_form.html.erb} +0 -0
  47. /data/app/views/quorum/jobs/{_blastx_form.html.erb → form/_blastx_form.html.erb} +0 -0
  48. /data/app/views/quorum/jobs/{_tblastn_form.html.erb → form/_tblastn_form.html.erb} +0 -0
data/Gemfile.lock CHANGED
@@ -1,116 +1,116 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- quorum (0.1.0)
4
+ quorum (0.2.0)
5
5
  bio-blastxmlparser (~> 1.0.1)
6
6
  jquery-rails
7
7
  net-ssh (~> 2.2.1)
8
8
  rails (~> 3.1.0)
9
9
  resque (~> 1.19.0)
10
+ resque-result (~> 1.0.1)
10
11
 
11
12
  GEM
12
13
  remote: http://rubygems.org/
13
14
  specs:
14
- actionmailer (3.1.0)
15
- actionpack (= 3.1.0)
15
+ actionmailer (3.1.3)
16
+ actionpack (= 3.1.3)
16
17
  mail (~> 2.3.0)
17
- actionpack (3.1.0)
18
- activemodel (= 3.1.0)
19
- activesupport (= 3.1.0)
18
+ actionpack (3.1.3)
19
+ activemodel (= 3.1.3)
20
+ activesupport (= 3.1.3)
20
21
  builder (~> 3.0.0)
21
22
  erubis (~> 2.7.0)
22
23
  i18n (~> 0.6)
23
- rack (~> 1.3.2)
24
- rack-cache (~> 1.0.3)
24
+ rack (~> 1.3.5)
25
+ rack-cache (~> 1.1)
25
26
  rack-mount (~> 0.8.2)
26
27
  rack-test (~> 0.6.1)
27
- sprockets (~> 2.0.0)
28
- activemodel (3.1.0)
29
- activesupport (= 3.1.0)
30
- bcrypt-ruby (~> 3.0.0)
28
+ sprockets (~> 2.0.3)
29
+ activemodel (3.1.3)
30
+ activesupport (= 3.1.3)
31
31
  builder (~> 3.0.0)
32
32
  i18n (~> 0.6)
33
- activerecord (3.1.0)
34
- activemodel (= 3.1.0)
35
- activesupport (= 3.1.0)
33
+ activerecord (3.1.3)
34
+ activemodel (= 3.1.3)
35
+ activesupport (= 3.1.3)
36
36
  arel (~> 2.2.1)
37
37
  tzinfo (~> 0.3.29)
38
- activeresource (3.1.0)
39
- activemodel (= 3.1.0)
40
- activesupport (= 3.1.0)
41
- activesupport (3.1.0)
38
+ activeresource (3.1.3)
39
+ activemodel (= 3.1.3)
40
+ activesupport (= 3.1.3)
41
+ activesupport (3.1.3)
42
42
  multi_json (~> 1.0)
43
43
  arel (2.2.1)
44
- bcrypt-ruby (3.0.0)
45
44
  bio-blastxmlparser (1.0.1)
46
45
  bio-logger (>= 1.0.0)
47
46
  nokogiri (>= 1.5.0)
48
47
  bio-logger (1.0.0)
49
48
  log4r (>= 1.1.9)
50
49
  builder (3.0.0)
51
- capybara (1.1.1)
50
+ capybara (1.1.2)
52
51
  mime-types (>= 1.16)
53
52
  nokogiri (>= 1.3.3)
54
53
  rack (>= 1.0.0)
55
54
  rack-test (>= 0.5.4)
56
55
  selenium-webdriver (~> 2.0)
57
56
  xpath (~> 0.1.4)
58
- childprocess (0.2.2)
57
+ childprocess (0.3.0)
59
58
  ffi (~> 1.0.6)
60
59
  database_cleaner (0.6.7)
61
60
  diff-lcs (1.1.3)
62
61
  erubis (2.7.0)
63
- factory_girl (2.1.0)
62
+ factory_girl (2.1.2)
63
+ activesupport
64
64
  factory_girl_rails (1.2.0)
65
65
  factory_girl (~> 2.1.0)
66
66
  railties (>= 3.0.0)
67
- ffi (1.0.9)
67
+ ffi (1.0.11)
68
68
  hike (1.2.1)
69
69
  i18n (0.6.0)
70
- jquery-rails (1.0.16)
70
+ jquery-rails (1.0.19)
71
71
  railties (~> 3.0)
72
72
  thor (~> 0.14)
73
- json_pure (1.5.4)
74
- spruz (~> 0.2.8)
75
- log4r (1.1.9)
73
+ json (1.6.5)
74
+ log4r (1.1.10)
76
75
  mail (2.3.0)
77
76
  i18n (>= 0.4.0)
78
77
  mime-types (~> 1.16)
79
78
  treetop (~> 1.4.8)
80
- mime-types (1.16)
81
- multi_json (1.0.3)
82
- mysql2 (0.3.7)
83
- net-ssh (2.2.1)
79
+ mime-types (1.17.2)
80
+ multi_json (1.0.4)
81
+ mysql2 (0.3.11)
82
+ net-ssh (2.2.2)
84
83
  nokogiri (1.5.0)
85
- polyglot (0.3.2)
86
- rack (1.3.2)
87
- rack-cache (1.0.3)
84
+ polyglot (0.3.3)
85
+ rack (1.3.6)
86
+ rack-cache (1.1)
88
87
  rack (>= 0.4)
89
88
  rack-mount (0.8.3)
90
89
  rack (>= 1.0.0)
91
- rack-protection (1.1.4)
90
+ rack-protection (1.2.0)
92
91
  rack
93
92
  rack-ssl (1.3.2)
94
93
  rack
95
94
  rack-test (0.6.1)
96
95
  rack (>= 1.0)
97
- rails (3.1.0)
98
- actionmailer (= 3.1.0)
99
- actionpack (= 3.1.0)
100
- activerecord (= 3.1.0)
101
- activeresource (= 3.1.0)
102
- activesupport (= 3.1.0)
96
+ rails (3.1.3)
97
+ actionmailer (= 3.1.3)
98
+ actionpack (= 3.1.3)
99
+ activerecord (= 3.1.3)
100
+ activeresource (= 3.1.3)
101
+ activesupport (= 3.1.3)
103
102
  bundler (~> 1.0)
104
- railties (= 3.1.0)
105
- railties (3.1.0)
106
- actionpack (= 3.1.0)
107
- activesupport (= 3.1.0)
103
+ railties (= 3.1.3)
104
+ railties (3.1.3)
105
+ actionpack (= 3.1.3)
106
+ activesupport (= 3.1.3)
108
107
  rack-ssl (~> 1.3.2)
109
108
  rake (>= 0.8.7)
110
109
  rdoc (~> 3.4)
111
110
  thor (~> 0.14.6)
112
- rake (0.9.2)
113
- rdoc (3.9.4)
111
+ rake (0.9.2.2)
112
+ rdoc (3.12)
113
+ json (~> 1.4)
114
114
  redis (2.2.2)
115
115
  redis-namespace (1.0.3)
116
116
  redis (< 3.0.0)
@@ -119,40 +119,47 @@ GEM
119
119
  redis-namespace (~> 1.0.2)
120
120
  sinatra (>= 0.9.2)
121
121
  vegas (~> 0.1.2)
122
- rspec (2.6.0)
123
- rspec-core (~> 2.6.0)
124
- rspec-expectations (~> 2.6.0)
125
- rspec-mocks (~> 2.6.0)
126
- rspec-core (2.6.4)
127
- rspec-expectations (2.6.0)
122
+ resque-meta (1.0.3)
123
+ resque (~> 1.8)
124
+ resque-result (1.0.1)
125
+ resque (~> 1.9)
126
+ resque-meta (~> 1.0)
127
+ resque_spec (0.8.1)
128
+ resque (>= 1.19.0)
129
+ rspec (>= 2.5.0)
130
+ rspec (2.8.0)
131
+ rspec-core (~> 2.8.0)
132
+ rspec-expectations (~> 2.8.0)
133
+ rspec-mocks (~> 2.8.0)
134
+ rspec-core (2.8.0)
135
+ rspec-expectations (2.8.0)
128
136
  diff-lcs (~> 1.1.2)
129
- rspec-mocks (2.6.0)
130
- rspec-rails (2.6.1)
131
- actionpack (~> 3.0)
132
- activesupport (~> 3.0)
133
- railties (~> 3.0)
134
- rspec (~> 2.6.0)
135
- rubyzip (0.9.4)
136
- selenium-webdriver (2.5.0)
137
- childprocess (>= 0.2.1)
138
- ffi (>= 1.0.7)
139
- json_pure
137
+ rspec-mocks (2.8.0)
138
+ rspec-rails (2.8.1)
139
+ actionpack (>= 3.0)
140
+ activesupport (>= 3.0)
141
+ railties (>= 3.0)
142
+ rspec (~> 2.8.0)
143
+ rubyzip (0.9.5)
144
+ selenium-webdriver (2.17.0)
145
+ childprocess (>= 0.2.5)
146
+ ffi (~> 1.0.9)
147
+ multi_json (~> 1.0.4)
140
148
  rubyzip
141
- sinatra (1.3.0)
142
- rack (~> 1.3)
143
- rack-protection (~> 1.1)
144
- tilt (~> 1.3)
145
- sprockets (2.0.0)
149
+ sinatra (1.3.2)
150
+ rack (~> 1.3, >= 1.3.6)
151
+ rack-protection (~> 1.2)
152
+ tilt (~> 1.3, >= 1.3.3)
153
+ sprockets (2.0.3)
146
154
  hike (~> 1.2)
147
155
  rack (~> 1.0)
148
156
  tilt (~> 1.1, != 1.3.0)
149
- spruz (0.2.13)
150
157
  thor (0.14.6)
151
158
  tilt (1.3.3)
152
159
  treetop (1.4.10)
153
160
  polyglot
154
161
  polyglot (>= 0.3.1)
155
- tzinfo (0.3.30)
162
+ tzinfo (0.3.31)
156
163
  vegas (0.1.8)
157
164
  rack (>= 1.0.0)
158
165
  xpath (0.1.4)
@@ -162,9 +169,10 @@ PLATFORMS
162
169
  ruby
163
170
 
164
171
  DEPENDENCIES
165
- capybara
166
- database_cleaner
172
+ capybara (~> 1.1.1)
173
+ database_cleaner (~> 0.6.7)
167
174
  factory_girl_rails (~> 1.2.0)
168
175
  mysql2
169
176
  quorum!
177
+ resque_spec (~> 0.8.1)
170
178
  rspec-rails (~> 2.6)
data/HISTORY.md ADDED
@@ -0,0 +1,9 @@
1
+ ## 0.2.0 (2012-01-20)
2
+
3
+ * Added link to Download Sequence in detailed report view.
4
+ * Added `rails g quorum:images` to override images.
5
+ * Deprecated Quorum initializer method `blast_script`.
6
+
7
+ ## 0.1.0 (2012-01-06)
8
+
9
+ * Initial release.
data/README.rdoc CHANGED
@@ -11,8 +11,8 @@ Dependencies:
11
11
 
12
12
  * Rails >= 3.1.0
13
13
  * Redis >= 0.900 for Resque (https://github.com/defunkt/resque)
14
- * NCBI Blast+ (ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/)
15
- * Emboss (http://emboss.sourceforge.net/)
14
+ * NCBI Blast+ (ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST)
15
+ * Emboss (http://emboss.sourceforge.net)
16
16
 
17
17
  See the gem in action.
18
18
 
@@ -41,6 +41,36 @@ Migrate the database.
41
41
  rake quorum:install:migrations
42
42
  rake db:migrate
43
43
 
44
+ == Upgrading?
45
+
46
+ Follow these steps to safely upgrade Quorum.
47
+
48
+ * Make a copy of "config/quorum_settings.yml".
49
+
50
+ <tt>cp config/quorum_settings.yml config/quorum_settings.yml.old</tt>
51
+
52
+ * If you overrode Quorum's styles and / or views, make a copy of the
53
+ existing directories before upgrading.
54
+
55
+ <tt>cp -R app/assets/stylesheets/quorum app/assets/stylesheets/quorum_old</tt>
56
+ <tt>cp -R app/views/quorum/jobs app/views/quorum/jobs_old</tt>
57
+
58
+ * Run the install generator and answer "Yes" to all conflicts.
59
+
60
+ <tt>rails generate quorum:install</tt>
61
+
62
+ * Copy the old Search Database(s) to the newly generated
63
+ "config/quorum_settings.yml" file.
64
+
65
+ * Update the database migrations.
66
+
67
+ <tt>rake quorum:install:migrations
68
+ rake db:migrate</tt>
69
+
70
+ * If applicable, override Quorum's views, styles and images.
71
+
72
+ * Update the remote machine(s).
73
+
44
74
  == Getting Started
45
75
 
46
76
  === NCBI Blast+ Setup
@@ -88,6 +118,38 @@ For a full list of supported arguments.
88
118
  Don't forget to update "config/quorum_settings.yml" with your newly created
89
119
  database(s).
90
120
 
121
+ ==== Download Blast Hit Sequence
122
+
123
+ Quorum provides a link to download a Blast hit sequence in the detailed report.
124
+ For this process to work smoothly, the sequence identifier MUST be unique
125
+ across ALL Blast databases.
126
+
127
+ Example:
128
+ "example_blast_database/contigs.fa"
129
+
130
+ >my_unique_sequence_identifier_201201201327077953
131
+ ATGC...
132
+
133
+ "another_example_blast_database/contigs.fa"
134
+
135
+ >my_unique_sequence_identifier_201201201327078017
136
+ CGTA...
137
+
138
+ If the sequence identifiers are not unique across all Blast databases and
139
+ you wish to remove the link to download a Blast hit sequence, follow the
140
+ steps below.
141
+
142
+ * Override Quorum's views (see Customize Quorum below)
143
+ * Comment out or remove the lines below in
144
+ "app/views/quorum/jobs/templates/_blast_detailed_report_template.html.erb"
145
+
146
+ \<p class="small">
147
+ <a id="download_sequence_{{= id }}"
148
+ onclick="downloadSequence(<%= @jobs.id %>, {{= id }}, '{{= algo }}', this)">
149
+ Download Sequence
150
+ </a>
151
+ \</p>
152
+
91
153
  === Remote Machine Setup -- Recommended for Production Use
92
154
 
93
155
  Follow the steps below to execute Quorum remotely via Net::SSH.
@@ -100,9 +162,9 @@ Follow the steps below to execute Quorum remotely via Net::SSH.
100
162
  * Ensure you have supplied the necessary information in
101
163
  "config/quorum_settings.yml" to execute Quorum remotely.
102
164
 
103
- remote: true
104
- ssh_host: remote.machine.org
105
- ssh_user: remote_user
165
+ <tt>remote: true</tt>
166
+ <tt>ssh_host: remote.machine.org</tt>
167
+ <tt>ssh_user: remote_user</tt>
106
168
 
107
169
  Net::SSH.start() optional params (http://net-ssh.github.com/ssh/v2/api/index.html)
108
170
 
@@ -112,28 +174,28 @@ Net::SSH.start() optional params (http://net-ssh.github.com/ssh/v2/api/index.htm
112
174
 
113
175
  * Tar and compress quorum.
114
176
 
115
- tar -czvf quorum.tar.gz quorum/
177
+ <tt>tar -czvf quorum.tar.gz quorum/</tt>
116
178
 
117
179
  * Copy the newly created tarball to the remote machine.
118
180
 
119
- scp quorum.tar.gz <username>@<host>:/path/to/install
181
+ <tt>scp quorum.tar.gz <username>@<host>:/path/to/install</tt>
120
182
 
121
183
  * Expand the tarball on the remote machine.
122
184
 
123
- ssh <username>@<host>
185
+ <tt>ssh <username>@<host></tt>
124
186
 
125
- tar -xzvf quorum.tar.gz
187
+ <tt>tar -xzvf quorum.tar.gz</tt>
126
188
 
127
189
  * Ensure Quorum script dependencies are added to the remote machine's PATH.
128
190
  If the remote machine doesn't have a .bashrc file, create one.
129
191
 
130
- touch /path/to/.bashrc
192
+ <tt>touch /path/to/.bashrc</tt>
131
193
 
132
194
  and add script dependencies to PATH.
133
195
 
134
196
  echo "export PATH=/path/to/dependencies:$PATH" >> /path/to/.bashrc
135
197
 
136
- === Customize Quorum's Views and Styles
198
+ === Customize Quorum's Views, Styles and Images
137
199
 
138
200
  To override Quorum's default views, run the generator.
139
201
 
@@ -155,6 +217,22 @@ it's a good idea to remove
155
217
  in "app/assets/stylesheets/application.css" and require your stylesheets
156
218
  individually.
157
219
 
220
+ To override Quorum's default images, run the generator.
221
+
222
+ rails generate quorum:images
223
+
224
+ A copy of Quorum's images can be found in your application under
225
+ "app/assets/images/quorum/".
226
+
227
+ <b>jQuery UI</b>
228
+
229
+ Don't like Quorum's jQuery UI theme? Override it!
230
+
231
+ * Override Quorum's styles and images.
232
+ * Roll your own jQuery UI theme. http://jqueryui.com/themeroller
233
+ * Replace Quorum's theme in "app/assets/{stylesheets:images}/quorum" with
234
+ your own.
235
+
158
236
  Don't plan on supporting all of Quorum's alogrithms? Override Quorum's views
159
237
  and comment out any unwanted algorithms in "app/views/quorum/jobs/new.html.erb"
160
238
  and "app/views/quorum/jobs/show.html.erb".
@@ -164,22 +242,22 @@ For example:
164
242
  Remove Blastp in "app/views/quorum/jobs/new.html.erb"
165
243
 
166
244
  <!-- Search Algorithms -->
167
- <!-- Comment out an alorithm below to remove it from the form. -->
245
+ <!-- Comment out an algorithm below to remove it from the form. -->
168
246
 
169
247
  <!-- blastn -->
170
- <%= render :partial => "blastn_form", :locals => {
248
+ <%= render :partial => "quorum/jobs/form/blastn_form", :locals => {
171
249
  :f => f, :blast_dbs => @blast_dbs } %>
172
250
 
173
251
  <!-- blastx -->
174
- <%= render :partial => "blastx_form", :locals => {
252
+ <%= render :partial => "quorum/jobs/form/blastx_form", :locals => {
175
253
  :f => f, :blast_dbs => @blast_dbs } %>
176
254
 
177
255
  <!-- tblastn -->
178
- <%= render :partial => "tblastn_form", :locals => {
256
+ <%= render :partial => "quorum/jobs/form/tblastn_form", :locals => {
179
257
  :f => f, :blast_dbs => @blast_dbs } %>
180
258
 
181
259
  <!-- blastp -->
182
- <% render :partial => "blastp_form", :locals => {
260
+ <% render :partial => "quorum/jobs/form/blastp_form", :locals => {
183
261
  :f => f, :blast_dbs => @blast_dbs } %>
184
262
 
185
263
  <!-- End Search Algorithms -->
@@ -200,21 +278,21 @@ Remove Blastp in "app/views/quorum/jobs/show.html.erb"
200
278
  <div id="tabs-1">
201
279
  <h2>Blastn</h2>
202
280
  <div id="blastn-results">
203
- Searching... <%= image_tag "quorum/knight_rider.gif" %>
281
+ Searching... <%= image_tag "quorum/loading.gif" %>
204
282
  </div>
205
283
  </div>
206
284
 
207
285
  <div id="tabs-2">
208
286
  <h2>Blastx</h2>
209
287
  <div id="blastx-results">
210
- Searching... <%= image_tag "quorum/knight_rider.gif" %>
288
+ Searching... <%= image_tag "quorum/loading.gif" %>
211
289
  </div>
212
290
  </div>
213
291
 
214
292
  <div id="tabs-3">
215
293
  <h2>Tblastn</h2>
216
294
  <div id="tblastn-results">
217
- Searching... <%= image_tag "quorum/knight_rider.gif" %>
295
+ Searching... <%= image_tag "quorum/loading.gif" %>
218
296
  </div>
219
297
  </div>
220
298
 
@@ -222,7 +300,7 @@ Remove Blastp in "app/views/quorum/jobs/show.html.erb"
222
300
  <div id="tabs-4">
223
301
  <h2>Blastp</h2>
224
302
  <div id="blastp-results">
225
- Searching... <%= image_tag "quorum/knight_rider.gif" %>
303
+ Searching... <%= image_tag "quorum/loading.gif" %>
226
304
  </div>
227
305
  </div>
228
306
  -->
@@ -232,7 +310,7 @@ Remove Blastp in "app/views/quorum/jobs/show.html.erb"
232
310
 
233
311
  For detailed Redis installation instructions, follow the links below.
234
312
 
235
- * Redis (http://redis.io/)
313
+ * Redis (http://redis.io)
236
314
  * Resque (https://github.com/defunkt/resque)
237
315
 
238
316
  === Resque
@@ -301,7 +379,7 @@ https://github.com/ncgr/quorum/issues
301
379
  === TODO
302
380
 
303
381
  * Add GFF3 annotations to detailed Blast reports
304
- * Add link to download Blast hit sequence in detailed report
382
+ * Add link to download multiple Blast hit sequences in detailed report
305
383
  * Support Hmmer3
306
384
 
307
385
  === Maintained By
@@ -315,4 +393,4 @@ https://github.com/ncgr/quorum/issues
315
393
 
316
394
  == License
317
395
 
318
- MIT License. Copyright NCGR http://ncgr.org/
396
+ MIT License. Copyright NCGR http://ncgr.org
@@ -180,7 +180,7 @@ var pollResults = function(id, interval, algos) {
180
180
  data: data,
181
181
  algo: a
182
182
  }
183
- );
183
+ );
184
184
  $('#' + a + '-results').html(temp);
185
185
  return;
186
186
  }
@@ -198,7 +198,7 @@ var viewDetailedReport = function(id, focus_id, query, algo) {
198
198
  // Create the modal box.
199
199
  $('#detailed_report_dialog').html(
200
200
  "<p class='center'>" +
201
- "Loading... <img src='/assets/quorum/knight_rider.gif' alt='Loading'>" +
201
+ "Loading... <img src='/assets/quorum/loading.gif' alt='Loading'>" +
202
202
  "</p>"
203
203
  ).dialog({
204
204
  modal: true,
@@ -249,7 +249,7 @@ var addBaseTitleIndex = function(bases, from, to, algo, type) {
249
249
  forward = false;
250
250
  }
251
251
 
252
- // Only set value to 3 if hseq is true and algo is tblastn.
252
+ // Set value to 3 for the below.
253
253
  if ((type === "hit" && algo === "tblastn") ||
254
254
  (type === "query" && algo === "blastx")) {
255
255
  value = 3;
@@ -350,6 +350,48 @@ var displayHspLinks = function(focus, group, data) {
350
350
  }
351
351
  }
352
352
 
353
+ //
354
+ // Download Blast hit sequence.
355
+ //
356
+ var downloadSequence = function(id, algo_id, algo, el) {
357
+ $(el).html('Fetching sequence...');
358
+
359
+ $.getJSON(
360
+ "/quorum/jobs/" + id + "/get_quorum_blast_hit_sequence.json?algo_id=" +
361
+ algo_id + "&algo=" + algo,
362
+ function(data) {
363
+ getSequenceFile(id, data[0].meta_id, el);
364
+ }
365
+ );
366
+ }
367
+
368
+ //
369
+ // Poll application for Blast hit sequence.
370
+ //
371
+ var getSequenceFile = function(id, meta_id, el) {
372
+ var url = "/quorum/jobs/" + id +
373
+ "/send_quorum_blast_hit_sequence?meta_id=" + meta_id;
374
+ $.get(
375
+ url,
376
+ function(data) {
377
+ if (data.length === 0) {
378
+ setTimeout(function() { getSequenceFile(id, meta_id, el) }, 2500);
379
+ } else {
380
+ if (data.indexOf("error") !== -1) {
381
+ // Print error message.
382
+ $(el).addClass('ui-state-error').html(data);
383
+ } else {
384
+ // Force browser to download file via iframe.
385
+ $(el).addClass('ui-state-highlight').html('Sequence Downloaded Successfully');
386
+ $('.quorum_sequence_download').remove();
387
+ $('body').append('<iframe class="quorum_sequence_download"></iframe>');
388
+ $('.quorum_sequence_download').attr('src', url).hide();
389
+ }
390
+ }
391
+ }
392
+ );
393
+ }
394
+
353
395
  //
354
396
  // Autoscroll to given div id.
355
397
  //
@@ -53,12 +53,11 @@ module Quorum
53
53
  # Returns Resque worker results.
54
54
  #
55
55
  def get_quorum_search_results
56
- valid = ["blastn", "blastx", "tblastn", "blastp"]
57
56
  empty = [{ :results => false }].to_json
58
57
 
59
58
  json = empty
60
59
 
61
- if valid.include? params[:algo]
60
+ if Quorum::BLAST_ALGORITHMS.include?(params[:algo])
62
61
  queued = "#{params[:algo]}_job".to_sym
63
62
  report = "#{params[:algo]}_job_reports".to_sym
64
63
 
@@ -84,6 +83,52 @@ module Quorum
84
83
  respond_with json
85
84
  end
86
85
 
86
+ #
87
+ # Find hit sequence, queue worker and return worker meta_id
88
+ # for lookup.
89
+ #
90
+ def get_quorum_blast_hit_sequence
91
+ json = []
92
+
93
+ if Quorum::BLAST_ALGORITHMS.include?(params[:algo])
94
+ begin
95
+ job = Job.find(params[:id])
96
+ rescue ActiveRecord::RecordNotFound => e
97
+ logger.error e.message
98
+ else
99
+ data = job.fetch_quorum_blast_sequence(
100
+ params[:algo], params[:algo_id]
101
+ )
102
+ json = [{ :meta_id => data.meta_id }]
103
+ end
104
+ end
105
+
106
+ respond_with json
107
+ end
108
+
109
+ #
110
+ # Send Blast hit sequence as attached file or render
111
+ # error message as text.
112
+ #
113
+ # See lib/generators/templates/blast_db.rb for more info.
114
+ #
115
+ def send_quorum_blast_hit_sequence
116
+ data = Workers::System.get_meta(params[:meta_id])
117
+ if data.succeeded?
118
+ unless data.result.downcase.include?("error")
119
+ send_data data.result,
120
+ :filename => "#{params[:meta_id]}.fa",
121
+ :type => "text/plain",
122
+ :disposition => "attachment"
123
+ return
124
+ else
125
+ render :text => data.result
126
+ return
127
+ end
128
+ end
129
+ render :text => ""
130
+ end
131
+
87
132
  private
88
133
 
89
134
  #