unipept 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -174,7 +174,7 @@ module Unipept
174
174
  Commands::Peptfilter.run(%w(-h))
175
175
  end
176
176
  end
177
- assert(out.include? 'show help for this command')
177
+ assert(out.include?('show help for this command'))
178
178
  end
179
179
  end
180
180
  end
@@ -81,7 +81,7 @@ module Unipept
81
81
  Commands::Prot2pept.run(%w(-h))
82
82
  end
83
83
  end
84
- assert(out.include? 'show help for this command')
84
+ assert(out.include?('show help for this command'))
85
85
  end
86
86
  end
87
87
  end
@@ -8,14 +8,14 @@ module Unipept
8
8
  Commands::Unipept.run(%w(-h))
9
9
  end
10
10
  end
11
- assert(out.include? 'show help for this command')
11
+ assert(out.include?('show help for this command'))
12
12
 
13
13
  out, _err = capture_io_while do
14
14
  assert_raises SystemExit do
15
15
  Commands::Unipept.run(%w(--help))
16
16
  end
17
17
  end
18
- assert(out.include? 'show help for this command')
18
+ assert(out.include?('show help for this command'))
19
19
  end
20
20
 
21
21
  def test_no_valid_subcommand
@@ -24,7 +24,7 @@ module Unipept
24
24
  Commands::Unipept.run(%w())
25
25
  end
26
26
  end
27
- assert(err.include? 'show help for this command')
27
+ assert(err.include?('show help for this command'))
28
28
  end
29
29
 
30
30
  def test_version
@@ -65,7 +65,7 @@ module Unipept
65
65
  end
66
66
  end
67
67
  assert_equal('', out)
68
- assert(err.include? 'xxx is not a valid output format')
68
+ assert(err.include?('xxx is not a valid output format'))
69
69
  end
70
70
 
71
71
  def test_default_format
@@ -130,7 +130,7 @@ module Unipept
130
130
  Commands::Uniprot.run(%w(-h))
131
131
  end
132
132
  end
133
- assert(out.include? 'show help for this command')
133
+ assert(out.include?('show help for this command'))
134
134
  end
135
135
  end
136
136
  end
@@ -75,7 +75,7 @@ module Unipept
75
75
  end
76
76
 
77
77
  def test_input_iterator_stdin
78
- runner = new_runner('test', host: 'https://param_host')
78
+ runner = new_runner('test', host: 'https://param_host')
79
79
  output = []
80
80
  _out, _err = capture_io_with_input(%w(a b c)) do
81
81
  runner.input_iterator.each { |el| output << el.chomp }
@@ -136,13 +136,13 @@ module Unipept
136
136
 
137
137
  def test_number_of_parallel_requests
138
138
  assert_equal(10, new_runner.concurrent_requests)
139
- runner = new_runner('test', host: 'http://param_host', parallel: '123')
139
+ runner = new_runner('test', host: 'http://param_host', parallel: '123')
140
140
  assert_equal(123, runner.concurrent_requests)
141
141
  end
142
142
 
143
143
  def test_queue_size
144
144
  assert_equal(200, new_runner.queue_size)
145
- runner = new_runner('test', host: 'http://param_host', parallel: '100')
145
+ runner = new_runner('test', host: 'http://param_host', parallel: '100')
146
146
  assert_equal(2000, runner.queue_size)
147
147
  end
148
148
 
@@ -152,7 +152,7 @@ module Unipept
152
152
  end
153
153
 
154
154
  def test_param_formatter
155
- runner = new_runner('test', host: 'http://param_host', format: 'json')
155
+ runner = new_runner('test', host: 'http://param_host', format: 'json')
156
156
  assert_equal('json', runner.formatter.type)
157
157
  end
158
158
 
@@ -170,7 +170,7 @@ module Unipept
170
170
  end
171
171
 
172
172
  def test_required_fields_are_selected
