unipept 0.3.5 → 0.4.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: 912794c26e712f70f1db0cb0946d87479a1c4dae
4
- data.tar.gz: 44adc715b0704425d542ca0450c4e523df0f19d2
3
+ metadata.gz: cb4cf2b51a09b13a5707a1cf5817f252663834d8
4
+ data.tar.gz: 1ca2701b05ffc2ed85261f51306b82f04742f74a
5
5
  SHA512:
6
- metadata.gz: e7dea9e6717f0f3b18510ae53b21c040412c4d25db3525fdd13baa660df72c24c44a6f9f5981301f3fc0352768821826acb082712652d9d2fb4d30b51f22527e
7
- data.tar.gz: 911afafcbb596b5d66e86c3cdec7ab4022622f635ff0edad85fbfce587949708feb85a2f33b51e0bfdfd4cddb1bb246905bd1dbf40d25db2f181383163030ecc
6
+ metadata.gz: 6c630669079cab95179b87a39803f16aa4d248ae5103be29d91fe5e9c3bf5aced6c2ee58e3e2022cc55f609a580f6acc72ae74337e67045ce0fd0c7be4ede5c5
7
+ data.tar.gz: e3931b23b6f89796a19ad0db836d9cd750a20012399ce70ef9f471c4751f819b855a9ae13f5625c01a26a6c9c9cd33fbbaf5e8ac416d669511aff408a3d524c2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.5
1
+ 0.4.0
data/bin/unipept CHANGED
@@ -14,7 +14,8 @@ class ApiRunner < Cri::CommandRunner
14
14
 
15
15
  def initialize(args, opts, cmd)
16
16
  super
17
- host = Unipept::Configuration.new['host']
17
+ @configuration = Unipept::Configuration.new
18
+ host = @configuration['host']
18
19
  if host.nil? || host.empty?
19
20
  puts "WARNING: no host has been set, you can set the host with `unipept config host http://localhost:3000/`"
20
21
  exit 1
@@ -24,11 +25,12 @@ class ApiRunner < Cri::CommandRunner
24
25
  end
25
26
 
26
27
  @url = "#{host}/api/v1/#{mapping[cmd.name]}.json"
28
+ @message_url = "#{host}/api/v1/messages.json"
27
29
  end
28
30
 
29
31
 
30
32
  def mapping
31
- {'pept2taxa' => 'single', 'pept2lca' => 'lca'}
33
+ {'pept2taxa' => 'pept2taxa', 'pept2lca' => 'pept2lca'}
32
34
  end
33
35
 
34
36
  def input_iterator
@@ -50,14 +52,28 @@ class ApiRunner < Cri::CommandRunner
50
52
  else
51
53
  names = filter.any? {|f| /.*name.*/.match f}
52
54
  end
53
- {:sequences => sub_part,
55
+ {:input => sub_part,
54
56
  :equate_il => options[:equate],
55
- :full_lineage => options[:lineage],
57
+ :extra => options[:extra],
56
58
  :names => names,
57
59
  }
58
60
  end
59
61
 
62
+ def get_server_message
63
+ return if options[:quiet]
64
+ last_fetched = @configuration['last_fetch_date']
65
+ if last_fetched.nil? || (last_fetched + 60 * 60 * 24) < Time.now
66
+ version = File.read(File.join(File.dirname(__FILE__), "..", "VERSION"))
67
+ puts Typhoeus.get(@message_url, params: {version: version}).body
68
+
69
+ @configuration['last_fetch_date'] = Time.now
70
+ @configuration.save
71
+ end
72
+ end
73
+
60
74
  def run
75
+ get_server_message
76
+
61
77
  formatter = Unipept::Formatter.new_for_format(options[:format])
62
78
  peptides = input_iterator
63
79
 
@@ -168,10 +184,6 @@ class Taxa2lca < ApiRunner
168
184
  {"taxa2lca" => "taxa2lca"}
169
185
  end
170
186
 
171
- def url_options(sub_part)
172
- {:taxon_ids => sub_part, :full_lineage => options[:lineage]}
173
- end
174
-
175
187
  def peptide_iterator(peptides, &block)
176
188
  block.call(peptides.to_a, 0)
177
189
  end
@@ -185,11 +197,7 @@ end
185
197
  class Pept2prot < ApiRunner
186
198
 
187
199
  def mapping
188
- {"pept2prot" => "pept2pro"}
189
- end
190
-
191
- def url_options(sub_part)
192
- {:sequences => sub_part, :equate_il => options[:equate], :extra => options[:all]}
200
+ {"pept2prot" => "pept2prot"}
193
201
  end
194
202
 
195
203
  def download_xml(result)
@@ -212,6 +220,7 @@ end
212
220
  root_cmd = Cri::Command.new_basic_root.modify do
213
221
  name 'unipept'
214
222
  flag :v, :version, "print version"
223
+ flag :q, :quiet, "don't show update messages"
215
224
  option :i, :input, "input file", :argument => :required
216
225
  option :o, :output, "output file", :argument => :required
217
226
  option :f, :format, "output format (available: #{Unipept::Formatter.available.join "," }) (default: #{Unipept::Formatter.default})", :argument => :required
@@ -246,7 +255,7 @@ root_cmd.define_command('pept2taxa') do
246
255
 
247
256
  flag :e, :equate, "equate I and L"
248
257
  option :s, :select, "select the attributes", :argument => :required, :multiple => true
249
- option :l, :lineage, "Show full lineage"
258
+ option :a, :extra, "Show full lineage"
250
259
  option :x, :xml, "Download taxonomy from NCBI as xml (specify output filename)", :argument => :required
251
260
 
252
261
  runner ApiRunner
@@ -260,7 +269,7 @@ root_cmd.define_command('pept2lca') do
260
269
 
261
270
  flag :e, :equate, "equate I and L"
262
271
  option :s, :select, "select the attributes", :argument => :required, :multiple => true
263
- option :l, :lineage, "Show full lineage"
272
+ option :a, :extra, "Show full lineage"
264
273
 
265
274
  runner ApiRunner
266
275
  end
@@ -272,7 +281,7 @@ root_cmd.define_command('taxa2lca') do
272
281
  description 'Search Unipept for the given taxon ids and return the lowest common ancestor'
273
282
 
274
283
  option :s, :select, "select the attributes", :argument => :required, :multiple => true
275
- option :l, :lineage, "Show full lineage"
284
+ option :a, :extra, "Show full lineage"
276
285
 
277
286
  runner Taxa2lca
278
287
  end
@@ -286,7 +295,7 @@ root_cmd.define_command('pept2prot') do
286
295
  flag :e, :equate, "equate I and L"
287
296
  option :s, :select, "select the attributes", :argument => :required, :multiple => true
288
297
  option :x, :xml, "download uniprot record in specified directory", :argument => :required
289
- flag :a, :all, "include all information. WARNING: will take much longer!"
298
+ flag :a, :extra, "include all information. WARNING: will take much longer!"
290
299
 
291
300
  runner Pept2prot
292
301
  end
@@ -63,9 +63,9 @@ module Unipept
63
63
  CSV.generate do |csv|
64
64
  data.each do |o|
65
65
  if o.kind_of? Array
66
- o.each {|h| csv << h.values }
66
+ o.each {|h| csv << h.values.map { |v| v == "" ? nil : v }}
67
67
  else
68
- csv << o.values
68
+ csv << o.values.map { |v| v == "" ? nil : v }
69
69
  end
70
70
  end
71
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unipept
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toon Willems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-11 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda