unipept 0.3.0 → 0.3.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: e0cedbb475ea3469e5e59bed186772d043056252
4
- data.tar.gz: bae15a7be7890c1c9331f4c12edc148db1273425
3
+ metadata.gz: e8ceae14f14f26fc95744563b982738ef445d77b
4
+ data.tar.gz: e3a91a2e7ca3b2b076c19e0d7291bb90c69dfd04
5
5
  SHA512:
6
- metadata.gz: af89285b238a595f688964b2294db03db2cd9a8943c8677eda59e951108a692c28a2ed28136187c4d3fca87ee6624d228537c196e8c0faff397f9cb983ae2717
7
- data.tar.gz: 845bf1890a13ce5e836690781c7dc32f59c0392e8620704734dc8edc13b03e98b3a1678d4b3ce0ff3a20f62e84d2a1d7908bf00035edc1f258dd03ae0bd51f90
6
+ metadata.gz: 354c5fd790c33c79d638455350a1b27aba0dfddf5e5d8e1b0c23c09ecaee7d185a88b7ad9be8fc14fdb1653e8f5c7bc71809085556da1b3c6bac7771b022eb3e
7
+ data.tar.gz: 0f86c782e0e1f058f6b5243671897b62619051334cd4f8e8f6f51bf655f160e1aeab28271b7226cd093cfaf9e9ff962ae1e476d37f4767e32882abeaaeb12700
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/bin/unipept CHANGED
@@ -70,13 +70,15 @@ class ApiRunner < Cri::CommandRunner
70
70
  filter_list = filter_list.map {|f| glob_to_regex(f) }
71
71
  output = STDOUT.tty? ? STDOUT : STDERR
72
72
 
73
+ batch_order = Unipept::BatchOrder.new
74
+
73
75
  printed_header = false
74
76
  result = []
75
77
 
76
78
  hydra = Typhoeus::Hydra.new(max_concurrency: 20)
77
79
  num_req = 0
78
80
 
79
- peptide_iterator(peptides) do |sub_division|
81
+ peptide_iterator(peptides).with_index do |sub_division, i|
80
82
  if $interupted
81
83
  $stdin.close
82
84
  exit 1
@@ -100,11 +102,14 @@ class ApiRunner < Cri::CommandRunner
100
102
 
101
103
  result << sub_result
102
104
 
103
- if ! printed_header
104
- write_to_output formatter.header(sub_result)
105
- printed_header = true
105
+ # wait till it's our turn to write
106
+ batch_order.wait(i) do
107
+ if ! printed_header
108
+ write_to_output formatter.header(sub_result)
109
+ printed_header = true
110
+ end
111
+ write_to_output formatter.format(sub_result)
106
112
  end
107
- write_to_output formatter.format(sub_result)
108
113
  else
109
114
  path = File.expand_path(File.join(Dir.home, "unipept.log"))
110
115
  File.open(path, "w") do |f|
@@ -117,9 +122,8 @@ class ApiRunner < Cri::CommandRunner
117
122
  hydra.queue request
118
123
 
119
124
  num_req += 1
120
- if num_req == 200
125
+ if num_req % 200 == 0
121
126
  hydra.run
122
- num_req = 0
123
127
  end
124
128
 
125
129
  end
@@ -0,0 +1,28 @@
1
+ module Unipept
2
+
3
+ class BatchOrder
4
+
5
+ attr_reader :order
6
+
7
+ def initialize
8
+ @order = {}
9
+ @current = 0
10
+ end
11
+
12
+ def wait(i, &block)
13
+ if i == @current
14
+ # start writing + those who have been waiting as well
15
+ block.call
16
+ @current += 1
17
+ while order[@current]
18
+ order.delete(@current).call
19
+ @current += 1
20
+ end
21
+ else
22
+ @order[i] = block
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
data/lib/unipept.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require_relative 'unipept/formatters'
2
2
  require_relative 'unipept/configuration'
3
+ require_relative 'unipept/batch_order'
3
4
 
4
5
  module Unipept
5
6
  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.0
4
+ version: 0.3.1
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-05 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda
@@ -131,6 +131,7 @@ files:
131
131
  - bin/unipept
132
132
  - bin/uniprot
133
133
  - lib/unipept.rb
134
+ - lib/unipept/batch_order.rb
134
135
  - lib/unipept/configuration.rb
135
136
  - lib/unipept/formatters.rb
136
137
  - test/helper.rb