unipept 1.1.0 → 1.1.1

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: e4a1d5d01af5e00b706fe387a78a1a661d11a0ed
4
- data.tar.gz: 22064ff35a1789a2cbc48fca2c4f4ec967c3d3a0
3
+ metadata.gz: f9e7aed1832989eddf44ce10e5ae42dc4976bf31
4
+ data.tar.gz: d23fd6021eeb04bc4c6cb9b077f0fca978422f38
5
5
  SHA512:
6
- metadata.gz: e880e9f0737b91efae32a9724cb20ded630af7ad6bc3853af3b3993ebafea024d957f66d9fb14315f2670ade638dc7d708cafb92e54d540906ad1539a529c334
7
- data.tar.gz: f7cd476ef08424f6a840033a33a025c70ce6eebeda8e71ea454c89246696678cb5049460bdc32904b54b72a447778d5b4aae01f134ac375153560bc5e9b1e684
6
+ metadata.gz: 6eeb2ca9e7dbbc13a0dd2c99a8aa3284cbca52250173060e4615f2b69d5d9b1cd27565c5cebc81275234d8f65542c07f4795f3d1b7bff71d89bb7b2bef9334f8
7
+ data.tar.gz: 6e79d4bf72af62e0c90c67e8f63a1eaa647850dfb616d225a2521a237274153e96887007f580bf83f5eab3112112f65bb2d6fdbde15a4630044bf3f63f2e6b04
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- - 2.1.6
3
+ - 2.3.1
4
+ - 2.2.5
5
+ - 2.1.9
5
6
  - 2.0.0
6
7
  - 1.9.3
7
8
  # - jruby-19mode
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -20,6 +20,7 @@ module Unipept::Commands
20
20
  end
21
21
  run do |opts, _args, _cmd|
22
22
  pattern = opts.fetch(:pattern, '([KR])([^P])')
23
+ pattern = Regexp.compile(pattern)
23
24
 
24
25
  # decide if we have FASTA input
25
26
  first_char = $stdin.getc
@@ -33,7 +34,7 @@ module Unipept::Commands
33
34
  protein = ''
34
35
  puts line
35
36
  else
36
- protein += line.chomp
37
+ protein << line.chomp
37
38
  end
38
39
  end
39
40
  puts Prot2pept.split(protein, pattern)
@@ -46,7 +47,7 @@ module Unipept::Commands
46
47
  end
47
48
 
48
49
  def self.split(protein, pattern)