173
- runner = new_runner('test', host: 'http://param_host', select: 'field')
173
+ runner = new_runner('test', host: 'http://param_host', select: 'field')
174
174
  def runner.required_fields
175
175
  ['test']
176
176
  end
@@ -178,32 +178,32 @@ module Unipept
178
178
  end
179
179
 
180
180
  def test_single_selected_fields
181
- runner = new_runner('test', host: 'http://param_host', select: 'field')
181
+ runner = new_runner('test', host: 'http://param_host', select: 'field')
182
182
  assert_equal([/^field$/], runner.selected_fields)
183
183
  end
184
184
 
185
185
  def test_comma_selected_fields
186
- runner = new_runner('test', host: 'http://param_host', select: 'field1,field2')
186
+ runner = new_runner('test', host: 'http://param_host', select: 'field1,field2')
187
187
  assert_equal([/^field1$/, /^field2$/], runner.selected_fields)
188
188
  end
189
189
 
190
190
  def test_multiple_selected_fields
191
- runner = new_runner('test', host: 'http://param_host', select: %w(field1 field2))
191
+ runner = new_runner('test', host: 'http://param_host', select: %w(field1 field2))
192
192
  assert_equal([/^field1$/, /^field2$/], runner.selected_fields)
193
193
  end
194
194
 
195
195
  def test_combined_selected_fields
196
- runner = new_runner('test', host: 'http://param_host', select: ['field1', 'field2,field3'])
196
+ runner = new_runner('test', host: 'http://param_host', select: ['field1', 'field2,field3'])
197
197
  assert_equal([/^field1$/, /^field2$/, /^field3$/], runner.selected_fields)
198
198
  end
199
199
 
200
200
  def test_wildcard_selected_fields
201
- runner = new_runner('test', host: 'http://param_host', select: 'field*')
201
+ runner = new_runner('test', host: 'http://param_host', select: 'field*')
202
202
  assert_equal([/^field.*$/], runner.selected_fields)
203
203
  end
204
204
 
205
205
  def test_basic_construct_request_body
206
- runner = new_runner('test', host: 'http://param_host')
206
+ runner = new_runner('test', host: 'http://param_host')
207
207
  body = runner.construct_request_body('test')
208
208
  assert_equal('test', body[:input])
209
209
  assert_equal(false, body[:equate_il])
@@ -212,7 +212,7 @@ module Unipept
212
212
  end
213
213
 
214
214
  def test_equate_construct_request_body
215
- runner = new_runner('test', host: 'http://param_host', equate: true)
215
+ runner = new_runner('test', host: 'http://param_host', equate: true)
216
216
  body = runner.construct_request_body('test')
217
217
  assert_equal('test', body[:input])
218
218
  assert_equal(true, body[:equate_il])
@@ -221,7 +221,7 @@ module Unipept
221
221
  end
222
222
 
223
223
  def test_all_no_select_construct_request_body
224
- runner = new_runner('test', host: 'http://param_host', all: true)
224
+ runner = new_runner('test', host: 'http://param_host', all: true)
225
225
  body = runner.construct_request_body('test')
226
226
  assert_equal('test', body[:input])
227
227
  assert_equal(false, body[:equate_il])
@@ -230,7 +230,7 @@ module Unipept
230
230
  end
231
231
 
232
232
  def test_all_names_select_construct_request_body
233
- runner = new_runner('test', host: 'http://param_host', all: true, select: 'test,names')
233
+ runner = new_runner('test', host: 'http://param_host', all: true, select: 'test,names')
234
234
  body = runner.construct_request_body('test')
235
235
  assert_equal('test', body[:input])
236
236
  assert_equal(false, body[:equate_il])
@@ -239,7 +239,7 @@ module Unipept
239
239
  end
240
240
 
241
241
  def test_all_names_wildcard_select_construct_request_body
242
- runner = new_runner('test', host: 'http://param_host', all: true, select: 'test,order*')
242
+ runner = new_runner('test', host: 'http://param_host', all: true, select: 'test,order*')
243
243
  body = runner.construct_request_body('test')
