unipept 1.1.3 → 1.2.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: 17fb4ae25816764349c1961d48289be0841b3e6a
4
- data.tar.gz: b484dc7db887da7172d408c75611083914d34049
3
+ metadata.gz: 59580ce92eedf89d921c0f37dc980c7a2ac4e2a2
4
+ data.tar.gz: 064e088ee2208683820c27e5331a8005beeb4753
5
5
  SHA512:
6
- metadata.gz: b4066aae51893a28a45fcaccb77f847c41ab39d8fa997e7445a16683904a9270a9b663e01e99860c0d65c5dd08cf941ce8d938081e252d677d6c9512d0ecd2b7
7
- data.tar.gz: ef1144113dc60261e27b23d90c351f59410bdb7701203b81309e37d2e72aa21f1c7e8c663ef3488d019d9cab763f14b7da437a8a49a2cb034b271490728d084c
6
+ metadata.gz: 9a8aa82f5cd23581eea54eaae828a96a90055794e39129caf3004c0104b3dfefd57149060b1ace6c50cf85b94dc4a208370186f9b5c5e7fce026bd0658a3ef32
7
+ data.tar.gz: 326a285c3753138a388c7bfbfce1cd773b9038c2af4c1cd9e3a186989325ebfe983728abb2741c34b044ca33496474953bd1a763470a46f37bd18a9d9c1240f3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.3
1
+ 1.2.0
@@ -2,6 +2,15 @@ require_relative 'api_runner'
2
2
 
3
3
  module Unipept::Commands
4
4
  class Pept2prot < ApiRunner
5
+ def initialize(args, opts, cmd)
6
+ if args[:meganize]
7
+ args[:all] = true
8
+ args[:select] = ['peptide,refseq_protein_ids']
9
+ args[:format] = 'blast'
10
+ end
11
+ super
12
+ end
13
+
5
14
  def required_fields
6
15
  ['peptide']
7
16
  end
@@ -180,6 +180,7 @@ module Unipept
180
180
  flag :e, :equate, 'equate isoleucine (I) and leucine (L) when matching peptides'
181
181
  flag :a, :all, 'report all information fields of UniProt entries available in Unipept. Note that this may have a performance penalty.'
182
182
  option :s, :select, 'select the information fields to return. Selected fields are passed as a comma separated list of field names. Multiple -s (or --select) options may be used.', argument: :required, multiple: true
183
+ option nil, :meganize, 'output the results in a BlastTab-like format that MEGAN can understand'
183
184
 
184
185
  runner Commands::Pept2prot
185
186
  end
data/lib/formatters.rb CHANGED
@@ -254,4 +254,37 @@ module Unipept
254
254
  data.map { |row| '<result>' + row.to_xml + '</result>' }.join('')
255
255
  end
256
256
  end
257
+
258
+ class BlastFormatter < Formatter
259
+ register :blast
260
+
261
+ # @return [String] The type of the current formatter: blast
262
+ def type
263
+ 'blast'
264
+ end
265
+
266
+ def header(_data, _fasta_mapper = nil)
267
+ ''
268
+ end
269
+
270
+ def footer
271
+ ''
272
+ end
273
+
274
+ # Converts the given input data to the Blast format.
275
+ #
276
+ # @param [Array] data The data we wish to convert
277
+ #
278
+ # @param [Boolean] Is this the first output batch?
279
+ #
280
+ # @return [String] The converted input data in the Blast format
281
+ def convert(data, _first)
282
+ data
283
+ .reject { |o| o['refseq_protein_ids'].empty? }
284
+ .map do |o|
285
+ "#{o['peptide']}\tref|#{o['refseq_protein_ids']}|\t100\t10\t0\t0\t0\t10\t0\t10\t1e-100\t100\n"
286
+ end
287
+ .join
288
+ end
289
+ end
257
290
  end
@@ -166,6 +166,7 @@ module Unipept
166
166
  def runner.required_fields
167
167
  ['test']
168
168
  end