49
- protein.gsub(/\*/, "\n").gsub(/#{pattern}/, "\\1\n\\2").gsub(/#{pattern}/, "\\1\n\\2").split("\n").reject(&:empty?)
50
+ protein.tr('*', "\n").gsub(pattern, "\\1\n\\2").gsub(pattern, "\\1\n\\2").split("\n").reject(&:empty?)
50
51
  end
51
52
 
52
53
  # Invokes the uniprot command-line tool with the given arguments.
@@ -60,6 +60,11 @@ module Unipept
60
60
  end
61
61
  end
62
62
 
63
+ # returns the required fields to do any mapping
64
+ def required_fields
65
+ []
66
+ end
67
+
63
68
  # Returns a new batch_iterator based on the batch_size
64
69
  def batch_iterator
65
70
  Unipept::BatchIterator.new(batch_size)
@@ -79,7 +84,10 @@ module Unipept
79
84
 
80
85
  # Returns an array of regular expressions containing all the selected fields
81
86
  def selected_fields
82
- @selected_fields ||= [*options[:select]].map { |f| f.split(',') }.flatten.map { |f| glob_to_regex(f) }
87
+ return @selected_fields unless @selected_fields.nil?
88
+ fields = [*options[:select]].map { |f| f.split(',') }.flatten
89
+ fields.concat(required_fields) unless fields.empty?
90
+ @selected_fields = fields.map { |f| glob_to_regex(f) }
83
91
  end
84
92
 
85
93
  # Returns a formatter, based on the format specified in the options
@@ -1,6 +1,10 @@
1
1
  require_relative 'api_runner'
2
2
  module Unipept::Commands
3
3
  class Pept2lca < ApiRunner
4
+ def required_fields
5
+ ['peptide']
6
+ end
7
+
4
8
  def default_batch_size
5
9
  if options[:all]
6
10
  100
@@ -2,6 +2,10 @@ require_relative 'api_runner'
2
2
 
3
3
  module Unipept::Commands
4
4
  class Pept2prot < ApiRunner
5
+ def required_fields
6
+ ['peptide']
7
+ end
8
+
5
9
  def default_batch_size
6
10
  if options[:all]
7
11
  5
@@ -1,6 +1,10 @@
1
1
  require_relative 'api_runner'
2
2
  module Unipept::Commands
3
3
  class Pept2taxa < ApiRunner
4
+ def required_fields
5
+ ['peptide']
6
+ end
7
+
4
8
  def default_batch_size
5
9
  if options[:all]
6
10
  5
@@ -1,6 +1,10 @@
1
1
  require_relative 'api_runner'
2
2
  module Unipept::Commands
3
3
  class Taxonomy < ApiRunner
4
+ def required_fields
5
+ ['taxon_id']
6
+ end
7
+
4
8
  def default_batch_size
5
9
  100
6
10
  end
@@ -103,6 +103,18 @@ module Unipept
103
103
  assert_equal(%w(a b c), output)
104
104
  end
105
105
 
106
+ def test_required_fields
107
+ assert_equal([], new_runner.required_fields)
108
+ end
109
+
110
+ def test_required_fields_configurable
111
+ r = new_runner
112
+ def r.required_fields
113
+ ['test']
114
+ end
115
+ assert_equal(['test'], r.required_fields)
116
+ end
117
+
106
118
  def test_default_batch_size
107
119
  assert_raises NotImplementedError do
108
120
  new_runner.default_batch_size
@@ -149,6 +161,22 @@ module Unipept
149
161
  assert_equal([], runner.selected_fields)
150
162
  end
151
163
 
164
+ def test_required_fields_are_not_selected_with_empty_selection
165
+ runner = new_runner
166
+ def runner.required_fields
167
+ ['test']
168
+ end
169
+ assert_equal([], runner.selected_fields)
170
+ end
171
+
172
+ def test_required_fields_are_selected
173
+ runner = new_runner('test', host: 'http://param_host', select: 'field')
174
+ def runner.required_fields
175
+ ['test']
176
+ end
177
+ assert_equal([/^field$/, /^test$/], runner.selected_fields)
178
+ end
179
+
152
180
  def test_single_selected_fields
153
181
  runner = new_runner('test', host: 'http://param_host', select: 'field')
154
182
  assert_equal([/^field$/], runner.selected_fields)
@@ -10,6 +10,12 @@ module Unipept
10
10
  assert_equal(100, pept2lca.default_batch_size)
11
11
  end
12
12
 
13
+ def test_required_fields
14
+ command = Cri::Command.define { name 'pept2lca' }
15
+ pept2lca = Commands::Pept2lca.new({ host: 'http://api.unipept.ugent.be' }, [], command)
16
+ assert_equal(['peptide'], pept2lca.required_fields)
17
+ end
18
+
13
19
  def test_argument_batch_size
14
20
  command = Cri::Command.define { name 'pept2lca' }
15
21
  pept2lca = Commands::Pept2lca.new({ host: 'http://api.unipept.ugent.be', batch: '123' }, [], command)
@@ -62,6 +68,19 @@ module Unipept
62
68
  assert_raises(StopIteration) { lines.next }
63
69
  end
64
70
 
71
+ def test_run_with_fasta_multiple_batches_and_select
72
+ out, err = capture_io_while do
73
+ Commands::Unipept.run(%w(pept2lca --host http://api.unipept.ugent.be --batch 2 --select taxon_id >test AALTER AALER >tost AALTER))
74
+ end
75
+ lines = out.each_line
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')
81
+ assert_raises(StopIteration) { lines.next }
82
+ end
83
+
65
84
  def test_run_with_fasta_multiple_batches_json
66
85
  out, err = capture_io_while do
67
86
  Commands::Unipept.run(%w(pept2lca --host http://api.unipept.ugent.be --batch 2 --format json >test AALTER AALER >tost AALTER))
@@ -10,6 +10,12 @@ module Unipept
10
10
  assert_equal(5, pept2prot.default_batch_size)
11
11
  end
12
12
 
13
+ def test_required_fields
14
+ command = Cri::Command.define { name 'pept2prot' }
15
+ pept2prot = Commands::Pept2prot.new({ host: 'http://api.unipept.ugent.be' }, [], command)
16
+ assert_equal(['peptide'], pept2prot.required_fields)
17
+ end
18
+
13
19
  def test_help
14
20
  out, _err = capture_io_while do
15
21
  assert_raises SystemExit do
@@ -48,6 +54,18 @@ module Unipept
48
54
  assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
49
55
  end
50
56
 
57
+ def test_run_with_fasta_multiple_batches_and_select
58
+ out, err = capture_io_while do
59
+ Commands::Unipept.run(%w(pept2prot --host http://api.unipept.ugent.be --batch 2 --select uniprot_id >test EGGAGSSTGQR ENFVYIAK >tost EGGAGSSTGQR))
60
+ end
61
+ lines = out.each_line
62
+ assert_equal('', err)
63
+ assert(lines.next.start_with? 'fasta_header,peptide,uniprot_id')
64
+ assert(lines.count { |line| line.start_with? '>test,EGGAGSSTGQR,' } >= 1)
65
+ assert(lines.count { |line| line.start_with? '>test,ENFVYIAK,' } >= 1)
66
+ assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
67
+ end
68
+
51
69
  def test_run_with_fasta_multiple_batches_json
52
70
  out, err = capture_io_while do
53
71
  Commands::Unipept.run(%w(pept2prot --host http://api.unipept.ugent.be --batch 2 --format json >test EGGAGSSTGQR ENFVYIAK >tost EGGAGSSTGQR))
@@ -10,6 +10,12 @@ module Unipept
10
10
  assert_equal(5, pept2taxa.default_batch_size)
11
11
  end
12
12
 
13
+ def test_required_fields
14
+ command = Cri::Command.define { name 'pept2taxa' }
15
+ pept2taxa = Commands::Pept2taxa.new({ host: 'http://api.unipept.ugent.be' }, [], command)
16
+ assert_equal(['peptide'], pept2taxa.required_fields)
17
+ end
18
+
13
19
  def test_help
14
20
  out, _err = capture_io_while do
15
21
  assert_raises SystemExit do
@@ -48,6 +54,18 @@ module Unipept
48
54
  assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
49
55
  end
50
56
 
57
+ def test_run_with_fasta_multiple_batches_and_select
58
+ out, err = capture_io_while do
59
+ Commands::Unipept.run(%w(pept2taxa --host http://api.unipept.ugent.be --batch 2 --select taxon_id >test EGGAGSSTGQR ENFVYIAK >tost EGGAGSSTGQR))
60
+ end
61
+ lines = out.each_line
62
+ assert_equal('', err)
63
+ assert(lines.next.start_with? 'fasta_header,peptide,taxon_id')
64
+ assert(lines.count { |line| line.start_with? '>test,EGGAGSSTGQR,' } >= 1)
65
+ assert(lines.count { |line| line.start_with? '>test,ENFVYIAK,' } >= 1)
66
+ assert(lines.count { |line| line.start_with? '>tost,EGGAGSSTGQR,' } >= 1)
67
+ end
68
+
51
69
  def test_run_with_fasta_multiple_batches_json
52
70
  out, err = capture_io_while do
53
71
  Commands::Unipept.run(%w(pept2taxa --host http://api.unipept.ugent.be --batch 2 --format json >test EGGAGSSTGQR ENFVYIAK >tost EGGAGSSTGQR))
@@ -10,6 +10,12 @@ module Unipept
10
10
  end
11
11
  end
12
12
 
13
+ def test_required_fields
14
+ command = Cri::Command.define { name 'taxa2lca' }
15
+ taxa2lca = Commands::Taxa2lca.new({ host: 'http://api.unipept.ugent.be' }, [], command)
16
+ assert_equal([], taxa2lca.required_fields)
17
+ end
18
+
13
19
  def test_help
14
20
  out, _err = capture_io_while do
15
21
  assert_raises SystemExit do
@@ -8,6 +8,12 @@ module Unipept
8
8
  assert_equal(100, taxonomy.default_batch_size)
9
9
  end
10
10
 
11
+ def test_required_fields
12
+ command = Cri::Command.define { name 'taxonomy' }
13
+ taxonomy = Commands::Taxonomy.new({ host: 'http://api.unipept.ugent.be' }, [], command)
14
+ assert_equal(['taxon_id'], taxonomy.required_fields)
15
+ end
16
+
11
17
  def test_help
12
18
  out, _err = capture_io_while do
13
19
  assert_raises SystemExit do
@@ -46,6 +52,18 @@ module Unipept
46
52
  assert(lines.count { |line| line.start_with? '>tost,1,' } >= 1)
47
53
  end
48
54
 
55
+ def test_run_with_fasta_multiple_batches_and_select
56
+ out, err = capture_io_while do
57
+ Commands::Unipept.run(%w(taxonomy --host http://api.unipept.ugent.be --batch 2 --select taxon_name >test 1 216816 >tost 1))
58
+ end
59
+ lines = out.each_line
60
+ assert_equal('', err)
61
+ assert(lines.next.start_with? 'fasta_header,taxon_id,taxon_name')
62
+ assert(lines.count { |line| line.start_with? '>test,1,' } >= 1)
63
+ assert(lines.count { |line| line.start_with? '>test,216816,' } >= 1)
64
+ assert(lines.count { |line| line.start_with? '>tost,1,' } >= 1)
65
+ end
66
+
49
67
  def test_run_with_fasta_multiple_batches_json
50
68
  out, err = capture_io_while do
51
69
  Commands::Unipept.run(%w(taxonomy --host http://api.unipept.ugent.be --batch 2 --format json >test 1 216816 >tost 1))
@@ -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.1.0 ruby lib
5
+ # stub: unipept 1.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "unipept"
9
- s.version = "1.1.0"
9
+ s.version = "1.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Toon Willems", "Bart Mesuere", "Tom Naessens"]
14
- s.date = "2015-09-16"
14
+ s.date = "2016-06-12"
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"
16
16
  s.email = "unipept@ugent.be"
17
17
  s.executables = ["unipept", "prot2pept", "peptfilter", "uniprot"]
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.1.0
4
+ version: 1.1.1
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-09-16 00:00:00.000000000 Z
13
+ date: 2016-06-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cri