244
244
  assert_equal('test', body[:input])
245
245
  assert_equal(false, body[:equate_il])
@@ -248,7 +248,7 @@ module Unipept
248
248
  end
249
249
 
250
250
  def test_all_no_names_select_construct_request_body
251
- runner = new_runner('test', host: 'http://param_host', all: true, select: 'test')
251
+ runner = new_runner('test', host: 'http://param_host', all: true, select: 'test')
252
252
  body = runner.construct_request_body('test')
253
253
  assert_equal('test', body[:input])
254
254
  assert_equal(false, body[:equate_il])
@@ -268,14 +268,14 @@ module Unipept
268
268
  _out, err = capture_io_while do
269
269
  runner.save_error('error message')
270
270
  end
271
- assert(err.start_with? 'API request failed! log can be found in')
271
+ assert(err.start_with?('API request failed! log can be found in'))
272
272
  assert_equal('error message', IO.foreach('errordir/error.log').next.chomp)
273
273
  end
274
274
  end
275
275
 
276
276
  def test_error_file_path
277
277
  runner = new_runner
278
- assert(runner.error_file_path.include? '/.unipept/')
278
+ assert(runner.error_file_path.include?('/.unipept/'))
279
279
  end
280
280
 
281
281
  def test_invalid_filter_result
@@ -329,7 +329,7 @@ module Unipept
329
329
  end
330
330
  out, err = capture_io_while(&lambda)
331
331
  assert_equal('', out)
332
- assert(err.chomp.start_with? 'request timed out')
332
+ assert(err.chomp.start_with?('request timed out'))
333
333
  end
334
334
 
335
335
  def test_code_0_handle_response
@@ -342,7 +342,7 @@ module Unipept
342
342
  end
343
343
  out, err = capture_io_while(&lambda)
344
344
  assert_equal('', out)
345
- assert(err.chomp.start_with? 'could not get an http')
345
+ assert(err.chomp.start_with?('could not get an http'))
346
346
  end
347
347
 
348
348
  def test_failed_handle_response
@@ -355,7 +355,7 @@ module Unipept
355
355
  end
356
356
  out, err = capture_io_while(&lambda)
357
357
  assert_equal('', out)
358
- assert(err.chomp.start_with? 'Got 10')
358
+ assert(err.chomp.start_with?('Got 10'))
359
359
  end
360
360
 
361
361
  def test_run
@@ -364,6 +364,7 @@ module Unipept
364
364
  def runner.input_iterator
365
365
  %w(0 1 2).each
366
366
  end
367
+
367
368
  def runner.batch_size
368
369
  2
369
370
  end
@@ -371,9 +372,9 @@ module Unipept
371
372
  end
372
373
  lines = out.each_line
373
374
  assert_equal('', err)
374
- assert(lines.next.start_with? 'taxon_id')
375
- assert(lines.next.start_with? '1,root')
376
- assert(lines.next.start_with? '2,Bacteria')
375
+ assert(lines.next.start_with?('taxon_id'))
376
+ assert(lines.next.start_with?('1,root'))
377
+ assert(lines.next.start_with?('2,Bacteria'))
377
378
  assert_raises(StopIteration) { lines.next }
378
379
  end
379
380
 
@@ -413,6 +414,7 @@ module Unipept
413
414
  def o.options
414
415
  ''
415
416
  end
417
+
416
418
  def o.encoded_body
417
419
  ''
418
420
  end
@@ -8,14 +8,14 @@ module Unipept
8
8
  Commands::Unipept.run(%w(config -h))
9
9
  end
10
10
  end
11
- assert(out.include? 'show help for this command')
11
+ assert(out.include?('show help for this command'))
12
12
 
13
13
  out, _err = capture_io_while do
14
14
  assert_raises SystemExit do
15
15
  Commands::Unipept.run(%w(config --help))
16
16
  end
17
17
  end
18
- assert(out.include? 'show help for this command')
18
+ assert(out.include?('show help for this command'))
19
19
  end