169
+ runner.required_fields
169
170
  assert_equal([], runner.selected_fields)
170
171
  end
171
172
 
@@ -16,6 +16,22 @@ module Unipept
16
16
  assert_equal(['peptide'], pept2prot.required_fields)
17
17
  end
18
18
 
19
+ def test_meganize_options
20
+ command = Cri::Command.define { name 'pept2prot' }
21
+ pept2prot = Commands::Pept2prot.new({ meganize: true, host: 'http://api.unipept.ugent.be' }, [], command)
22
+ assert(pept2prot.options[:all])
23
+ assert_equal(['peptide,refseq_protein_ids'], pept2prot.options[:select])
24
+ assert_equal('blast', pept2prot.options[:format])
25
+ end
26
+
27
+ def test_meganize_options_overridecommand
28
+ command = Cri::Command.define { name 'pept2prot' }
29
+ pept2prot = Commands::Pept2prot.new({ meganize: true, format: 'xml', all: false, select: ['something'], host: 'http://api.unipept.ugent.be' }, [], command)
30
+ assert(pept2prot.options[:all])
31
+ assert_equal(['peptide,refseq_protein_ids'], pept2prot.options[:select])
32
+ assert_equal('blast', pept2prot.options[:format])
33
+ end
34
+
19
35
  def test_help
20
36
  out, _err = capture_io_while do
21
37
  assert_raises SystemExit do
@@ -7,6 +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
11
  end
11
12
 
12
13
  def test_default_formatter
@@ -29,6 +30,9 @@ module Unipept
29
30
  formatter = Formatter.new_for_format('csv')
30
31
  assert_equal('csv', formatter.type)
31
32
 
33
+ formatter = Formatter.new_for_format('blast')
34
+ assert_equal('blast', formatter.type)
35
+
32
36
  formatter = Formatter.new_for_format('blah')
33
37
  assert_equal('csv', formatter.type)
34
38
  end
@@ -121,6 +125,31 @@ module Unipept
121
125
  end
122
126
  end
123
127
 
128
+ class BlastFormatterTestCase < Unipept::TestCase
129
+ def formatter
130
+ Formatter.new_for_format('blast')
131
+ end
132
+
133
+ def test_header
134
+ assert_equal('', formatter.header(nil, nil))
135
+ end
136
+
137
+ def test_footer
138
+ assert_equal('', formatter.footer)
139
+ end
140
+
141
+ def test_type
142
+ assert_equal('blast', formatter.type)
143
+ end
144
+
145
+ def test_convert
146
+ object = [{ 'peptide' => 'MDGTEYIIVK', 'refseq_protein_ids' => 'WP_008705701.1' }, { 'peptide' => 'ISVAQGASK', 'refseq_protein_ids' => 'NP_003881.2 XP_011547112.1 XP_011547113.1' }, { 'peptide' => 'ISVAQGASK', 'refseq_protein_ids' => '' }]
147
+ output = "MDGTEYIIVK\tref|WP_008705701.1|\t100\t10\t0\t0\t0\t10\t0\t10\t1e-100\t100\nISVAQGASK\tref|NP_003881.2 XP_011547112.1 XP_011547113.1|\t100\t10\t0\t0\t0\t10\t0\t10\t1e-100\t100\n"
148
+ assert_equal(output, formatter.convert(object, true))
149
+ assert_equal(output, formatter.convert(object, false))
150
+ end
151
+ end
152
+
124
153
  class CSVFormatterTestCase < Unipept::TestCase
125
154
  def formatter
126
155
  Formatter.new_for_format('csv')
data/unipept.gemspec CHANGED
@@ -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.3 ruby lib
5
+ # stub: unipept 1.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "unipept".freeze
9
- s.version = "1.1.3"
9
+ s.version = "1.2.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-17"
14
+ s.date = "2017-01-18"
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.1.3
4
+ version: 1.2.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-17 00:00:00.000000000 Z
13
+ date: 2017-01-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cri