sequenceserver 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/sequenceserver/blast/hsp.rb +16 -4
- data/lib/sequenceserver/database.rb +9 -3
- data/lib/sequenceserver/routes.rb +31 -16
- data/lib/sequenceserver/version.rb +1 -1
- data/views/result.erb +2 -2
- data/views/search.erb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 910445c0b05d5d6a4fa903c392c9db1bf591849e
|
4
|
+
data.tar.gz: 73971a25168f906c4dea26876f3a56b9033baaba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1c9b4f0d8804a510e25ce67efd741b409d71a43dd3385eac5478e6d89d79eb7c7b8dac6ef465a1b429b211b1d29cc152d5d16d787a054fd1407bb35f9093d77
|
7
|
+
data.tar.gz: f164914652ab3657ab784b19a6d75fb911b18bac067403d02dca10cbd1e94e16341182891562f470de63317b54bc0b4e96904bd3751a373a19779be119d6294c
|
data/README.md
CHANGED
@@ -32,6 +32,14 @@ cd sequenceserver
|
|
32
32
|
gem install bundler && bundle
|
33
33
|
```
|
34
34
|
|
35
|
+
We use Capybara with WebKit driver for functional testing. If the above step
|
36
|
+
fails, install `qt` (On Mac: `brew install qt`) and run `bundle` again.
|
37
|
+
|
38
|
+
If you are deploying SequenceServer from git (not advised) you can skip
|
39
|
+
installing development dependencies (and `qt`) by running
|
40
|
+
|
41
|
+
bundle install --without=development
|
42
|
+
|
35
43
|
###### Node
|
36
44
|
```
|
37
45
|
npm install
|
@@ -29,8 +29,8 @@ module SequenceServer
|
|
29
29
|
#
|
30
30
|
def stats
|
31
31
|
{
|
32
|
-
'Score' => [bit_score, score],
|
33
|
-
'E value' => evalue,
|
32
|
+
'Score' => [in_twodecimal(bit_score), score],
|
33
|
+
'E value' => in_scientific_or_twodecimal(evalue),
|
34
34
|
'Identities' => [in_fraction(identity, length),
|
35
35
|
in_percentage(identity, length)],
|
36
36
|
'Gaps' => [in_fraction(gaps, length),
|
@@ -148,7 +148,7 @@ module SequenceServer
|
|
148
148
|
|
149
149
|
## We define stats in terms of the following functions. ##
|
150
150
|
|
151
|
-
#
|
151
|
+
# Returns fractional representation as String.
|
152
152
|
#
|
153
153
|
# NOTE:
|
154
154
|
# Rational class reduces the fraction so we can't use that.
|
@@ -156,10 +156,22 @@ module SequenceServer
|
|
156
156
|
"#{num}/#{den}"
|
157
157
|
end
|
158
158
|
|
159
|
-
#
|
159
|
+
# Returns percentage as Float-String formatted to two decimal places.
|
160
160
|
def in_percentage(num, den)
|
161
161
|
format '%.2f', (num * 100.0 / den)
|
162
162
|
end
|
163
|
+
|
164
|
+
# Returns given Float as String formatted to two decimal places.
|
165
|
+
def in_twodecimal(num)
|
166
|
+
format '%.2f', num
|
167
|
+
end
|
168
|
+
|
169
|
+
# Formats the given number as "1e-3" if the number is less than 1 or
|
170
|
+
# greater than 10.
|
171
|
+
def in_scientific_or_twodecimal(num)
|
172
|
+
return in_twodecimal(num) if num >= 1 && num < 10
|
173
|
+
format '%.2e', num.to_f
|
174
|
+
end
|
163
175
|
end
|
164
176
|
|
165
177
|
class HSP
|
@@ -106,16 +106,22 @@ module SequenceServer
|
|
106
106
|
out.each_line do |line|
|
107
107
|
name = line.split(' ')[0]
|
108
108
|
next if multipart_database_name?(name)
|
109
|
-
|
109
|
+
begin
|
110
|
+
self << Database.new(*line.split(' '))
|
111
|
+
rescue NoMethodError => e
|
112
|
+
err << "BLAST Database error:\n#{e}\n#{line}"
|
113
|
+
end
|
110
114
|
end
|
115
|
+
throw_scan_error(cmd, out, err, $CHILD_STATUS)
|
111
116
|
end
|
112
117
|
end
|
113
118
|
|
114
119
|
def throw_scan_error(cmd, out, err, child_status)
|
115
120
|
errpat = /BLAST Database error/
|
121
|
+
if !child_status.success? || err.match(errpat)
|
122
|
+
fail BLAST_DATABASE_ERROR.new(cmd, err)
|
123
|
+
end
|
116
124
|
fail NO_BLAST_DATABASE_FOUND, config[:database_dir] if out.empty?
|
117
|
-
fail BLAST_DATABASE_ERROR.new(cmd, err) if !child_status.success? ||
|
118
|
-
err.match(errpat)
|
119
125
|
end
|
120
126
|
|
121
127
|
# Recursively scan `database_dir` for un-formatted FASTA and format them
|
@@ -19,16 +19,12 @@ module SequenceServer
|
|
19
19
|
# Make it a policy to dump to 'rack.errors' any exception raised by the
|
20
20
|
# app so that error handlers don't have to do it themselves. But for it
|
21
21
|
# to always work, Exceptions defined by us should not respond to `code`
|
22
|
-
# or http_status` methods. Error blocks
|
22
|
+
# or `http_status` methods. Error blocks must explicitly set http
|
23
23
|
# status, if needed, by calling `status` method.
|
24
|
-
# method.
|
25
24
|
enable :dump_errors
|
26
25
|
|
27
26
|
# We don't want Sinatra do setup any loggers for us. We will use our own.
|
28
27
|
set :logging, nil
|
29
|
-
|
30
|
-
# Public, and views directory will be found here.
|
31
|
-
set :root, lambda { SequenceServer.root }
|
32
28
|
end
|
33
29
|
|
34
30
|
# See
|
@@ -39,6 +35,21 @@ module SequenceServer
|
|
39
35
|
mime_type :tsv, 'text/tsv'
|
40
36
|
end
|
41
37
|
|
38
|
+
configure do
|
39
|
+
# Public, and views directory will be found here.
|
40
|
+
set :root, lambda { SequenceServer.root }
|
41
|
+
|
42
|
+
# Allow :frame_options to be configured for Rack::Protection.
|
43
|
+
#
|
44
|
+
# By default _any website_ can embed SequenceServer in an iframe. To
|
45
|
+
# change this, set `:frame_options` config to :deny, :sameorigin, or
|
46
|
+
# 'ALLOW-FROM uri'.
|
47
|
+
set :protection, lambda {
|
48
|
+
frame_options = SequenceServer.config[:frame_options]
|
49
|
+
frame_options && {:frame_options => frame_options}
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
42
53
|
configure :production do
|
43
54
|
set :public_folder,
|
44
55
|
lambda { File.join SequenceServer.root, 'public', 'dist' }
|
@@ -67,20 +78,19 @@ target="#{target}">)
|
|
67
78
|
# Prettify given data.
|
68
79
|
def prettify(data)
|
69
80
|
return prettify_tuple(data) if tuple? data
|
70
|
-
return prettify_float(data) if
|
81
|
+
return prettify_float(data) if float? data
|
71
82
|
data
|
72
83
|
end
|
73
84
|
|
74
|
-
# Formats float as "a.
|
85
|
+
# Formats float as "a.bc" or "a x b^c". The latter if float is in
|
75
86
|
# scientific notation. Former otherwise.
|
76
|
-
def prettify_float(
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
87
|
+
def prettify_float(data)
|
88
|
+
data.to_s.match(/(\d+\.\d+)e?([+-]\d+)?/)
|
89
|
+
base = Regexp.last_match[1]
|
90
|
+
power = Regexp.last_match[2]
|
91
|
+
s = format '%.2f', base
|
92
|
+
s << " × 10<sup>#{power}</sup>" if power
|
93
|
+
s
|
84
94
|
end
|
85
95
|
|
86
96
|
# Formats an array of two elements as "first (last)".
|
@@ -90,7 +100,12 @@ target="#{target}">)
|
|
90
100
|
|
91
101
|
# Is the given value a tuple? (array of length two).
|
92
102
|
def tuple?(data)
|
93
|
-
|
103
|
+
data.is_a?(Array) && data.length == 2
|
104
|
+
end
|
105
|
+
|
106
|
+
def float?(data)
|
107
|
+
data.is_a?(Float) ||
|
108
|
+
(data.is_a?(String) && data =~ /(\d+\.\d+)e?([+-]\d+)?/)
|
94
109
|
end
|
95
110
|
end
|
96
111
|
|
data/views/result.erb
CHANGED
@@ -48,8 +48,8 @@
|
|
48
48
|
<tr>
|
49
49
|
<td class="text-left"><%= h + 1 %>.</td>
|
50
50
|
<td> <a href="<%="#Query_#{query.number}_hit_#{hit.number}"%>"><%= "#{hit.id}" %></a> </td>
|
51
|
-
<td class="text-right"><%=
|
52
|
-
<td class="text-right"><%=
|
51
|
+
<td class="text-right"><%= prettify hit.score %></td>
|
52
|
+
<td class="text-right"><%= prettify hit.evalue %></td>
|
53
53
|
</tr>
|
54
54
|
<% end %>
|
55
55
|
</tbody>
|
data/views/search.erb
CHANGED
@@ -285,8 +285,13 @@
|
|
285
285
|
"Custom BLAST web interface by SequenceServer.",
|
286
286
|
"SequenceServer: Local BLAST with bespoke html interface.",
|
287
287
|
"Set up custom BLAST interface with SequenceServer.",
|
288
|
-
"Easy BLASTing with SequenceServer."
|
289
|
-
|
288
|
+
"Easy BLASTing with SequenceServer.",
|
289
|
+
"Run BLAST locally with Sequenceserver.",
|
290
|
+
"BLAST against a custom, local database with SequenceServer.",
|
291
|
+
"Run BLAST locally on Mac OSX with SequenceServer.",
|
292
|
+
"Run BLAST locally on Ubuntu with SequenceServer.",
|
293
|
+
"Run BLAST locally on Linux with SequenceServer."
|
294
|
+
][rand(9)]
|
290
295
|
%>
|
291
296
|
</a>
|
292
297
|
<a
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequenceserver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anurag Priyam
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: sinatra
|