20
20
 
21
21
  def test_no_args
@@ -24,7 +24,7 @@ module Unipept
24
24
  Commands::Unipept.run(%w(config))
25
25
  end
26
26
  end
27
- assert(err.include? 'show help for this command')
27
+ assert(err.include?('show help for this command'))
28
28
  end
29
29
 
30
30
  def test_too_many_args
@@ -33,7 +33,7 @@ module Unipept
33
33
  Commands::Unipept.run(%w(config a b c))
34
34
  end
35
35
  end
36
- assert(err.include? 'show help for this command')
36
+ assert(err.include?('show help for this command'))
37
37
  end
38
38
 
39
39
  def test_setting_config
@@ -34,14 +34,14 @@ module Unipept
34
34
  Commands::Unipept.run(%w(pept2lca -h))
35
35
  end
36
36
  end
37
- assert(out.include? 'show help for this command')
37
+ assert(out.include?('show help for this command'))
38
38
 
39
39
  out, _err = capture_io_while do
40
40
  assert_raises SystemExit do
41
41
  Commands::Unipept.run(%w(pept2lca --help))
42
42
  end
43
43
  end
44
- assert(out.include? 'show help for this command')
44
+ assert(out.include?('show help for this command'))
45
45
  end
46
46
 
47
47
  def test_run
@@ -50,8 +50,8 @@ module Unipept
50
50
  end
51
51
  lines = out.each_line
52
52
  assert_equal('', err)
53
- assert(lines.next.start_with? 'peptide,taxon_id')
54
- assert(lines.next.start_with? 'AALTER,1,root,no rank')
53
+ assert(lines.next.start_with?('peptide,taxon_id'))
54
+ assert(lines.next.start_with?('AALTER,1,root,no rank'))
55
55
  assert_raises(StopIteration) { lines.next }
56
56
  end
57
57
 
@@ -61,10 +61,10 @@ module Unipept
61
61
  end
62
62
  lines = out.each_line
63
63
  assert_equal('', err)
64
- assert(lines.next.start_with? 'fasta_header,peptide,taxon_id')
65
- assert(lines.next.start_with? '>test,AALTER,1,root,no rank')
66
- assert(lines.next.start_with? '>test,AALER,1,root,no rank')
67
- assert(lines.next.start_with? '>tost,AALTER,1,root,no rank')
64
+ assert(lines.next.start_with?('fasta_header,peptide,taxon_id'))
65
+ assert(lines.next.start_with?('>test,AALTER,1,root,no rank'))
66
+ assert(lines.next.start_with?('>test,AALER,1,root,no rank'))
67
+ assert(lines.next.start_with?('>tost,AALTER,1,root,no rank'))
68
68
  assert_raises(StopIteration) { lines.next }
69
69
  end
70
70
 
@@ -74,10 +74,10 @@ module Unipept
74
74
  end
75
75
  lines = out.each_line
76
76
  assert_equal('', err)
77
- assert(lines.next.start_with? 'fasta_header,peptide,taxon_id')
78
- assert(lines.next.start_with? '>test,AALTER,1')
79
- assert(lines.next.start_with? '>test,AALER,1')
80
- assert(lines.next.start_with? '>tost,AALTER,1')
77
+ assert(lines.next.start_with?('fasta_header,peptide,taxon_id'))
78
+ assert(lines.next.start_with?('>test,AALTER,1'))
79
+ assert(lines.next.start_with?('>test,AALER,1'))
80
+ assert(lines.next.start_with?('>tost,AALTER,1'))
81
81
  assert_raises(StopIteration) { lines.next }
82
82
  end
83
83
 
@@ -88,10 +88,10 @@ module Unipept
88
88
  lines = out.each_line
89
89
  assert_equal('', err)
90
90
  output = lines.to_a.join('').chomp
91
- assert(output.start_with? '[')
92
- assert(output.end_with? ']')
91
+ assert(output.start_with?('['))
92
+ assert(output.end_with?(']'))
93
93
  assert(!output.include?('}{'))
94
- assert(output.include? 'fasta_header')
94
+ assert(output.include?('fasta_header'))
95
95
  end
96
96
 
97
97
  def test_run_with_fasta_multiple_batches_xml
@@ -101,9 +101,9 @@ module Unipept
101
101
  lines = out.each_line
102
102
  assert_equal('', err)
103
103
  output = lines.to_a.join('').chomp
104
- assert(output.start_with? '<results>')
105
- assert(output.end_with? '</results>')
106
- assert(output.include? '<fasta_header>')
104
+ assert(output.start_with?('<results>'))
105
+ assert(output.end_with?('</results>'))
106
+ assert(output.include?('<fasta_header>'))
107
107
  end
108
108
  end
109
109
  end
@@ -22,14 +22,14 @@ module Unipept
22
22
  Commands::Unipept.run(%w(pept2prot -h))
23
23
  end
24
24
  end
25
- assert(out.include? 'show help for this command')
25
+ assert(out.include?('show help for this command'))
26
26
 
27
27
  out, _err = capture_io_while do
28
28
  assert_raises SystemExit do
29
29
  Commands::Unipept.run(%w(pept2prot --help))
30
30
  end
31
31
  end
32
- assert(out.include? 'show help for this command')
32
+ assert(out.include?('show help for this command'))
33
33
  end
34
34
 
35
35
  def test_run
@@ -38,8 +38,8 @@ module Unipept
38
38
  end
39
39
  lines = out.each_line
40
40
  assert_equal('', err)
41
- assert(lines.next.start_with? 'peptide,uniprot_id,protein_name,taxon_id')
42
- assert(lines.next.start_with? 'ENFVYIAK,')
41
+ assert(lines.next.start_with?('peptide,uniprot_id,protein_name,taxon_id'))
42
+ assert(lines.next.start_with?('ENFVYIAK,'))
43
43
  end
44
44
 
45
45
  def test_run_with_fasta_multiple_batches
@@ -48,7 +48,7 @@ module Unipept
48
48
  end
49
49
  lines = out.each_line
50
50
  assert_equal('', err)
51
- assert(lines.next.start_with? 'fasta_header,peptide,uniprot_id,protein_name,taxon_id')
51
+ assert(lines.next.start_with?('fasta_header,peptide,uniprot_id,protein_name,taxon_id'))
52
52
  assert(lines.count { |line| line.start_with? '>test,EGGAGSSTGQR,' } >= 1)
53
53
  assert(lines.count { |line| line.start_with? '>test,ENFVYIAK,' } >= 1)
54
54
  assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
@@ -60,7 +60,7 @@ module Unipept
60
60
  end
61
61
  lines = out.each_line
62
62
  assert_equal('', err)
63
- assert(lines.next.start_with? 'fasta_header,peptide,uniprot_id')
63
+ assert(lines.next.start_with?('fasta_header,peptide,uniprot_id'))
64
64
  assert(lines.count { |line| line.start_with? '>test,EGGAGSSTGQR,' } >= 1)
65
65
  assert(lines.count { |line| line.start_with? '>test,ENFVYIAK,' } >= 1)
66
66
  assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
@@ -73,10 +73,10 @@ module Unipept
73
73
  lines = out.each_line
74
74
  assert_equal('', err)
75
75
  output = lines.to_a.join('').chomp
76
- assert(output.start_with? '[')
77
- assert(output.end_with? ']')
76
+ assert(output.start_with?('['))
77
+ assert(output.end_with?(']'))
78
78
  assert(!output.include?('}{'))
79
- assert(output.include? 'fasta_header')
79
+ assert(output.include?('fasta_header'))
80
80
  end
81
81
 
82
82
  def test_run_with_fasta_multiple_batches_xml
@@ -86,9 +86,9 @@ module Unipept
86
86
  lines = out.each_line
87
87
  assert_equal('', err)
