unipept 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59580ce92eedf89d921c0f37dc980c7a2ac4e2a2
4
- data.tar.gz: 064e088ee2208683820c27e5331a8005beeb4753
3
+ metadata.gz: 6e803f0d77ccd06f8b983f3fac7d51ebc5c170e6
4
+ data.tar.gz: f30e852d61c6a69c250306148fc2fa1a064f63f7
5
5
  SHA512:
6
- metadata.gz: 9a8aa82f5cd23581eea54eaae828a96a90055794e39129caf3004c0104b3dfefd57149060b1ace6c50cf85b94dc4a208370186f9b5c5e7fce026bd0658a3ef32
7
- data.tar.gz: 326a285c3753138a388c7bfbfce1cd773b9038c2af4c1cd9e3a186989325ebfe983728abb2741c34b044ca33496474953bd1a763470a46f37bd18a9d9c1240f3
6
+ metadata.gz: fb053972592c1c18b33304c6f39d7db8ebcfcb8dedf1ed99c53a9ad8d73121feff1b8f806c6b7f80bc75bab0c03e9ae272122020ab716093fd9d7a30e1a16c2f
7
+ data.tar.gz: 7664a300163ceed13732c7286b017e9e28e08ebfc39072b15321cce85d12db60d26de79a52f50f4d70aa2528f4e222e1b451fd3f027fa6072e293895dbe66799
@@ -7,6 +7,7 @@ rvm:
7
7
  - 2.0.0
8
8
 
9
9
  install:
10
+ - gem update --system
10
11
  - bundle install --without release
11
12
 
12
13
  notifications:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
@@ -51,6 +51,7 @@ module Unipept
51
51
  EOS
52
52
  flag :v, :version, 'displays the version'
53
53
  flag :q, :quiet, 'disable service messages'
54
+ flag nil, :'no-header', 'disable header in csv output', hidden: true
54
55
  option :i, :input, 'read input from file', argument: :required
55
56
  option nil, :batch, 'specify the batch size', argument: :required, hidden: true
56
57
  option nil, :parallel, 'specify the number of parallel requests', argument: :required, hidden: true
@@ -15,6 +15,7 @@ module Unipept
15
15
  @host = host
16
16
  @user_agent = 'Unipept CLI - unipept ' + Unipept::VERSION
17
17
  @url = "#{@host}/api/v1/#{cmd.name}.json"
18
+ @fasta = false
18
19
  end
19
20
 
20
21
  # Returns the host. If a value is defined by both an option and the config
@@ -86,7 +87,7 @@ module Unipept
86
87
  def selected_fields
87
88
  return @selected_fields unless @selected_fields.nil?
88
89
  fields = [*options[:select]].map { |f| f.split(',') }.flatten
89
- fields.concat(required_fields) unless fields.empty?
90
+ fields.concat(required_fields) if @fasta && !fields.empty?
90
91
  @selected_fields = fields.map { |f| glob_to_regex(f) }
91
92
  end
92
93
 
@@ -114,6 +115,7 @@ module Unipept
114
115
 
115
116
  batch_iterator.iterate(input_iterator) do |input_slice, batch_id, fasta_mapper|
116
117
  last_id = batch_id
