rbbt-util 5.44.1 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbbt +67 -90
- data/etc/app.d/base.rb +2 -2
- data/etc/app.d/semaphores.rb +3 -3
- data/lib/rbbt/annotations/annotated_array.rb +207 -207
- data/lib/rbbt/annotations/refactor.rb +27 -0
- data/lib/rbbt/annotations/util.rb +282 -282
- data/lib/rbbt/annotations.rb +343 -320
- data/lib/rbbt/association/database.rb +200 -225
- data/lib/rbbt/association/index.rb +294 -291
- data/lib/rbbt/association/item.rb +227 -227
- data/lib/rbbt/association/open.rb +35 -34
- data/lib/rbbt/association/util.rb +0 -169
- data/lib/rbbt/association.rb +2 -4
- data/lib/rbbt/entity/identifiers.rb +119 -118
- data/lib/rbbt/entity/refactor.rb +12 -0
- data/lib/rbbt/entity.rb +319 -315
- data/lib/rbbt/hpc/batch.rb +72 -53
- data/lib/rbbt/hpc/lsf.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
- data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
- data/lib/rbbt/hpc/orchestrate.rb +19 -13
- data/lib/rbbt/hpc/slurm.rb +18 -18
- data/lib/rbbt/knowledge_base/entity.rb +13 -5
- data/lib/rbbt/knowledge_base/query.rb +2 -2
- data/lib/rbbt/knowledge_base/registry.rb +32 -31
- data/lib/rbbt/knowledge_base/traverse.rb +1 -1
- data/lib/rbbt/knowledge_base.rb +1 -1
- data/lib/rbbt/monitor.rb +36 -25
- data/lib/rbbt/persist/refactor.rb +166 -0
- data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
- data/lib/rbbt/persist/tsv.rb +187 -185
- data/lib/rbbt/persist.rb +556 -551
- data/lib/rbbt/refactor.rb +20 -0
- data/lib/rbbt/resource/path/refactor.rb +178 -0
- data/lib/rbbt/resource/path.rb +317 -497
- data/lib/rbbt/resource/util.rb +0 -48
- data/lib/rbbt/resource.rb +3 -390
- data/lib/rbbt/tsv/accessor.rb +2 -838
- data/lib/rbbt/tsv/attach.rb +303 -299
- data/lib/rbbt/tsv/change_id.rb +244 -245
- data/lib/rbbt/tsv/csv.rb +87 -85
- data/lib/rbbt/tsv/dumper.rb +2 -100
- data/lib/rbbt/tsv/excel.rb +26 -24
- data/lib/rbbt/tsv/field_index.rb +4 -1
- data/lib/rbbt/tsv/filter.rb +3 -2
- data/lib/rbbt/tsv/index.rb +2 -284
- data/lib/rbbt/tsv/manipulate.rb +750 -747
- data/lib/rbbt/tsv/marshal.rb +3 -3
- data/lib/rbbt/tsv/matrix.rb +2 -2
- data/lib/rbbt/tsv/parallel/through.rb +2 -1
- data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
- data/lib/rbbt/tsv/parser.rb +678 -678
- data/lib/rbbt/tsv/refactor.rb +195 -0
- data/lib/rbbt/tsv/stream.rb +253 -251
- data/lib/rbbt/tsv/util.rb +420 -420
- data/lib/rbbt/tsv.rb +210 -208
- data/lib/rbbt/util/R/eval.rb +4 -4
- data/lib/rbbt/util/R/plot.rb +62 -166
- data/lib/rbbt/util/R.rb +21 -18
- data/lib/rbbt/util/cmd.rb +2 -318
- data/lib/rbbt/util/color.rb +269 -269
- data/lib/rbbt/util/colorize.rb +89 -89
- data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
- data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
- data/lib/rbbt/util/concurrency/processes.rb +389 -386
- data/lib/rbbt/util/config.rb +169 -167
- data/lib/rbbt/util/iruby.rb +20 -0
- data/lib/rbbt/util/log/progress/report.rb +241 -241
- data/lib/rbbt/util/log/progress/util.rb +99 -99
- data/lib/rbbt/util/log/progress.rb +102 -102
- data/lib/rbbt/util/log/refactor.rb +49 -0
- data/lib/rbbt/util/log.rb +486 -532
- data/lib/rbbt/util/migrate.rb +1 -1
- data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
- data/lib/rbbt/util/misc/development.rb +12 -11
- data/lib/rbbt/util/misc/exceptions.rb +117 -112
- data/lib/rbbt/util/misc/format.rb +2 -230
- data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
- data/lib/rbbt/util/misc/inspect.rb +2 -476
- data/lib/rbbt/util/misc/lock.rb +109 -106
- data/lib/rbbt/util/misc/omics.rb +9 -1
- data/lib/rbbt/util/misc/pipes.rb +765 -793
- data/lib/rbbt/util/misc/refactor.rb +20 -0
- data/lib/rbbt/util/misc/ssw.rb +27 -17
- data/lib/rbbt/util/misc/system.rb +0 -15
- data/lib/rbbt/util/misc.rb +39 -20
- data/lib/rbbt/util/named_array/refactor.rb +4 -0
- data/lib/rbbt/util/named_array.rb +3 -220
- data/lib/rbbt/util/open/refactor.rb +7 -0
- data/lib/rbbt/util/open.rb +3 -857
- data/lib/rbbt/util/procpath.rb +6 -6
- data/lib/rbbt/util/python/paths.rb +27 -0
- data/lib/rbbt/util/python/run.rb +115 -0
- data/lib/rbbt/util/python/script.rb +110 -0
- data/lib/rbbt/util/python/util.rb +3 -3
- data/lib/rbbt/util/python.rb +22 -81
- data/lib/rbbt/util/semaphore.rb +152 -148
- data/lib/rbbt/util/simpleopt.rb +9 -8
- data/lib/rbbt/util/ssh/refactor.rb +19 -0
- data/lib/rbbt/util/ssh.rb +122 -118
- data/lib/rbbt/util/tar.rb +117 -115
- data/lib/rbbt/util/tmpfile.rb +69 -67
- data/lib/rbbt/util/version.rb +2 -0
- data/lib/rbbt/workflow/refactor/entity.rb +11 -0
- data/lib/rbbt/workflow/refactor/export.rb +66 -0
- data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
- data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
- data/lib/rbbt/workflow/refactor/task_info.rb +65 -0
- data/lib/rbbt/workflow/refactor.rb +153 -0
- data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
- data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
- data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
- data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
- data/lib/rbbt/workflow/remote_workflow.rb +6 -1
- data/lib/rbbt/workflow/step/run.rb +766 -766
- data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
- data/lib/rbbt/workflow/step.rb +2 -362
- data/lib/rbbt/workflow/task.rb +118 -118
- data/lib/rbbt/workflow/usage.rb +289 -287
- data/lib/rbbt/workflow/util/archive.rb +6 -5
- data/lib/rbbt/workflow/util/data.rb +1 -1
- data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
- data/lib/rbbt/workflow/util/trace.rb +79 -44
- data/lib/rbbt/workflow.rb +4 -882
- data/lib/rbbt-util.rb +21 -13
- data/lib/rbbt.rb +16 -3
- data/python/rbbt/__init__.py +19 -1
- data/share/Rlib/plot.R +37 -37
- data/share/Rlib/svg.R +22 -5
- data/share/install/software/lib/install_helpers +1 -1
- data/share/rbbt_commands/hpc/list +2 -3
- data/share/rbbt_commands/hpc/orchestrate +4 -4
- data/share/rbbt_commands/hpc/tail +2 -0
- data/share/rbbt_commands/hpc/task +10 -7
- data/share/rbbt_commands/lsf/list +2 -3
- data/share/rbbt_commands/lsf/orchestrate +4 -4
- data/share/rbbt_commands/lsf/tail +2 -0
- data/share/rbbt_commands/lsf/task +10 -7
- data/share/rbbt_commands/migrate +1 -1
- data/share/rbbt_commands/pbs/list +2 -3
- data/share/rbbt_commands/pbs/orchestrate +4 -4
- data/share/rbbt_commands/pbs/tail +2 -0
- data/share/rbbt_commands/pbs/task +10 -7
- data/share/rbbt_commands/resource/produce +8 -1
- data/share/rbbt_commands/slurm/list +2 -3
- data/share/rbbt_commands/slurm/orchestrate +4 -4
- data/share/rbbt_commands/slurm/tail +2 -0
- data/share/rbbt_commands/slurm/task +10 -7
- data/share/rbbt_commands/system/clean +5 -5
- data/share/rbbt_commands/system/status +5 -5
- data/share/rbbt_commands/tsv/get +2 -3
- data/share/rbbt_commands/tsv/info +10 -13
- data/share/rbbt_commands/tsv/keys +18 -14
- data/share/rbbt_commands/tsv/slice +2 -2
- data/share/rbbt_commands/tsv/transpose +6 -2
- data/share/rbbt_commands/workflow/info +20 -24
- data/share/rbbt_commands/workflow/list +1 -1
- data/share/rbbt_commands/workflow/prov +20 -13
- data/share/rbbt_commands/workflow/server +11 -1
- data/share/rbbt_commands/workflow/task +76 -71
- data/share/rbbt_commands/workflow/write_info +26 -9
- data/share/software/opt/ssw/ssw.c +861 -0
- data/share/software/opt/ssw/ssw.h +130 -0
- data/share/workflow_config.ru +3 -3
- metadata +40 -2
data/lib/rbbt/tsv/index.rb
CHANGED
@@ -1,284 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'rbbt/persist'
|
5
|
-
require 'rbbt/persist/tsv'
|
6
|
-
|
7
|
-
require 'rbbt/tsv/manipulate'
|
8
|
-
require 'rbbt/tsv/filter'
|
9
|
-
|
10
|
-
module TSV
|
11
|
-
|
12
|
-
def index(options = {})
|
13
|
-
options = Misc.add_defaults options,
|
14
|
-
:target => :key, :fields => nil, :type => :single, :order => false
|
15
|
-
|
16
|
-
persist_options = Misc.pull_keys options, :persist
|
17
|
-
persist_options[:prefix] ||= "Index[#{options[:target] || :key}]"
|
18
|
-
|
19
|
-
Log.debug "Index: #{ filename } - #{Misc.fingerprint options}"
|
20
|
-
Persist.persist_tsv self, filename, options, persist_options do |new|
|
21
|
-
with_unnamed do
|
22
|
-
target, fields, index_type, order = Misc.process_options options, :target, :fields, :type, :order
|
23
|
-
|
24
|
-
new.serializer = index_type if new.respond_to? :serializer and new.serializer == :type
|
25
|
-
|
26
|
-
if order
|
27
|
-
|
28
|
-
# Maybe best to do the stuff in memory first instead of the original
|
29
|
-
# object, which could be persisted
|
30
|
-
save = new
|
31
|
-
new = {}
|
32
|
-
|
33
|
-
new_key_field, new_fields = through target, fields, true do |key, values|
|
34
|
-
next if key.empty?
|
35
|
-
case type
|
36
|
-
when :single
|
37
|
-
values = [values]
|
38
|
-
values.unshift key
|
39
|
-
when :double
|
40
|
-
values = values.dup
|
41
|
-
values.unshift [key]
|
42
|
-
when :list, :flat
|
43
|
-
values = values.dup
|
44
|
-
values.unshift key
|
45
|
-
end
|
46
|
-
|
47
|
-
values.each_with_index do |list, i|
|
48
|
-
list = [list] unless type == :double
|
49
|
-
|
50
|
-
list.uniq.each do |value|
|
51
|
-
if new.include? value
|
52
|
-
new_value = new[value]
|
53
|
-
else
|
54
|
-
new_value = []
|
55
|
-
end
|
56
|
-
|
57
|
-
if new_value[i].nil?
|
58
|
-
new_value[i] = key
|
59
|
-
else
|
60
|
-
new_value[i] += "|" << key
|
61
|
-
end
|
62
|
-
new[value] = new_value
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# Update original object
|
68
|
-
new.each do |key, values|
|
69
|
-
case
|
70
|
-
when index_type == :double
|
71
|
-
save[key] = [values.compact.collect{|v| v.split "|"}.flatten.uniq]
|
72
|
-
when index_type == :flat
|
73
|
-
save[key] = values.compact.collect{|v| v.split "|"}.flatten.uniq
|
74
|
-
when index_type == :single
|
75
|
-
save[key] = values.compact.collect{|v| v.split "|"}.flatten.first
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
new = save
|
80
|
-
else
|
81
|
-
new_key_field, new_fields = through target, fields, true do |key, values|
|
82
|
-
case
|
83
|
-
when type == :single
|
84
|
-
values = [values]
|
85
|
-
when type == :double
|
86
|
-
values = values.flatten
|
87
|
-
else
|
88
|
-
values = values.dup
|
89
|
-
end
|
90
|
-
|
91
|
-
values.unshift key
|
92
|
-
|
93
|
-
values.uniq.each do |value|
|
94
|
-
case index_type
|
95
|
-
when :double
|
96
|
-
if not new.include? value
|
97
|
-
new[value] = [[key]]
|
98
|
-
else
|
99
|
-
current = new[value]
|
100
|
-
current[0] << key
|
101
|
-
new[value] = current
|
102
|
-
end
|
103
|
-
when :flat
|
104
|
-
if not new.include? value
|
105
|
-
new[value] = [key]
|
106
|
-
else
|
107
|
-
current = new[value]
|
108
|
-
current << key
|
109
|
-
new[value] = current
|
110
|
-
end
|
111
|
-
|
112
|
-
else
|
113
|
-
new[value] = key unless new.include? value
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
new_fields = [] if new_fields.nil?
|
120
|
-
TSV.setup(new, :type => index_type, :filename => filename, :fields => [new_key_field], :key_field => new_fields * ", ", :namespace => namespace)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def self.index(file, options = {})
|
126
|
-
persist_options = Misc.pull_keys options, :persist
|
127
|
-
persist_options[:prefix] ||= "StaticIndex[#{options[:target] || :key}]"
|
128
|
-
|
129
|
-
Log.debug "Static Index: #{ file } - #{Misc.fingerprint options}"
|
130
|
-
Persist.persist_tsv nil, file, options, persist_options do |data|
|
131
|
-
data_options = Misc.pull_keys options, :data
|
132
|
-
data_options[:grep] ||= data_options[:tsv_grep] if data_options[:tsv_grep]
|
133
|
-
identifiers = TSV.open(file, data_options)
|
134
|
-
identifiers.with_monitor :desc => "Creating Index for #{ file }" do
|
135
|
-
identifiers.index(options.merge :persist_data => data, :persist => persist_options[:persist])
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def pos_index(pos_field = nil, options = {})
|
141
|
-
pos_field ||= "Position"
|
142
|
-
|
143
|
-
options = Misc.add_defaults options,
|
144
|
-
:persist => false, :persist_file => nil, :persist_update => false
|
145
|
-
|
146
|
-
persist_options = Misc.pull_keys options, :persist
|
147
|
-
persist_options[:prefix] ||= "PosIndex[#{pos_field}]"
|
148
|
-
|
149
|
-
Persist.persist(filename || self.object_id.to_s, :fwt, persist_options) do
|
150
|
-
max_key_size = 0
|
151
|
-
index_data = []
|
152
|
-
with_unnamed do
|
153
|
-
with_monitor :desc => "Creating Index Data", :step => 10000 do
|
154
|
-
through :key, pos_field do |key, values|
|
155
|
-
key_size = key.length
|
156
|
-
max_key_size = key_size if key_size > max_key_size
|
157
|
-
|
158
|
-
pos = values.first
|
159
|
-
if Array === pos
|
160
|
-
pos.each do |p|
|
161
|
-
index_data << [key, p.to_i]
|
162
|
-
end
|
163
|
-
else
|
164
|
-
index_data << [key, pos.to_i]
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
index = FixWidthTable.get(:memory, max_key_size, false)
|
171
|
-
index.add_point index_data
|
172
|
-
index.read
|
173
|
-
index
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def self.pos_index(file, pos_field = nil, options = {})
|
178
|
-
pos_field ||= "Position"
|
179
|
-
|
180
|
-
data_options = Misc.pull_keys options, :data
|
181
|
-
filename = case
|
182
|
-
when (String === file or Path === file)
|
183
|
-
file
|
184
|
-
when file.respond_to?(:filename)
|
185
|
-
file.filename
|
186
|
-
else
|
187
|
-
file.object_id.to_s
|
188
|
-
end
|
189
|
-
persist_options = Misc.pull_keys options, :persist
|
190
|
-
persist_options[:prefix] ||= "StaticPosIndex[#{pos_field}]"
|
191
|
-
|
192
|
-
filters = Misc.process_options options, :filters
|
193
|
-
|
194
|
-
if filters
|
195
|
-
filename += ":Filtered[#{filters.collect{|f| f * "="} * ", "}]"
|
196
|
-
end
|
197
|
-
|
198
|
-
Persist.persist(filename, :fwt, persist_options) do
|
199
|
-
tsv = TSV.open(file, data_options)
|
200
|
-
if filters
|
201
|
-
tsv.filter
|
202
|
-
filters.each do |match, value|
|
203
|
-
tsv.add_filter match, value
|
204
|
-
end
|
205
|
-
end
|
206
|
-
tsv.pos_index(pos_field, options)
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def range_index(start_field = nil, end_field = nil, options = {})
|
211
|
-
start_field ||= "Start"
|
212
|
-
end_field ||= "End"
|
213
|
-
|
214
|
-
options = Misc.add_defaults options,
|
215
|
-
:persist => false, :persist_file => nil, :persist_update => false
|
216
|
-
|
217
|
-
persist_options = Misc.pull_keys options, :persist
|
218
|
-
persist_options[:prefix] ||= "RangeIndex[#{start_field}-#{end_field}]"
|
219
|
-
|
220
|
-
Persist.persist(filename || self.object_id.to_s, :fwt, persist_options) do
|
221
|
-
max_key_size = 0
|
222
|
-
index_data = []
|
223
|
-
with_unnamed do
|
224
|
-
with_monitor :desc => "Creating Index Data", :step => 10000 do
|
225
|
-
through :key, [start_field, end_field] do |key, values|
|
226
|
-
key_size = key.length
|
227
|
-
max_key_size = key_size if key_size > max_key_size
|
228
|
-
|
229
|
-
start_pos, end_pos = values
|
230
|
-
if Array === start_pos
|
231
|
-
start_pos.zip(end_pos).each do |s,e|
|
232
|
-
index_data << [key, [s.to_i, e.to_i]]
|
233
|
-
end
|
234
|
-
else
|
235
|
-
index_data << [key, [start_pos.to_i, end_pos.to_i]]
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
index = FixWidthTable.get(:memory, max_key_size, true)
|
242
|
-
index.add_range index_data
|
243
|
-
index.read
|
244
|
-
index
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
def self.range_index(file, start_field = nil, end_field = nil, options = {})
|
249
|
-
start_field ||= "Start"
|
250
|
-
end_field ||= "End"
|
251
|
-
|
252
|
-
data_options = Misc.pull_keys options, :data
|
253
|
-
filename = case
|
254
|
-
when (String === file or Path === file)
|
255
|
-
file
|
256
|
-
when file.respond_to?(:filename)
|
257
|
-
file.filename
|
258
|
-
else
|
259
|
-
file.object_id.to_s
|
260
|
-
end
|
261
|
-
|
262
|
-
persist_options = Misc.pull_keys options, :persist
|
263
|
-
persist_options[:prefix] ||= "StaticRangeIndex[#{start_field}-#{end_field}]"
|
264
|
-
|
265
|
-
filters = Misc.process_options options, :filters
|
266
|
-
|
267
|
-
if filters
|
268
|
-
filename += ":Filtered[#{filters.collect{|f| f * "="} * ", "}]"
|
269
|
-
end
|
270
|
-
|
271
|
-
Persist.persist(filename, :fwt, persist_options) do
|
272
|
-
tsv = TSV.open(file, data_options)
|
273
|
-
if filters
|
274
|
-
tsv.filter
|
275
|
-
filters.each do |match, value|
|
276
|
-
tsv.add_filter match, value
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
tsv.range_index(start_field, end_field, options)
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
1
|
+
require_relative '../refactor'
|
2
|
+
Rbbt.require_instead 'scout/tsv'
|