88
88
  output = lines.to_a.join('').chomp
89
- assert(output.start_with? '<results>')
90
- assert(output.end_with? '</results>')
91
- assert(output.include? '<fasta_header>')
89
+ assert(output.start_with?('<results>'))
90
+ assert(output.end_with?('</results>'))
91
+ assert(output.include?('<fasta_header>'))
92
92
  end
93
93
  end
94
94
  end
@@ -22,14 +22,14 @@ module Unipept
22
22
  Commands::Unipept.run(%w(pept2taxa -h))
23
23
  end
24
24
  end
25
- assert(out.include? 'show help for this command')
25
+ assert(out.include?('show help for this command'))
26
26
 
27
27
  out, _err = capture_io_while do
28
28
  assert_raises SystemExit do
29
29
  Commands::Unipept.run(%w(pept2taxa --help))
30
30
  end
31
31
  end
32
- assert(out.include? 'show help for this command')
32
+ assert(out.include?('show help for this command'))
33
33
  end
34
34
 
35
35
  def test_run
@@ -38,8 +38,8 @@ module Unipept
38
38
  end
39
39
  lines = out.each_line
40
40
  assert_equal('', err)
41
- assert(lines.next.start_with? 'peptide,taxon_id,taxon_name,taxon_rank')
42
- assert(lines.next.start_with? 'ENFVYIAK,')
41
+ assert(lines.next.start_with?('peptide,taxon_id,taxon_name,taxon_rank'))
42
+ assert(lines.next.start_with?('ENFVYIAK,'))
43
43
  end
44
44
 
45
45
  def test_run_with_fasta_multiple_batches
@@ -48,7 +48,7 @@ module Unipept
48
48
  end
49
49
  lines = out.each_line
50
50
  assert_equal('', err)
51
- assert(lines.next.start_with? 'fasta_header,peptide,taxon_id,taxon_name,taxon_rank')
51
+ assert(lines.next.start_with?('fasta_header,peptide,taxon_id,taxon_name,taxon_rank'))
52
52
  assert(lines.count { |line| line.start_with? '>test,EGGAGSSTGQR,' } >= 1)
53
53
  assert(lines.count { |line| line.start_with? '>test,ENFVYIAK,' } >= 1)
54
54
  assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
@@ -60,7 +60,7 @@ module Unipept
60
60
  end
61
61
  lines = out.each_line
62
62
  assert_equal('', err)
63
- assert(lines.next.start_with? 'fasta_header,peptide,taxon_id')
63
+ assert(lines.next.start_with?('fasta_header,peptide,taxon_id'))
64
64
  assert(lines.count { |line| line.start_with? '>test,EGGAGSSTGQR,' } >= 1)
65
65
  assert(lines.count { |line| line.start_with? '>test,ENFVYIAK,' } >= 1)
66
66
  assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
@@ -73,10 +73,10 @@ module Unipept
73
73
  lines = out.each_line
74
74
  assert_equal('', err)
75
75
  output = lines.to_a.join('').chomp
76
- assert(output.start_with? '[')
77
- assert(output.end_with? ']')
76
+ assert(output.start_with?('['))
77
+ assert(output.end_with?(']'))
78
78
  assert(!output.include?('}{'))
79
- assert(output.include? 'fasta_header')
79
+ assert(output.include?('fasta_header'))
80
80
  end
81
81
 
82
82
  def test_run_with_fasta_multiple_batches_xml
@@ -86,9 +86,9 @@ module Unipept
86
86
  lines = out.each_line
87
87
  assert_equal('', err)
88
88
  output = lines.to_a.join('').chomp
89
- assert(output.start_with? '<results>')
90
- assert(output.end_with? '</results>')
91
- assert(output.include? '<fasta_header>')
89
+ assert(output.start_with?('<results>'))
90
+ assert(output.end_with?('</results>'))
91
+ assert(output.include?('<fasta_header>'))
92
92
  end
93
93
  end
94
94
  end