118
+ @fasta = !fasta_mapper.nil?
117
119
  request = ::RetryableTyphoeus::Request.new(
118
120
  @url,
119
121
  method: :post,
@@ -165,7 +167,7 @@ module Unipept
165
167
 
166
168
  lambda do
167
169
  unless result.empty?
168
- output_writer.write_line formatter.header(result, fasta_mapper) if batch_id.zero?
170
+ output_writer.write_line formatter.header(result, fasta_mapper) if batch_id.zero? && !options[:"no-header"]
169
171
  output_writer.write_line formatter.format(result, fasta_mapper, batch_id.zero?)
170
172
  end
171
173
  end
@@ -32,7 +32,7 @@ module Unipept
32
32
  #
33
33
  # @return [Array<String>] The list of available formatters
34
34
  def self.available
35
- formatters.keys
35
+ formatters.select { |_key, value| !value.hidden? }.keys
36
36
  end
37
37
 
38
38
  # @return [String] The type of the default formatter: csv
@@ -45,6 +45,10 @@ module Unipept
45
45
  raise NotImplementedError, 'This must be implemented in a subclass.'
46
46
  end
47
47
 
48
+ def self.hidden?
49
+ false
50
+ end
51
+
48
52
  # Returns the header row for the given sample_data and fasta_mapper. This
49
53
  # row is output only once at the beginning of the output
50
54
  #
@@ -263,6 +267,10 @@ module Unipept
263
267
  'blast'
264
268
  end
265
269
 
270
+ def self.hidden?
271
+ true
272
+ end
273
+
266
274
  def header(_data, _fasta_mapper = nil)
267
275
  ''
268
276
  end
@@ -170,14 +170,24 @@ module Unipept
170
170
  assert_equal([], runner.selected_fields)
171
171
  end
172
172
 
173
- def test_required_fields_are_selected
173
+ def test_required_fields_are_selected_for_fasta
174
174
  runner = new_runner('test', host: 'http://param_host', select: 'field')
175
175
  def runner.required_fields
176
176
  ['test']
177
177
  end
178
+ runner.instance_variable_set(:@fasta, true)
178
179
  assert_equal([/^field$/, /^test$/], runner.selected_fields)
179
180
  end
180
181
 
182
+ def test_required_fields_are_not_selected_if_not_fasta
183
+ runner = new_runner('test', host: 'http://param_host', select: 'field')
184
+ def runner.required_fields
185
+ ['test']
186
+ end
187
+ runner.instance_variable_set(:@fasta, false)
188
+ assert_equal([/^field$/], runner.selected_fields)
189
+ end
190
+
181
191
  def test_single_selected_fields
182
192
  runner = new_runner('test', host: 'http://param_host', select: 'field')
183
193
  assert_equal([/^field$/], runner.selected_fields)
@@ -308,6 +318,18 @@ module Unipept
308
318
  assert_equal('value2,value2', lines.next.chomp)
309
319
  end
310
320
 
321
+ def test_success_no_header_option_handle_response
322
+ runner = new_runner('test', Hash[:host, 'test', :'no-header', true])
323
+ response = new_response(success: true, response_body: '[{"key1":"value1","key2":"value1"},{"key1":"value2","key2":"value2"}]')
324
+ lambda = runner.handle_response(response, 0, nil)
325
+ assert(lambda.lambda?)
326
+ out, err = capture_io_while(&lambda)
327
+ lines = out.each_line
328
+ assert_equal('', err)
329
+ assert_equal('value1,value1', lines.next.chomp)
330
+ assert_equal('value2,value2', lines.next.chomp)
331
+ end
332
+
311
333
  def test_success_no_header_handle_response
312
334
  runner = new_runner
313
335
  response = new_response(success: true, response_body: '[{"key1":"value1","key2":"value1"},{"key1":"value2","key2":"value2"}]')
@@ -7,7 +7,7 @@ module Unipept
7
7
  assert(formatters.include?('json'))
8
8
  assert(formatters.include?('csv'))
9
9
  assert(formatters.include?('xml'))
10
- assert(formatters.include?('blast'))
10
+ assert(!formatters.include?('blast'))
11
11
  end
12
12
 
13
13
  def test_default_formatter
@@ -2,16 +2,16 @@
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 1.2.0 ruby lib
5
+ # stub: unipept 1.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "unipept".freeze
9
- s.version = "1.2.0"
9
+ s.version = "1.3.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Toon Willems".freeze, "Bart Mesuere".freeze, "Tom Naessens".freeze]
14
- s.date = "2017-01-18"
14
+ s.date = "2017-01-28"
15
15
  s.description = " Command line interface to the Unipept (http://unipept.ugent.be) web services\n (pept2lca, taxa2lca, pept2taxa, pept2prot and taxonomy) and some utility\n commands for handling proteins using the command line.\n".freeze
16
16
  s.email = "unipept@ugent.be".freeze
17
17
  s.executables = ["unipept".freeze, "prot2pept".freeze, "peptfilter".freeze, "uniprot".freeze]
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: 1.2.0
4
+ version: 1.3.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: 2017-01-18 00:00:00.000000000 Z
13
+ date: 2017-01-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cri