unipept 0.2.10 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/unipept +49 -17
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0cedbb475ea3469e5e59bed186772d043056252
|
4
|
+
data.tar.gz: bae15a7be7890c1c9331f4c12edc148db1273425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af89285b238a595f688964b2294db03db2cd9a8943c8677eda59e951108a692c28a2ed28136187c4d3fca87ee6624d228537c196e8c0faff397f9cb983ae2717
|
7
|
+
data.tar.gz: 845bf1890a13ce5e836690781c7dc32f59c0392e8620704734dc8edc13b03e98b3a1678d4b3ce0ff3a20f62e84d2a1d7908bf00035edc1f258dd03ae0bd51f90
|
data/Rakefile
CHANGED
@@ -23,7 +23,7 @@ Jeweler::Tasks.new do |gem|
|
|
23
23
|
gem.email = "willemstoon@gmail.com"
|
24
24
|
gem.authors = ["Toon Willems"]
|
25
25
|
# dependencies defined in Gemfile
|
26
|
-
gem.add_dependency '
|
26
|
+
gem.add_dependency 'typhoeus', '~> 0.6'
|
27
27
|
gem.add_dependency 'cri', '~> 2.6'
|
28
28
|
end
|
29
29
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/bin/unipept
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'cri'
|
4
|
-
require '
|
4
|
+
require 'typhoeus'
|
5
5
|
require 'yaml'
|
6
6
|
require 'json'
|
7
7
|
require 'fileutils'
|
@@ -45,7 +45,7 @@ class ApiRunner < Cri::CommandRunner
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def batch_size
|
48
|
-
|
48
|
+
100
|
49
49
|
end
|
50
50
|
|
51
51
|
def url_options(sub_part)
|
@@ -73,32 +73,60 @@ class ApiRunner < Cri::CommandRunner
|
|
73
73
|
printed_header = false
|
74
74
|
result = []
|
75
75
|
|
76
|
+
hydra = Typhoeus::Hydra.new(max_concurrency: 20)
|
77
|
+
num_req = 0
|
78
|
+
|
76
79
|
peptide_iterator(peptides) do |sub_division|
|
77
80
|
if $interupted
|
78
81
|
$stdin.close
|
79
82
|
exit 1
|
80
83
|
end
|
81
|
-
begin
|
82
|
-
sub_result = JSON[Faraday.post(@url, url_options(sub_division)).body]
|
83
|
-
rescue
|
84
|
-
STDERR.puts "API endpoint gave an error, exiting."
|
85
|
-
exit 1
|
86
|
-
end
|
87
84
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
85
|
+
request = Typhoeus::Request.new(
|
86
|
+
@url,
|
87
|
+
method: :post,
|
88
|
+
body: url_options(sub_division)
|
89
|
+
)
|
90
|
+
request.on_complete do |resp|
|
91
|
+
if resp.timed_out?
|
92
|
+
$stderr.puts "request timed out, continuing anyway, but results might be incomplete"
|
93
|
+
else
|
94
|
+
if resp.success?
|
95
|
+
# if JSON parsing goes wrong
|
96
|
+
sub_result = JSON[resp.response_body] rescue []
|
97
|
+
sub_result = [sub_result] if not sub_result.kind_of? Array
|
98
|
+
|
99
|
+
sub_result.map! {|r| r.select! {|k,v| filter_list.any? {|f| f.match k } } } if ! filter_list.empty?
|
100
|
+
|
101
|
+
result << sub_result
|
102
|
+
|
103
|
+
if ! printed_header
|
104
|
+
write_to_output formatter.header(sub_result)
|
105
|
+
printed_header = true
|
106
|
+
end
|
107
|
+
write_to_output formatter.format(sub_result)
|
108
|
+
else
|
109
|
+
path = File.expand_path(File.join(Dir.home, "unipept.log"))
|
110
|
+
File.open(path, "w") do |f|
|
111
|
+
f.write resp.response_body
|
112
|
+
end
|
113
|
+
$stderr.puts "API request failed! log can be found in #{path}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
hydra.queue request
|
93
118
|
|
94
|
-
|
95
|
-
|
96
|
-
|
119
|
+
num_req += 1
|
120
|
+
if num_req == 200
|
121
|
+
hydra.run
|
122
|
+
num_req = 0
|
97
123
|
end
|
98
124
|
|
99
|
-
write_to_output formatter.format(sub_result)
|
100
125
|
end
|
101
126
|
|
127
|
+
hydra.run
|
128
|
+
|
129
|
+
|
102
130
|
begin
|
103
131
|
download_xml(result)
|
104
132
|
rescue
|
@@ -179,6 +207,10 @@ class Pept2prot < ApiRunner
|
|
179
207
|
end
|
180
208
|
end
|
181
209
|
|
210
|
+
def batch_size
|
211
|
+
10
|
212
|
+
end
|
213
|
+
|
182
214
|
end
|
183
215
|
|
184
216
|
root_cmd = Cri::Command.new_basic_root.modify do
|
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.
|
4
|
+
version: 0.3.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
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|
@@ -81,19 +81,19 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.8'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: typhoeus
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.6'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: cri
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.2.
|
158
|
+
rubygems_version: 2.2.2
|
159
159
|
signing_key:
|
160
160
|
specification_version: 4
|
161
161
|
summary: CLI interface to unipept
|