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.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rbbt +67 -90
  3. data/etc/app.d/base.rb +2 -2
  4. data/etc/app.d/semaphores.rb +3 -3
  5. data/lib/rbbt/annotations/annotated_array.rb +207 -207
  6. data/lib/rbbt/annotations/refactor.rb +27 -0
  7. data/lib/rbbt/annotations/util.rb +282 -282
  8. data/lib/rbbt/annotations.rb +343 -320
  9. data/lib/rbbt/association/database.rb +200 -225
  10. data/lib/rbbt/association/index.rb +294 -291
  11. data/lib/rbbt/association/item.rb +227 -227
  12. data/lib/rbbt/association/open.rb +35 -34
  13. data/lib/rbbt/association/util.rb +0 -169
  14. data/lib/rbbt/association.rb +2 -4
  15. data/lib/rbbt/entity/identifiers.rb +119 -118
  16. data/lib/rbbt/entity/refactor.rb +12 -0
  17. data/lib/rbbt/entity.rb +319 -315
  18. data/lib/rbbt/hpc/batch.rb +72 -53
  19. data/lib/rbbt/hpc/lsf.rb +2 -2
  20. data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
  21. data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
  22. data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
  23. data/lib/rbbt/hpc/orchestrate.rb +19 -13
  24. data/lib/rbbt/hpc/slurm.rb +18 -18
  25. data/lib/rbbt/knowledge_base/entity.rb +13 -5
  26. data/lib/rbbt/knowledge_base/query.rb +2 -2
  27. data/lib/rbbt/knowledge_base/registry.rb +32 -31
  28. data/lib/rbbt/knowledge_base/traverse.rb +1 -1
  29. data/lib/rbbt/knowledge_base.rb +1 -1
  30. data/lib/rbbt/monitor.rb +36 -25
  31. data/lib/rbbt/persist/refactor.rb +166 -0
  32. data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
  33. data/lib/rbbt/persist/tsv.rb +187 -185
  34. data/lib/rbbt/persist.rb +556 -551
  35. data/lib/rbbt/refactor.rb +20 -0
  36. data/lib/rbbt/resource/path/refactor.rb +178 -0
  37. data/lib/rbbt/resource/path.rb +317 -497
  38. data/lib/rbbt/resource/util.rb +0 -48
  39. data/lib/rbbt/resource.rb +3 -390
  40. data/lib/rbbt/tsv/accessor.rb +2 -838
  41. data/lib/rbbt/tsv/attach.rb +303 -299
  42. data/lib/rbbt/tsv/change_id.rb +244 -245
  43. data/lib/rbbt/tsv/csv.rb +87 -85
  44. data/lib/rbbt/tsv/dumper.rb +2 -100
  45. data/lib/rbbt/tsv/excel.rb +26 -24
  46. data/lib/rbbt/tsv/field_index.rb +4 -1
  47. data/lib/rbbt/tsv/filter.rb +3 -2
  48. data/lib/rbbt/tsv/index.rb +2 -284
  49. data/lib/rbbt/tsv/manipulate.rb +750 -747
  50. data/lib/rbbt/tsv/marshal.rb +3 -3
  51. data/lib/rbbt/tsv/matrix.rb +2 -2
  52. data/lib/rbbt/tsv/parallel/through.rb +2 -1
  53. data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
  54. data/lib/rbbt/tsv/parser.rb +678 -678
  55. data/lib/rbbt/tsv/refactor.rb +195 -0
  56. data/lib/rbbt/tsv/stream.rb +253 -251
  57. data/lib/rbbt/tsv/util.rb +420 -420
  58. data/lib/rbbt/tsv.rb +210 -208
  59. data/lib/rbbt/util/R/eval.rb +4 -4
  60. data/lib/rbbt/util/R/plot.rb +62 -166
  61. data/lib/rbbt/util/R.rb +21 -18
  62. data/lib/rbbt/util/cmd.rb +2 -318
  63. data/lib/rbbt/util/color.rb +269 -269
  64. data/lib/rbbt/util/colorize.rb +89 -89
  65. data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
  66. data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
  67. data/lib/rbbt/util/concurrency/processes.rb +389 -386
  68. data/lib/rbbt/util/config.rb +169 -167
  69. data/lib/rbbt/util/iruby.rb +20 -0
  70. data/lib/rbbt/util/log/progress/report.rb +241 -241
  71. data/lib/rbbt/util/log/progress/util.rb +99 -99
  72. data/lib/rbbt/util/log/progress.rb +102 -102
  73. data/lib/rbbt/util/log/refactor.rb +49 -0
  74. data/lib/rbbt/util/log.rb +486 -532
  75. data/lib/rbbt/util/migrate.rb +1 -1
  76. data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
  77. data/lib/rbbt/util/misc/development.rb +12 -11
  78. data/lib/rbbt/util/misc/exceptions.rb +117 -112
  79. data/lib/rbbt/util/misc/format.rb +2 -230
  80. data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
  81. data/lib/rbbt/util/misc/inspect.rb +2 -476
  82. data/lib/rbbt/util/misc/lock.rb +109 -106
  83. data/lib/rbbt/util/misc/omics.rb +9 -1
  84. data/lib/rbbt/util/misc/pipes.rb +765 -793
  85. data/lib/rbbt/util/misc/refactor.rb +20 -0
  86. data/lib/rbbt/util/misc/ssw.rb +27 -17
  87. data/lib/rbbt/util/misc/system.rb +0 -15
  88. data/lib/rbbt/util/misc.rb +39 -20
  89. data/lib/rbbt/util/named_array/refactor.rb +4 -0
  90. data/lib/rbbt/util/named_array.rb +3 -220
  91. data/lib/rbbt/util/open/refactor.rb +7 -0
  92. data/lib/rbbt/util/open.rb +3 -857
  93. data/lib/rbbt/util/procpath.rb +6 -6
  94. data/lib/rbbt/util/python/paths.rb +27 -0
  95. data/lib/rbbt/util/python/run.rb +115 -0
  96. data/lib/rbbt/util/python/script.rb +110 -0
  97. data/lib/rbbt/util/python/util.rb +3 -3
  98. data/lib/rbbt/util/python.rb +22 -81
  99. data/lib/rbbt/util/semaphore.rb +152 -148
  100. data/lib/rbbt/util/simpleopt.rb +9 -8
  101. data/lib/rbbt/util/ssh/refactor.rb +19 -0
  102. data/lib/rbbt/util/ssh.rb +122 -118
  103. data/lib/rbbt/util/tar.rb +117 -115
  104. data/lib/rbbt/util/tmpfile.rb +69 -67
  105. data/lib/rbbt/util/version.rb +2 -0
  106. data/lib/rbbt/workflow/refactor/entity.rb +11 -0
  107. data/lib/rbbt/workflow/refactor/export.rb +66 -0
  108. data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
  109. data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
  110. data/lib/rbbt/workflow/refactor/task_info.rb +65 -0
  111. data/lib/rbbt/workflow/refactor.rb +153 -0
  112. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
  113. data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
  114. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
  115. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
  116. data/lib/rbbt/workflow/remote_workflow.rb +6 -1
  117. data/lib/rbbt/workflow/step/run.rb +766 -766
  118. data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
  119. data/lib/rbbt/workflow/step.rb +2 -362
  120. data/lib/rbbt/workflow/task.rb +118 -118
  121. data/lib/rbbt/workflow/usage.rb +289 -287
  122. data/lib/rbbt/workflow/util/archive.rb +6 -5
  123. data/lib/rbbt/workflow/util/data.rb +1 -1
  124. data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
  125. data/lib/rbbt/workflow/util/trace.rb +79 -44
  126. data/lib/rbbt/workflow.rb +4 -882
  127. data/lib/rbbt-util.rb +21 -13
  128. data/lib/rbbt.rb +16 -3
  129. data/python/rbbt/__init__.py +19 -1
  130. data/share/Rlib/plot.R +37 -37
  131. data/share/Rlib/svg.R +22 -5
  132. data/share/install/software/lib/install_helpers +1 -1
  133. data/share/rbbt_commands/hpc/list +2 -3
  134. data/share/rbbt_commands/hpc/orchestrate +4 -4
  135. data/share/rbbt_commands/hpc/tail +2 -0
  136. data/share/rbbt_commands/hpc/task +10 -7
  137. data/share/rbbt_commands/lsf/list +2 -3
  138. data/share/rbbt_commands/lsf/orchestrate +4 -4
  139. data/share/rbbt_commands/lsf/tail +2 -0
  140. data/share/rbbt_commands/lsf/task +10 -7
  141. data/share/rbbt_commands/migrate +1 -1
  142. data/share/rbbt_commands/pbs/list +2 -3
  143. data/share/rbbt_commands/pbs/orchestrate +4 -4
  144. data/share/rbbt_commands/pbs/tail +2 -0
  145. data/share/rbbt_commands/pbs/task +10 -7
  146. data/share/rbbt_commands/resource/produce +8 -1
  147. data/share/rbbt_commands/slurm/list +2 -3
  148. data/share/rbbt_commands/slurm/orchestrate +4 -4
  149. data/share/rbbt_commands/slurm/tail +2 -0
  150. data/share/rbbt_commands/slurm/task +10 -7
  151. data/share/rbbt_commands/system/clean +5 -5
  152. data/share/rbbt_commands/system/status +5 -5
  153. data/share/rbbt_commands/tsv/get +2 -3
  154. data/share/rbbt_commands/tsv/info +10 -13
  155. data/share/rbbt_commands/tsv/keys +18 -14
  156. data/share/rbbt_commands/tsv/slice +2 -2
  157. data/share/rbbt_commands/tsv/transpose +6 -2
  158. data/share/rbbt_commands/workflow/info +20 -24
  159. data/share/rbbt_commands/workflow/list +1 -1
  160. data/share/rbbt_commands/workflow/prov +20 -13
  161. data/share/rbbt_commands/workflow/server +11 -1
  162. data/share/rbbt_commands/workflow/task +76 -71
  163. data/share/rbbt_commands/workflow/write_info +26 -9
  164. data/share/software/opt/ssw/ssw.c +861 -0
  165. data/share/software/opt/ssw/ssw.h +130 -0
  166. data/share/workflow_config.ru +3 -3
  167. metadata +40 -2
@@ -1,284 +1,2 @@
1
- require 'rbbt/fix_width_table'
2
- require 'rbbt/util/misc'
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'