unipept 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -1
- data/.travis.yml +1 -1
- data/Gemfile +5 -5
- data/Gemfile.lock +40 -32
- data/README.md +3 -3
- data/VERSION +1 -1
- data/lib/commands/unipept.rb +1 -11
- data/lib/commands/unipept/api_runner.rb +5 -8
- data/lib/commands/unipept/config.rb +1 -1
- data/lib/formatters.rb +3 -3
- data/lib/retryable_typhoeus.rb +34 -0
- data/test/commands/unipept/test_api_runner.rb +11 -6
- data/test/commands/unipept/test_pept2prot.rb +3 -3
- data/test/commands/unipept/test_pept2taxa.rb +3 -3
- data/test/commands/unipept/test_taxonomy.rb +3 -3
- data/test/{test_bach_order.rb → test_batch_order.rb} +0 -0
- data/test/test_retryable_typhoeus.rb +108 -0
- data/unipept.gemspec +21 -19
- metadata +25 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 662aed8d64c58c637883ff112a3f7be5a8ea05b1
|
4
|
+
data.tar.gz: 52842a660a7dfe19c47403b7d1b4a83cc5d29525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 461714f0766dab2e1c28cadc751245e00fda0e3462d184ed941fcf8ac1ee2562f1635fe0932b7a533722be2dabb7c7328800fb76a2ffacb8391cac92893f125e
|
7
|
+
data.tar.gz: 7559ef5e0dbedf38cac9d0186289ffb8cd6672b131d84fa13389a09f9c1a41003164f949ef40852475479e84e49868dab618bcd0f2280514103fb1f594b9dc83
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
Include:
|
3
|
-
-
|
3
|
+
- ''
|
4
4
|
Exclude:
|
5
5
|
- 'unipept.gemspec'
|
6
6
|
- 'vendor/**/*'
|
@@ -10,6 +10,8 @@ Style/ClassAndModuleChildren:
|
|
10
10
|
Enabled: false
|
11
11
|
|
12
12
|
# disable for now
|
13
|
+
Lint/NestedMethodDefinition:
|
14
|
+
Enabled: false
|
13
15
|
Style/ClassVars:
|
14
16
|
Enabled: false
|
15
17
|
Style/Documentation:
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -4,12 +4,12 @@ source 'http://rubygems.org'
|
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
5
|
|
6
6
|
gem 'cri', '~> 2.7'
|
7
|
-
gem 'typhoeus', '
|
7
|
+
gem 'typhoeus', '0.7.2'
|
8
8
|
|
9
9
|
group :development do
|
10
|
-
gem 'rake'
|
11
|
-
gem 'minitest'
|
12
|
-
gem 'rubocop'
|
13
|
-
gem 'jeweler'
|
10
|
+
gem 'rake', '~> 10.4'
|
11
|
+
gem 'minitest', '~> 5.7'
|
12
|
+
gem 'rubocop', '~>0.32'
|
13
|
+
gem 'jeweler', '~> 2.0'
|
14
14
|
gem 'coveralls', require: false
|
15
15
|
end
|
data/Gemfile.lock
CHANGED
@@ -7,22 +7,24 @@ GEM
|
|
7
7
|
parser (>= 2.2.0.pre.3, < 3.0)
|
8
8
|
builder (3.2.2)
|
9
9
|
colored (1.2)
|
10
|
-
coveralls (0.
|
11
|
-
|
12
|
-
rest-client
|
13
|
-
simplecov (
|
14
|
-
term-ansicolor
|
15
|
-
thor
|
10
|
+
coveralls (0.8.2)
|
11
|
+
json (~> 1.8)
|
12
|
+
rest-client (>= 1.6.8, < 2)
|
13
|
+
simplecov (~> 0.10.0)
|
14
|
+
term-ansicolor (~> 1.3)
|
15
|
+
thor (~> 0.19.1)
|
16
16
|
cri (2.7.0)
|
17
17
|
colored (~> 1.2)
|
18
18
|
descendants_tracker (0.0.4)
|
19
19
|
thread_safe (~> 0.3, >= 0.3.1)
|
20
20
|
docile (1.1.5)
|
21
|
-
|
21
|
+
domain_name (0.5.24)
|
22
|
+
unf (>= 0.0.5, < 1.0.0)
|
23
|
+
ethon (0.7.4)
|
22
24
|
ffi (>= 1.3.0)
|
23
25
|
faraday (0.9.1)
|
24
26
|
multipart-post (>= 1.2, < 3)
|
25
|
-
ffi (1.9.
|
27
|
+
ffi (1.9.10)
|
26
28
|
git (1.2.9.1)
|
27
29
|
github_api (0.12.3)
|
28
30
|
addressable (~> 2.3)
|
@@ -32,8 +34,10 @@ GEM
|
|
32
34
|
multi_json (>= 1.7.5, < 2.0)
|
33
35
|
nokogiri (~> 1.6.3)
|
34
36
|
oauth2
|
35
|
-
hashie (3.4.
|
37
|
+
hashie (3.4.2)
|
36
38
|
highline (1.7.2)
|
39
|
+
http-cookie (1.0.2)
|
40
|
+
domain_name (~> 0.5)
|
37
41
|
jeweler (2.0.1)
|
38
42
|
builder
|
39
43
|
bundler (>= 1.0)
|
@@ -43,15 +47,15 @@ GEM
|
|
43
47
|
nokogiri (>= 1.5.10)
|
44
48
|
rake
|
45
49
|
rdoc
|
46
|
-
json (1.8.
|
47
|
-
jwt (1.
|
48
|
-
mime-types (2.
|
50
|
+
json (1.8.3)
|
51
|
+
jwt (1.5.1)
|
52
|
+
mime-types (2.6.1)
|
49
53
|
mini_portile (0.6.2)
|
50
|
-
minitest (5.
|
51
|
-
multi_json (1.11.
|
54
|
+
minitest (5.7.0)
|
55
|
+
multi_json (1.11.1)
|
52
56
|
multi_xml (0.5.5)
|
53
57
|
multipart-post (2.0.0)
|
54
|
-
netrc (0.
|
58
|
+
netrc (0.10.3)
|
55
59
|
nokogiri (1.6.6.2)
|
56
60
|
mini_portile (~> 0.6.0)
|
57
61
|
oauth2 (1.0.0)
|
@@ -60,36 +64,40 @@ GEM
|
|
60
64
|
multi_json (~> 1.3)
|
61
65
|
multi_xml (~> 0.5)
|
62
66
|
rack (~> 1.2)
|
63
|
-
parser (2.
|
67
|
+
parser (2.3.0.pre.2)
|
64
68
|
ast (>= 1.1, < 3.0)
|
65
|
-
powerpack (0.
|
66
|
-
rack (1.6.
|
69
|
+
powerpack (0.1.1)
|
70
|
+
rack (1.6.4)
|
67
71
|
rainbow (2.0.0)
|
68
72
|
rake (10.4.2)
|
69
73
|
rdoc (4.2.0)
|
70
74
|
json (~> 1.4)
|
71
|
-
rest-client (1.
|
75
|
+
rest-client (1.8.0)
|
76
|
+
http-cookie (>= 1.0.2, < 2.0)
|
72
77
|
mime-types (>= 1.16, < 3.0)
|
73
78
|
netrc (~> 0.7)
|
74
|
-
rubocop (0.
|
79
|
+
rubocop (0.32.1)
|
75
80
|
astrolabe (~> 1.3)
|
76
|
-
parser (>= 2.2.
|
77
|
-
powerpack (~> 0.
|
81
|
+
parser (>= 2.2.2.5, < 3.0)
|
82
|
+
powerpack (~> 0.1)
|
78
83
|
rainbow (>= 1.99.1, < 3.0)
|
79
84
|
ruby-progressbar (~> 1.4)
|
80
|
-
ruby-progressbar (1.7.
|
85
|
+
ruby-progressbar (1.7.5)
|
81
86
|
simplecov (0.10.0)
|
82
87
|
docile (~> 1.1.0)
|
83
88
|
json (~> 1.8)
|
84
89
|
simplecov-html (~> 0.10.0)
|
85
90
|
simplecov-html (0.10.0)
|
86
|
-
term-ansicolor (1.3.
|
91
|
+
term-ansicolor (1.3.2)
|
87
92
|
tins (~> 1.0)
|
88
93
|
thor (0.19.1)
|
89
94
|
thread_safe (0.3.5)
|
90
|
-
tins (1.
|
91
|
-
typhoeus (0.7.
|
92
|
-
ethon (>= 0.7.
|
95
|
+
tins (1.5.4)
|
96
|
+
typhoeus (0.7.2)
|
97
|
+
ethon (>= 0.7.4)
|
98
|
+
unf (0.1.4)
|
99
|
+
unf_ext
|
100
|
+
unf_ext (0.0.7.1)
|
93
101
|
|
94
102
|
PLATFORMS
|
95
103
|
ruby
|
@@ -97,8 +105,8 @@ PLATFORMS
|
|
97
105
|
DEPENDENCIES
|
98
106
|
coveralls
|
99
107
|
cri (~> 2.7)
|
100
|
-
jeweler
|
101
|
-
minitest
|
102
|
-
rake
|
103
|
-
rubocop
|
104
|
-
typhoeus (
|
108
|
+
jeweler (~> 2.0)
|
109
|
+
minitest (~> 5.7)
|
110
|
+
rake (~> 10.4)
|
111
|
+
rubocop (~> 0.32)
|
112
|
+
typhoeus (= 0.7.2)
|
data/README.md
CHANGED
@@ -23,8 +23,8 @@ The Unipept CLI is available as a *gem*. This means it can easily be installed w
|
|
23
23
|
|
24
24
|
```bash
|
25
25
|
$ gem install unipept
|
26
|
-
Successfully installed unipept-0.
|
27
|
-
Parsing documentation for unipept-0.
|
26
|
+
Successfully installed unipept-0.10.0
|
27
|
+
Parsing documentation for unipept-0.10.0
|
28
28
|
Done installing documentation for unipept after 0 seconds
|
29
29
|
1 gem installed
|
30
30
|
```
|
@@ -33,7 +33,7 @@ After successful installation, the unipept command should be available:
|
|
33
33
|
|
34
34
|
```bash
|
35
35
|
$ unipept -v
|
36
|
-
0.
|
36
|
+
0.10.0
|
37
37
|
```
|
38
38
|
|
39
39
|
The help can be accessed by running `unipept -h`.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.10.0
|
data/lib/commands/unipept.rb
CHANGED
@@ -55,7 +55,7 @@ module Unipept
|
|
55
55
|
option nil, :batch, 'specify the batch size', argument: :required, hidden: true
|
56
56
|
option nil, :parallel, 'specify the number of parallel requests', argument: :required, hidden: true
|
57
57
|
option :o, :output, 'write output to file', argument: :required
|
58
|
-
option :f, :format, "define the output format (available: #{Unipept::Formatter.available.join ', '
|
58
|
+
option :f, :format, "define the output format (available: #{Unipept::Formatter.available.join ', '}) (default: #{Unipept::Formatter.default})", argument: :required
|
59
59
|
|
60
60
|
# Configuration options
|
61
61
|
option nil, 'host', 'specify the server running the Unipept web service', argument: :required
|
@@ -104,8 +104,6 @@ module Unipept
|
|
104
104
|
- to standard input
|
105
105
|
|
106
106
|
The command will give priority to the first way tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.
|
107
|
-
|
108
|
-
The unipept pept2taxa subcommand yields NCBI Taxonomy records as output.
|
109
107
|
EOS
|
110
108
|
|
111
109
|
flag :e, :equate, 'equate isoleucine (I) and leucine (L) when matching peptides'
|
@@ -130,8 +128,6 @@ module Unipept
|
|
130
128
|
- to standard input
|
131
129
|
|
132
130
|
The command will give priority to the first way tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.
|
133
|
-
|
134
|
-
The unipept pept2lca subcommand yields an NCBI Taxonomy record as output.
|
135
131
|
EOS
|
136
132
|
|
137
133
|
flag :e, :equate, 'equate isoleucine (I) and leucine (L) when matching peptides'
|
@@ -156,8 +152,6 @@ module Unipept
|
|
156
152
|
- to standard input
|
157
153
|
|
158
154
|
The command will give priority to the first way NCBI Taxonomy Identifiers are passed, in the order as listed above. Text files and standard input should have one NCBI Taxonomy Identifier per line.
|
159
|
-
|
160
|
-
The unipept taxonomy subcommand yields NCBI Taxonomy records as output.
|
161
155
|
EOS
|
162
156
|
|
163
157
|
flag :a, :all, 'report all information fields of NCBI Taxonomy records available in Unipept. Note that this may have a performance penalty.'
|
@@ -181,8 +175,6 @@ module Unipept
|
|
181
175
|
- to standard input
|
182
176
|
|
183
177
|
The command will give priority to the first way tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.
|
184
|
-
|
185
|
-
The unipept pept2prot subcommand yields Uniprot records as output.
|
186
178
|
EOS
|
187
179
|
|
188
180
|
flag :e, :equate, 'equate isoleucine (I) and leucine (L) when matching peptides'
|
@@ -207,8 +199,6 @@ module Unipept
|
|
207
199
|
- to standard input
|
208
200
|
|
209
201
|
The command will give priority to the first way NCBI Taxonomy Identifiers are passed, in the order as listed above. Text files and standard input should have one NCBI Taxonomy Identifier per line.
|
210
|
-
|
211
|
-
The unipept taxonomy subcommand yields NCBI Taxonomy records as output.
|
212
202
|
EOS
|
213
203
|
|
214
204
|
flag :a, :all, 'report all information fields of NCBI Taxonomy records available in Unipept. Note that this may have a performance penalty.'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative '../../retryable_typhoeus'
|
2
|
+
|
1
3
|
module Unipept
|
2
4
|
class Commands::ApiRunner < Cri::CommandRunner
|
3
5
|
attr_reader :configuration
|
@@ -20,11 +22,7 @@ module Unipept
|
|
20
22
|
def host
|
21
23
|
# find host in opts first
|
22
24
|
host = options[:host] ? options[:host] : @configuration['host']
|
23
|
-
|
24
|
-
# No host has been set?
|
25
|
-
if host.nil? || host.empty?
|
26
|
-
abort 'WARNING: no host has been set, you can set the host with `unipept config host http://api.unipept.ugent.be/`'
|
27
|
-
end
|
25
|
+
host = 'http://api.unipept.ugent.be' if host.nil? || host.empty?
|
28
26
|
|
29
27
|
# add http:// if needed
|
30
28
|
if host.start_with?('http://') || host.start_with?('https://')
|
@@ -92,7 +90,7 @@ module Unipept
|
|
92
90
|
# Constructs a request body (a Hash) for set of input strings, using the
|
93
91
|
# options supplied by the user.
|
94
92
|
def construct_request_body(input)
|
95
|
-
names = selected_fields.empty? || selected_fields.any? { |f| f.to_s.include?
|
93
|
+
names = selected_fields.empty? || selected_fields.any? { |f| f.to_s.include?('name') || f.to_s.include?('.*$') }
|
96
94
|
{ input: input,
|
97
95
|
equate_il: options[:equate] == true,
|
98
96
|
extra: options[:all] == true,
|
@@ -109,8 +107,7 @@ module Unipept
|
|
109
107
|
|
110
108
|
batch_iterator.iterate(input_iterator) do |input_slice, batch_id, fasta_mapper|
|
111
109
|
last_id = batch_id
|
112
|
-
|
113
|
-
request = Typhoeus::Request.new(
|
110
|
+
request = ::RetryableTyphoeus::Request.new(
|
114
111
|
@url,
|
115
112
|
method: :post,
|
116
113
|
body: construct_request_body(input_slice),
|
data/lib/formatters.rb
CHANGED
@@ -200,7 +200,7 @@ module Unipept
|
|
200
200
|
def convert(data, _first)
|
201
201
|
CSV.generate do |csv|
|
202
202
|
data.each do |o|
|
203
|
-
csv << o.values.map { |v| v == ''
|
203
|
+
csv << o.values.map { |v| v == '' ? nil : v }
|
204
204
|
end
|
205
205
|
end
|
206
206
|
end
|
@@ -217,13 +217,13 @@ module Unipept
|
|
217
217
|
|
218
218
|
class ::Array
|
219
219
|
def to_xml(array_name = :array, _item_name = :item)
|
220
|
-
%(<#{array_name}>) + map { |n|n.to_xml(:item) }.join + "</#{array_name}>"
|
220
|
+
%(<#{array_name}>) + map { |n| n.to_xml(:item) }.join + "</#{array_name}>"
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
224
224
|
class ::Hash
|
225
225
|
def to_xml(name = nil)
|
226
|
-
data = to_a.map { |k, v|v.to_xml(k) }.join
|
226
|
+
data = to_a.map { |k, v| v.to_xml(k) }.join
|
227
227
|
name ? "<#{name}>#{data}</#{name}>" : data
|
228
228
|
end
|
229
229
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Retryable Typheous
|
2
|
+
# Inspiration: https://gist.github.com/kunalmodi/2939288
|
3
|
+
# Patches the request and hydra to allow requests to get resend when they fail
|
4
|
+
|
5
|
+
module RetryableTyphoeus
|
6
|
+
require 'typhoeus'
|
7
|
+
|
8
|
+
include Typhoeus
|
9
|
+
|
10
|
+
DEFAULT_RETRIES = 10
|
11
|
+
|
12
|
+
class Request < Typhoeus::Request
|
13
|
+
attr_accessor :retries
|
14
|
+
|
15
|
+
def initialize(base_url, options = {})
|
16
|
+
@retries = (options.delete(:retries) || DEFAULT_RETRIES)
|
17
|
+
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def finish(response, bypass_memoization = nil)
|
22
|
+
if response.success? || @retries <= 0
|
23
|
+
super
|
24
|
+
else
|
25
|
+
@retries -= 1
|
26
|
+
if @hydra
|
27
|
+
@hydra.queue_front self
|
28
|
+
else
|
29
|
+
run
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -36,12 +36,8 @@ module Unipept
|
|
36
36
|
runner = new_runner('test', { host: 'param_host' }, %w(a b c))
|
37
37
|
runner.configuration.delete('host')
|
38
38
|
runner.options.delete(:host)
|
39
|
-
|
40
|
-
|
41
|
-
runner.host
|
42
|
-
end
|
43
|
-
end
|
44
|
-
assert(err.start_with? 'WARNING: no host has been set')
|
39
|
+
host = runner.host
|
40
|
+
assert_equal('http://api.unipept.ugent.be', host)
|
45
41
|
end
|
46
42
|
|
47
43
|
def test_host_priority
|
@@ -214,6 +210,15 @@ module Unipept
|
|
214
210
|
assert_equal(true, body[:names])
|
215
211
|
end
|
216
212
|
|
213
|
+
def test_all_names_wildcard_select_construct_request_body
|
214
|
+
runner = new_runner('test', host: 'http://param_host', all: true, select: 'test,order*')
|
215
|
+
body = runner.construct_request_body('test')
|
216
|
+
assert_equal('test', body[:input])
|
217
|
+
assert_equal(false, body[:equate_il])
|
218
|
+
assert_equal(true, body[:extra])
|
219
|
+
assert_equal(true, body[:names])
|
220
|
+
end
|
221
|
+
|
217
222
|
def test_all_no_names_select_construct_request_body
|
218
223
|
runner = new_runner('test', host: 'http://param_host', all: true, select: 'test')
|
219
224
|
body = runner.construct_request_body('test')
|
@@ -43,9 +43,9 @@ module Unipept
|
|
43
43
|
lines = out.each_line
|
44
44
|
assert_equal('', err)
|
45
45
|
assert(lines.next.start_with? 'fasta_header,peptide,uniprot_id,taxon_id')
|
46
|
-
assert(lines.
|
47
|
-
assert(lines.
|
48
|
-
assert(lines.
|
46
|
+
assert(lines.count { |line| line.start_with? '>test,EGGAGSSTGQR,' } >= 1)
|
47
|
+
assert(lines.count { |line| line.start_with? '>test,ENFVYIAK,' } >= 1)
|
48
|
+
assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_run_with_fasta_multiple_batches_json
|
@@ -43,9 +43,9 @@ module Unipept
|
|
43
43
|
lines = out.each_line
|
44
44
|
assert_equal('', err)
|
45
45
|
assert(lines.next.start_with? 'fasta_header,peptide,taxon_id,taxon_name,taxon_rank')
|
46
|
-
assert(lines.
|
47
|
-
assert(lines.
|
48
|
-
assert(lines.
|
46
|
+
assert(lines.count { |line| line.start_with? '>test,EGGAGSSTGQR,' } >= 1)
|
47
|
+
assert(lines.count { |line| line.start_with? '>test,ENFVYIAK,' } >= 1)
|
48
|
+
assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_run_with_fasta_multiple_batches_json
|
@@ -41,9 +41,9 @@ module Unipept
|
|
41
41
|
lines = out.each_line
|
42
42
|
assert_equal('', err)
|
43
43
|
assert(lines.next.start_with? 'fasta_header,taxon_id,taxon_name,taxon_rank')
|
44
|
-
assert(lines.
|
45
|
-
assert(lines.
|
46
|
-
assert(lines.
|
44
|
+
assert(lines.count { |line| line.start_with? '>test,1,' } >= 1)
|
45
|
+
assert(lines.count { |line| line.start_with? '>test,216816,' } >= 1)
|
46
|
+
assert(lines.count { |line| line.start_with? '>tost,1,' } >= 1)
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_run_with_fasta_multiple_batches_json
|
File without changes
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require_relative '../lib/retryable_typhoeus'
|
2
|
+
|
3
|
+
module Unipept
|
4
|
+
class BatchIteratorTestCase < Unipept::TestCase
|
5
|
+
def test_request_retry_default_parameter
|
6
|
+
request = new_request
|
7
|
+
assert_equal(10, request.retries)
|
8
|
+
request.retries = 3
|
9
|
+
assert_equal(3, request.retries)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_request_retry_parameter
|
13
|
+
request = new_request(retries: 5)
|
14
|
+
assert_equal(5, request.retries)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_succesful_requests_complete
|
18
|
+
hydra = new_hydra
|
19
|
+
|
20
|
+
response = new_response
|
21
|
+
Typhoeus.stub('stubbed.com').and_return(response)
|
22
|
+
|
23
|
+
request = new_request
|
24
|
+
|
25
|
+
hydra.queue request
|
26
|
+
hydra.run
|
27
|
+
|
28
|
+
assert_equal(10, request.retries)
|
29
|
+
assert_equal(true, response.success?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_failing_requests_retry_wo_hydra
|
33
|
+
response_fail = new_response(400)
|
34
|
+
response_success = new_response(200)
|
35
|
+
Typhoeus::Expectation.clear
|
36
|
+
Typhoeus.stub('stubbed.com').and_return([response_fail, response_success])
|
37
|
+
|
38
|
+
request = new_request
|
39
|
+
request.run
|
40
|
+
|
41
|
+
assert_equal(9, request.retries)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_failing_requests_retry_with_hydra
|
45
|
+
hydra = new_hydra
|
46
|
+
|
47
|
+
response_fail = new_response(400)
|
48
|
+
response_success = new_response(200)
|
49
|
+
Typhoeus::Expectation.clear
|
50
|
+
Typhoeus.stub('stubbed.com').and_return([response_fail, response_success])
|
51
|
+
|
52
|
+
request = new_request
|
53
|
+
|
54
|
+
hydra.queue request
|
55
|
+
hydra.run
|
56
|
+
|
57
|
+
assert_equal(9, request.retries)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_failing_requests_finally_complete_wo_hydra
|
61
|
+
response = new_response(400)
|
62
|
+
Typhoeus.stub('stubbed.com').and_return(response)
|
63
|
+
|
64
|
+
request = new_request
|
65
|
+
request.run
|
66
|
+
|
67
|
+
assert_equal(0, request.retries)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_failing_requests_finally_complete_with_error
|
71
|
+
hydra = new_hydra
|
72
|
+
response = new_response(400)
|
73
|
+
Typhoeus.stub('stubbed.com').and_return(response)
|
74
|
+
|
75
|
+
request = new_request
|
76
|
+
|
77
|
+
hydra.queue request
|
78
|
+
hydra.run
|
79
|
+
|
80
|
+
assert_equal(0, request.retries)
|
81
|
+
assert_equal(false, response.success?)
|
82
|
+
end
|
83
|
+
|
84
|
+
def new_request(extra_opts = {})
|
85
|
+
::RetryableTyphoeus::Request.new(
|
86
|
+
'stubbed.com',
|
87
|
+
request_options.merge(extra_opts)
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
def request_options
|
92
|
+
{
|
93
|
+
method: :post,
|
94
|
+
body: 'body',
|
95
|
+
accept_encoding: 'gzip',
|
96
|
+
headers: { 'User-Agent' => 'user-agent' }
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
def new_hydra
|
101
|
+
Typhoeus::Hydra.new(max_concurrency: 10)
|
102
|
+
end
|
103
|
+
|
104
|
+
def new_response(code = 200)
|
105
|
+
Typhoeus::Response.new(code: code, body: {}, return_code: :ok)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/unipept.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: unipept 0.
|
5
|
+
# stub: unipept 0.10.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "unipept"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.10.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Toon Willems", "Bart Mesuere", "Tom Naessens"]
|
13
|
-
s.date = "2015-
|
13
|
+
s.date = "2015-07-01"
|
14
14
|
s.description = " Command line interface to the Unipept (http://unipept.ugent.be) web services\n (pept2lca, taxa2lca, pept2taxa and taxonomy) and some utility commands for\n handling proteins using the command line.\n"
|
15
15
|
s.email = "unipept@ugent.be"
|
16
16
|
s.executables = ["unipept", "prot2pept", "peptfilter", "uniprot"]
|
@@ -49,6 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
"lib/configuration.rb",
|
50
50
|
"lib/formatters.rb",
|
51
51
|
"lib/output_writer.rb",
|
52
|
+
"lib/retryable_typhoeus.rb",
|
52
53
|
"lib/server_message.rb",
|
53
54
|
"lib/version.rb",
|
54
55
|
"test/commands/test_peptfilter.rb",
|
@@ -63,11 +64,12 @@ Gem::Specification.new do |s|
|
|
63
64
|
"test/commands/unipept/test_taxa2lca.rb",
|
64
65
|
"test/commands/unipept/test_taxonomy.rb",
|
65
66
|
"test/helper.rb",
|
66
|
-
"test/test_bach_order.rb",
|
67
67
|
"test/test_batch_iterator.rb",
|
68
|
+
"test/test_batch_order.rb",
|
68
69
|
"test/test_configuration.rb",
|
69
70
|
"test/test_formatters.rb",
|
70
71
|
"test/test_output_writer.rb",
|
72
|
+
"test/test_retryable_typhoeus.rb",
|
71
73
|
"test/test_server_message.rb",
|
72
74
|
"unipept.gemspec"
|
73
75
|
]
|
@@ -83,28 +85,28 @@ Gem::Specification.new do |s|
|
|
83
85
|
|
84
86
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
85
87
|
s.add_runtime_dependency(%q<cri>, ["~> 2.7"])
|
86
|
-
s.add_runtime_dependency(%q<typhoeus>, ["
|
87
|
-
s.add_development_dependency(%q<rake>, ["
|
88
|
-
s.add_development_dependency(%q<minitest>, ["
|
89
|
-
s.add_development_dependency(%q<rubocop>, ["
|
90
|
-
s.add_development_dependency(%q<jeweler>, ["
|
88
|
+
s.add_runtime_dependency(%q<typhoeus>, ["= 0.7.2"])
|
89
|
+
s.add_development_dependency(%q<rake>, ["~> 10.4"])
|
90
|
+
s.add_development_dependency(%q<minitest>, ["~> 5.7"])
|
91
|
+
s.add_development_dependency(%q<rubocop>, ["~> 0.32"])
|
92
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
91
93
|
s.add_development_dependency(%q<coveralls>, [">= 0"])
|
92
94
|
else
|
93
95
|
s.add_dependency(%q<cri>, ["~> 2.7"])
|
94
|
-
s.add_dependency(%q<typhoeus>, ["
|
95
|
-
s.add_dependency(%q<rake>, ["
|
96
|
-
s.add_dependency(%q<minitest>, ["
|
97
|
-
s.add_dependency(%q<rubocop>, ["
|
98
|
-
s.add_dependency(%q<jeweler>, ["
|
96
|
+
s.add_dependency(%q<typhoeus>, ["= 0.7.2"])
|
97
|
+
s.add_dependency(%q<rake>, ["~> 10.4"])
|
98
|
+
s.add_dependency(%q<minitest>, ["~> 5.7"])
|
99
|
+
s.add_dependency(%q<rubocop>, ["~> 0.32"])
|
100
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
99
101
|
s.add_dependency(%q<coveralls>, [">= 0"])
|
100
102
|
end
|
101
103
|
else
|
102
104
|
s.add_dependency(%q<cri>, ["~> 2.7"])
|
103
|
-
s.add_dependency(%q<typhoeus>, ["
|
104
|
-
s.add_dependency(%q<rake>, ["
|
105
|
-
s.add_dependency(%q<minitest>, ["
|
106
|
-
s.add_dependency(%q<rubocop>, ["
|
107
|
-
s.add_dependency(%q<jeweler>, ["
|
105
|
+
s.add_dependency(%q<typhoeus>, ["= 0.7.2"])
|
106
|
+
s.add_dependency(%q<rake>, ["~> 10.4"])
|
107
|
+
s.add_dependency(%q<minitest>, ["~> 5.7"])
|
108
|
+
s.add_dependency(%q<rubocop>, ["~> 0.32"])
|
109
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
108
110
|
s.add_dependency(%q<coveralls>, [">= 0"])
|
109
111
|
end
|
110
112
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unipept
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toon Willems
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cri
|
@@ -30,72 +30,72 @@ dependencies:
|
|
30
30
|
name: typhoeus
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 0.7.2
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 0.7.2
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rake
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - "
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '10.4'
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - "
|
54
|
+
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '10.4'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: minitest
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- - "
|
61
|
+
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
63
|
+
version: '5.7'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- - "
|
68
|
+
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '
|
70
|
+
version: '5.7'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: rubocop
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - "
|
75
|
+
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
77
|
+
version: '0.32'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - "
|
82
|
+
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: '0'
|
84
|
+
version: '0.32'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: jeweler
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - "
|
89
|
+
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: '0'
|
91
|
+
version: '2.0'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- - "
|
96
|
+
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: '0'
|
98
|
+
version: '2.0'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: coveralls
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/configuration.rb
|
156
156
|
- lib/formatters.rb
|
157
157
|
- lib/output_writer.rb
|
158
|
+
- lib/retryable_typhoeus.rb
|
158
159
|
- lib/server_message.rb
|
159
160
|
- lib/version.rb
|
160
161
|
- test/commands/test_peptfilter.rb
|
@@ -169,11 +170,12 @@ files:
|
|
169
170
|
- test/commands/unipept/test_taxa2lca.rb
|
170
171
|
- test/commands/unipept/test_taxonomy.rb
|
171
172
|
- test/helper.rb
|
172
|
-
- test/test_bach_order.rb
|
173
173
|
- test/test_batch_iterator.rb
|
174
|
+
- test/test_batch_order.rb
|
174
175
|
- test/test_configuration.rb
|
175
176
|
- test/test_formatters.rb
|
176
177
|
- test/test_output_writer.rb
|
178
|
+
- test/test_retryable_typhoeus.rb
|
177
179
|
- test/test_server_message.rb
|
178
180
|
- unipept.gemspec
|
179
181
|
homepage: https://github.com/unipept/unipept-cli/
|