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,227 +1,227 @@
1
- require 'rbbt/entity'
2
-
3
- module AssociationItem
4
- extend Object::Entity
5
-
6
- annotation :knowledge_base
7
- annotation :database
8
- annotation :reverse
9
-
10
- property :name => :single do
11
- [source_entity, target_entity].collect{|e| e.respond_to?(:name)? e.name || e : e } * "~"
12
- end
13
-
14
- property :full_name => :single do
15
- database ? [database, name] * ":" : name
16
- end
17
-
18
- property :invert => :both do
19
- if Array === self
20
- inverted = self.collect do |item|
21
- s,_sep,t= item.partition "~"
22
- new = [t,s] * _sep
23
- end
24
- self.annotate inverted
25
- inverted.reverse = ! reverse
26
- inverted
27
- else
28
- s,_sep,t= self.partition "~"
29
- inverted = self.annotate([t,s] * _sep)
30
- inverted.reverse = ! reverse
31
- inverted
32
- end
33
- end
34
-
35
- property :namespace => :both do
36
- knowledge_base.namespace
37
- end
38
-
39
- property :part => :array2single do
40
- self.clean_annotations.collect{|p| p.partition("~") }
41
- end
42
-
43
- property :target => :array2single do
44
- self.part.collect{|p| p[2]}
45
- end
46
-
47
- property :source => :array2single do
48
- self.clean_annotations.collect{|p| p[/[^~]+/] }
49
- end
50
-
51
- property :target_entity_type => :both do
52
- Entity.formats[target_type].to_s
53
- end
54
-
55
- property :source_entity_type => :both do
56
- Entity.formats[source_type].to_s
57
- end
58
-
59
- property :target_type => :both do
60
- if reverse
61
- knowledge_base.source(database)
62
- else
63
- knowledge_base.target(database)
64
- end
65
- end
66
-
67
- property :source_type => :both do
68
- if reverse
69
- knowledge_base.target(database)
70
- else
71
- knowledge_base.source(database)
72
- end
73
- end
74
-
75
- property :undirected => :both do
76
- knowledge_base.undirected(database)
77
- end
78
-
79
- property :target_entity => :array2single do
80
- type = target_type
81
- knowledge_base.annotate self.target, type, database #if self.target.any?
82
- end
83
-
84
- property :source_entity => :array2single do
85
- type = source_type
86
- knowledge_base.annotate self.source, type, database #if self.source.any?
87
- end
88
-
89
- property :index => :both do |database|
90
- @index ||= knowledge_base.get_index(database)
91
- end
92
- property :value => :array2single do
93
- index = index(database)
94
- value = self.reverse ? index.chunked_values_at(self.invert) : index.chunked_values_at(self)
95
- value.collect{|v| NamedArray.setup(v, index.fields)}
96
- end
97
-
98
- property :info_fields => :both do
99
- knowledge_base.index_fields(database)
100
- end
101
-
102
- property :info => :array2single do
103
- fields = self.info_fields
104
-
105
- return [{}] * self.length if fields.nil? or fields.empty?
106
-
107
- value = self.value
108
- value.collect{|v|
109
- raise "No info for pair; not registered in index" if v.nil?
110
- Hash[*fields.zip(v).flatten]
111
- }
112
- end
113
-
114
- property :tsv => :array do
115
- info_fields = self.info_fields
116
- fields = [self.source_type, self.target_type].concat info_fields
117
- type = [self.source_type, self.target_type] * "~"
118
- tsv = TSV.setup({}, :key_field => type, :fields => fields, :type => :list, :namespace => self.namespace)
119
- index = index(database)
120
- index.with_unnamed do
121
- index.chunked_values_at(self).each_with_index do |v,i|
122
- p = self[i]
123
- source, _sep, target = p.partition("~")
124
- if info_fields.empty?
125
- tsv[p] = [source, target]
126
- else
127
- tsv[p] = [source, target].concat v
128
- end
129
- end
130
- end
131
- tsv.entity_options = {:organism => namespace}
132
- knowledge_base.entity_options.each do |type,options|
133
- tsv.entity_options.merge! options
134
- end
135
- tsv
136
- end
137
-
138
- property :filter => :array do |*args,&block|
139
- block = args.pop if Proc === args.last
140
- keys = tsv.with_unnamed do tsv.select(*args, &block).keys end
141
- keys = self.annotate keys
142
- keys
143
- end
144
-
145
- def self.incidence(pairs, key_field = nil, &block)
146
- matrix = {}
147
- targets = []
148
- sources = []
149
- matches = {}
150
-
151
- pairs.inject([]){|acc,m| acc << m; acc << m.invert if m.respond_to?(:undirected) and m.undirected; acc }.each do |p|
152
- s, sep, t = p.partition "~"
153
-
154
- sources << s
155
- targets << t
156
- if block_given?
157
- matches[s] ||= Hash.new{nil}
158
- value = block.call p
159
- matches[s][t] = value unless value.nil? or (mv = matches[s][t] and value > mv)
160
- else
161
- matches[s] ||= Hash.new{false}
162
- matches[s][t] ||= true
163
- end
164
- end
165
-
166
- sources.uniq!
167
- targets = targets.uniq.sort
168
-
169
- matches.each do |s,hash|
170
- matrix[s] = hash.values_at(*targets)
171
- end
172
-
173
- defined?(TSV)? TSV.setup(matrix, :key_field => (key_field || "Source") , :fields => targets, :type => :list) : matrix
174
- end
175
-
176
- def self.adjacency(pairs, key_field = nil, &block)
177
- incidence = incidence(pairs, key_field, &block)
178
-
179
- targets = incidence.fields
180
- adjacency = TSV.setup({}, :key_field => incidence.key_field, :fields => ["Target"], :type => :double)
181
- TSV.traverse incidence, :into => adjacency, :unnamed => true do |k,values|
182
- target_values = targets.zip(values).reject{|t,v| v.nil? }.collect{|t,v| [t,v]}
183
- next if target_values.empty?
184
- [k, Misc.zip_fields(target_values)]
185
- end
186
- end
187
-
188
- def self._select_match(orig, elem)
189
- if Array === orig and Array === elem
190
- (orig & elem).any?
191
- elsif Array === orig
192
- orig.include? elem
193
- elsif Array === elem
194
- elem.include? orig
195
- else
196
- elem === orif
197
- end
198
- false
199
- end
200
-
201
- def self.select(list, method = nil, &block)
202
- if method and method.any?
203
- list.select do |item|
204
- method.collect do |key,value|
205
- case key
206
- when :target
207
- _select_match item.target, value
208
- when :source
209
- _select_match item.source, value
210
- else
211
- orig = item.info[key]
212
- orig = orig.split(";;") if String orig
213
- _select_match orig, value
214
- end
215
- end
216
- end
217
- else
218
- list.select(&block)
219
- end
220
- end
221
- end
222
-
223
- module TSV
224
- def self.incidence(tsv)
225
- AssociationItem.incidence Association.index(tsv, :persist => false).keys
226
- end
227
- end
1
+ #require_relative '../entity'
2
+ #
3
+ #module AssociationItem
4
+ # extend Entity
5
+ #
6
+ # annotation :knowledge_base
7
+ # annotation :database
8
+ # annotation :reverse
9
+ #
10
+ # property :name => :single do
11
+ # [source_entity, target_entity].collect{|e| e.respond_to?(:name)? e.name || e : e } * "~"
12
+ # end
13
+ #
14
+ # property :full_name => :single do
15
+ # database ? [database, name] * ":" : name
16
+ # end
17
+ #
18
+ # property :invert => :both do
19
+ # if Array === self
20
+ # inverted = self.collect do |item|
21
+ # s,_sep,t= item.partition "~"
22
+ # new = [t,s] * _sep
23
+ # end
24
+ # self.annotate inverted
25
+ # inverted.reverse = ! reverse
26
+ # inverted
27
+ # else
28
+ # s,_sep,t= self.partition "~"
29
+ # inverted = self.annotate([t,s] * _sep)
30
+ # inverted.reverse = ! reverse
31
+ # inverted
32
+ # end
33
+ # end
34
+ #
35
+ # property :namespace => :both do
36
+ # knowledge_base.namespace
37
+ # end
38
+ #
39
+ # property :part => :array2single do
40
+ # self.clean_annotations.collect{|p| p.partition("~") }
41
+ # end
42
+ #
43
+ # property :target => :array2single do
44
+ # self.part.collect{|p| p[2]}
45
+ # end
46
+ #
47
+ # property :source => :array2single do
48
+ # self.clean_annotations.collect{|p| p[/[^~]+/] }
49
+ # end
50
+ #
51
+ # property :target_entity_type => :both do
52
+ # Entity.formats[target_type].to_s
53
+ # end
54
+ #
55
+ # property :source_entity_type => :both do
56
+ # Entity.formats[source_type].to_s
57
+ # end
58
+ #
59
+ # property :target_type => :both do
60
+ # if reverse
61
+ # knowledge_base.source(database)
62
+ # else
63
+ # knowledge_base.target(database)
64
+ # end
65
+ # end
66
+ #
67
+ # property :source_type => :both do
68
+ # if reverse
69
+ # knowledge_base.target(database)
70
+ # else
71
+ # knowledge_base.source(database)
72
+ # end
73
+ # end
74
+ #
75
+ # property :undirected => :both do
76
+ # knowledge_base.undirected(database)
77
+ # end
78
+ #
79
+ # property :target_entity => :array2single do
80
+ # type = target_type
81
+ # knowledge_base.annotate self.target, type, database #if self.target.any?
82
+ # end
83
+ #
84
+ # property :source_entity => :array2single do
85
+ # type = source_type
86
+ # knowledge_base.annotate self.source, type, database #if self.source.any?
87
+ # end
88
+ #
89
+ # property :index => :both do |database|
90
+ # @index ||= knowledge_base.get_index(database)
91
+ # end
92
+ # property :value => :array2single do
93
+ # index = index(database)
94
+ # value = self.reverse ? index.chunked_values_at(self.invert) : index.chunked_values_at(self)
95
+ # value.collect{|v| NamedArray.setup(v, index.fields)}
96
+ # end
97
+ #
98
+ # property :info_fields => :both do
99
+ # knowledge_base.index_fields(database)
100
+ # end
101
+ #
102
+ # property :info => :array2single do
103
+ # fields = self.info_fields
104
+ #
105
+ # return [{}] * self.length if fields.nil? or fields.empty?
106
+ #
107
+ # value = self.value
108
+ # value.collect{|v|
109
+ # raise "No info for pair; not registered in index" if v.nil?
110
+ # Hash[*fields.zip(v).flatten]
111
+ # }
112
+ # end
113
+ #
114
+ # property :tsv => :array do
115
+ # info_fields = self.info_fields
116
+ # fields = [self.source_type, self.target_type].concat info_fields
117
+ # type = [self.source_type, self.target_type] * "~"
118
+ # tsv = TSV.setup({}, :key_field => type, :fields => fields, :type => :list, :namespace => self.namespace)
119
+ # index = index(database)
120
+ # index.with_unnamed do
121
+ # index.chunked_values_at(self).each_with_index do |v,i|
122
+ # p = self[i]
123
+ # source, _sep, target = p.partition("~")
124
+ # if info_fields.empty?
125
+ # tsv[p] = [source, target]
126
+ # else
127
+ # tsv[p] = [source, target].concat v
128
+ # end
129
+ # end
130
+ # end
131
+ # tsv.entity_options = {:namespace => namespace}
132
+ # knowledge_base.entity_options.each do |type,options|
133
+ # tsv.entity_options.merge! options
134
+ # end
135
+ # tsv
136
+ # end
137
+ #
138
+ # property :filter => :array do |*args,&block|
139
+ # block = args.pop if Proc === args.last
140
+ # keys = tsv.with_unnamed do tsv.select(*args, &block).keys end
141
+ # keys = self.annotate keys
142
+ # keys
143
+ # end
144
+ #
145
+ # def self.incidence(pairs, key_field = nil, &block)
146
+ # matrix = {}
147
+ # targets = []
148
+ # sources = []
149
+ # matches = {}
150
+ #
151
+ # pairs.inject([]){|acc,m| acc << m; acc << m.invert if m.respond_to?(:undirected) and m.undirected; acc }.each do |p|
152
+ # s, sep, t = p.partition "~"
153
+ #
154
+ # sources << s
155
+ # targets << t
156
+ # if block_given?
157
+ # matches[s] ||= Hash.new{nil}
158
+ # value = block.call p
159
+ # matches[s][t] = value unless value.nil? or (mv = matches[s][t] and value > mv)
160
+ # else
161
+ # matches[s] ||= Hash.new{false}
162
+ # matches[s][t] ||= true
163
+ # end
164
+ # end
165
+ #
166
+ # sources.uniq!
167
+ # targets = targets.uniq.sort
168
+ #
169
+ # matches.each do |s,hash|
170
+ # matrix[s] = hash.values_at(*targets)
171
+ # end
172
+ #
173
+ # defined?(TSV)? TSV.setup(matrix, :key_field => (key_field || "Source") , :fields => targets, :type => :list) : matrix
174
+ # end
175
+ #
176
+ # def self.adjacency(pairs, key_field = nil, &block)
177
+ # incidence = incidence(pairs, key_field, &block)
178
+ #
179
+ # targets = incidence.fields
180
+ # adjacency = TSV.setup({}, :key_field => incidence.key_field, :fields => ["Target"], :type => :double)
181
+ # TSV.traverse incidence, :into => adjacency, :unnamed => true do |k,values|
182
+ # target_values = targets.zip(values).reject{|t,v| v.nil? }.collect{|t,v| [t,v]}
183
+ # next if target_values.empty?
184
+ # [k, Misc.zip_fields(target_values)]
185
+ # end
186
+ # end
187
+ #
188
+ # def self._select_match(orig, elem)
189
+ # if Array === orig and Array === elem
190
+ # (orig & elem).any?
191
+ # elsif Array === orig
192
+ # orig.include? elem
193
+ # elsif Array === elem
194
+ # elem.include? orig
195
+ # else
196
+ # elem === orif
197
+ # end
198
+ # false
199
+ # end
200
+ #
201
+ # def self.select(list, method = nil, &block)
202
+ # if method and method.any?
203
+ # list.select do |item|
204
+ # method.collect do |key,value|
205
+ # case key
206
+ # when :target
207
+ # _select_match item.target, value
208
+ # when :source
209
+ # _select_match item.source, value
210
+ # else
211
+ # orig = item.info[key]
212
+ # orig = orig.split(";;") if String orig
213
+ # _select_match orig, value
214
+ # end
215
+ # end
216
+ # end
217
+ # else
218
+ # list.select(&block)
219
+ # end
220
+ # end
221
+ #end
222
+ #
223
+ #module TSV
224
+ # def self.incidence(tsv)
225
+ # AssociationItem.incidence Association.index(tsv, :persist => false).keys
226
+ # end
227
+ #end
@@ -1,35 +1,36 @@
1
- require 'rbbt/association/database'
1
+ #require 'rbbt/association/database'
2
2
 
3
- module Association
4
- def self.version_file(file, namespace)
5
- old_file, file = file, file.sub('NAMESPACE', namespace) if namespace and String === file
6
- old_file.annotate file if Path === old_file
7
- file
8
- end
9
-
10
- def self.open(file, options = nil, persist_options = nil)
11
- options = options.nil? ? {} : options.dup
12
- persist_options = persist_options.nil? ? Misc.pull_keys(options, :persist) : persist_options.dup
13
-
14
- options = Misc.add_defaults options, :zipped => true, :merge => true, :monitor => {:desc => "Opening database #{Misc.fingerprint file}"}
15
- options[:zipped] = false unless options[:merge]
16
- persist_options = Misc.add_defaults persist_options.dup, :persist => true, :dir => Rbbt.var.associations
17
- persist = persist_options[:persist]
18
-
19
- file = version_file(file, options[:namespace]) if options[:namespace] and String === file
20
-
21
- data = Persist.persist_tsv(file, nil, options, persist_options.merge(:prefix => "Association Database")) do |data|
22
- file = file.call if Proc === file
23
-
24
- options = options.dup
25
- data.serializer = :double if data.respond_to? :serializer
26
-
27
- tsv = Association.database(file, options.merge(:unnamed => true, :data => data, :type => :double))
28
-
29
- data
30
- end
31
- data.entity_options = options[:entity_options] if options[:entity_options]
32
- data
33
- end
34
-
35
- end
3
+ #module Association
4
+ # def self.version_file(file, namespace)
5
+ # old_file, file = file, file.sub('NAMESPACE', namespace) if namespace and String === file
6
+ # old_file.annotate file if Path === old_file
7
+ # file
8
+ # end
9
+ #
10
+ # def self.open(file, options = nil, persist_options = nil)
11
+ # options = options.nil? ? {} : options.dup
12
+ # persist_options = persist_options.nil? ? IndiferentHash.pull_keys(options, :persist) : persist_options.dup
13
+ #
14
+ # options = IndiferentHash.add_defaults options, :zipped => true, :merge => true, :monitor => {:desc => "Opening database #{Log.fingerprint file}"}
15
+ # options[:zipped] = false unless options[:merge]
16
+ # persist_options = IndiferentHash.add_defaults persist_options.dup, :persist => true, :dir => Rbbt.var.associations
17
+ # persist = persist_options[:persist]
18
+ #
19
+ # file = version_file(file, options[:namespace]) if options[:namespace] and String === file
20
+ #
21
+ # data = Persist.persist_tsv(file, nil, options, persist_options.merge(:prefix => "Association Database")) do |data|
22
+ # data = {} if data.nil?
23
+ # file = file.call if Proc === file
24
+ #
25
+ # options = options.dup
26
+ # data.serializer = :double if data.respond_to? :serializer
27
+ #
28
+ # tsv = Association.database(file, options.merge(:unnamed => true, :data => data, :type => :double))
29
+ #
30
+ # data
31
+ # end
32
+ # data.entity_options = options[:entity_options] if options[:entity_options]
33
+ # data
34
+ # end
35
+ #
36
+ #end