rbbt-util 5.14.7 → 5.14.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rbbt/association/index.rb +1 -0
- data/lib/rbbt/association/item.rb +2 -1
- data/lib/rbbt/association.rb +14 -11
- data/lib/rbbt/knowledge_base.rb +18 -5
- data/lib/rbbt/tsv/accessor.rb +1 -0
- data/lib/rbbt/tsv/change_id.rb +10 -2
- data/lib/rbbt/util/named_array.rb +6 -2
- data/lib/rbbt/workflow/accessor.rb +2 -1
- data/share/rbbt_commands/workflow/knowledge_base +14 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d676e9769e4e13d664c42a65e74ec8c7d70bbe63
|
4
|
+
data.tar.gz: f3a75c5456360ae6e31d713ef964650adcb2edb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2cb4d0761e9b44f8d108888a966b874f572f144b16620754c6551349fc8c8d04ee061393e7032d829a3fa1f0e72a04185e5f6af3d5c264d4582daf7524063e9
|
7
|
+
data.tar.gz: 8402954673614b9b0ff6c4b73237a47d1f077ef795f9c452f96fab732e665428cb470e2ae38c12ed3c818c0c1b2d512d8322444020ba3b1783e528c30ce8a048
|
@@ -96,6 +96,7 @@ module Association
|
|
96
96
|
|
97
97
|
def subset_entities(entities)
|
98
98
|
source, target = select_entities(entities)
|
99
|
+
source = :all if source.nil? and target.nil?
|
99
100
|
raise "Please specify source entities" if source.nil?
|
100
101
|
target = :all if target.nil?
|
101
102
|
return if Array === target and target.empty?
|
@@ -38,7 +38,7 @@ module AssociationItem
|
|
38
38
|
end
|
39
39
|
|
40
40
|
property :value => :array2single do
|
41
|
-
value = knowledge_base.get_index(database).chunked_values_at self
|
41
|
+
value = (reverse ? knowledge_base.get_index(database).reverse : knowledge_base.get_index(database)).chunked_values_at self
|
42
42
|
value.collect{|v| NamedArray.setup(v, knowledge_base.get_index(database).fields)}
|
43
43
|
end
|
44
44
|
|
@@ -46,6 +46,7 @@ module AssociationItem
|
|
46
46
|
fields = knowledge_base.index_fields(database)
|
47
47
|
return [{}] * self.length if fields.nil? or fields.empty?
|
48
48
|
|
49
|
+
value = self.value
|
49
50
|
value.collect{|v|
|
50
51
|
Hash[*fields.zip(v).flatten]
|
51
52
|
}
|
data/lib/rbbt/association.rb
CHANGED
@@ -12,19 +12,22 @@ module Association
|
|
12
12
|
|
13
13
|
def self.add_reciprocal(tsv)
|
14
14
|
|
15
|
-
new =
|
15
|
+
new = tsv.dup
|
16
16
|
tsv.with_unnamed do
|
17
17
|
tsv.through do |key, values|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
target_values
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
Misc.zip_fields(values).each do |zipped|
|
19
|
+
target, *rest = zipped
|
20
|
+
|
21
|
+
target_values = new[target] || []
|
22
|
+
if target_values and target_values.any?
|
23
|
+
zipped_target_values = Misc.zip_fields(target_values)
|
24
|
+
|
25
|
+
zipped_target_values << ([key].concat rest)
|
26
|
+
|
27
|
+
new_values = Misc.zip_fields zipped_target_values
|
28
|
+
else
|
29
|
+
new_values = [[key], rest.collect{|v| [v]}]
|
30
|
+
end
|
28
31
|
|
29
32
|
new[target] = new_values
|
30
33
|
end
|
data/lib/rbbt/knowledge_base.rb
CHANGED
@@ -196,30 +196,37 @@ class KnowledgeBase
|
|
196
196
|
|
197
197
|
def identify_source(name, entity)
|
198
198
|
database = get_database(name, :persist => true)
|
199
|
-
return entity if database.include? entity
|
199
|
+
return entity if Symbol === entity or (String === entity and database.include? entity)
|
200
200
|
source = source(name)
|
201
201
|
@identifiers[name] ||= {}
|
202
202
|
@identifiers[name]['source'] ||= begin
|
203
203
|
if database.identifier_files.any?
|
204
204
|
if TSV.parse_header(database.identifier_files.first).all_fields.include? source
|
205
|
-
TSV.index(database.identifiers, :target => source, :persist => true)
|
205
|
+
TSV.index(database.identifiers, :target => source, :persist => true, :order => true)
|
206
206
|
else
|
207
207
|
{}
|
208
208
|
end
|
209
209
|
else
|
210
210
|
if TSV.parse_header(Organism.identifiers(namespace)).all_fields.include? source
|
211
|
-
Organism.identifiers(namespace).index(:target => source, :persist => true)
|
211
|
+
Organism.identifiers(namespace).index(:target => source, :persist => true, :order => true)
|
212
212
|
else
|
213
213
|
{}
|
214
214
|
end
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
|
-
|
218
|
+
if Array === entity
|
219
|
+
@identifiers[name]['source'].chunked_values_at(entity).zip(entity).collect{|p|
|
220
|
+
p.compact.first
|
221
|
+
}
|
222
|
+
else
|
223
|
+
@identifiers[name]['source'][entity] || entity
|
224
|
+
end
|
219
225
|
end
|
220
226
|
|
221
227
|
def identify_target(name, entity)
|
222
228
|
database = get_database(name, :persist => true)
|
229
|
+
return entity if Symbol === entity
|
223
230
|
target = target(name)
|
224
231
|
|
225
232
|
@identifiers[name] ||= {}
|
@@ -238,7 +245,13 @@ class KnowledgeBase
|
|
238
245
|
end
|
239
246
|
end
|
240
247
|
end
|
241
|
-
|
248
|
+
if Array === entity
|
249
|
+
@identifiers[name]['target'].chunked_values_at(entity).zip(entity).collect{|p|
|
250
|
+
p.compact.first
|
251
|
+
}
|
252
|
+
else
|
253
|
+
@identifiers[name]['target'][entity] || entity
|
254
|
+
end
|
242
255
|
end
|
243
256
|
|
244
257
|
def identify(name, entity)
|
data/lib/rbbt/tsv/accessor.rb
CHANGED
@@ -593,6 +593,7 @@ module TSV
|
|
593
593
|
end
|
594
594
|
with_unnamed do
|
595
595
|
<<-EOF
|
596
|
+
Filename = #{Path === filename ? filename.find : (filename || "No filename")}
|
596
597
|
Key field = #{key_field || "*No key field*"}
|
597
598
|
Fields = #{fields ? Misc.fingerprint(fields) : "*No field info*"}
|
598
599
|
Type = #{type}
|
data/lib/rbbt/tsv/change_id.rb
CHANGED
@@ -7,7 +7,13 @@ module TSV
|
|
7
7
|
identifiers, persist_input = Misc.process_options options, :identifiers, :persist_input
|
8
8
|
|
9
9
|
if not tsv.fields.include? format
|
10
|
-
|
10
|
+
new = {}
|
11
|
+
tsv.each do |k,v|
|
12
|
+
new[k] = v.dup
|
13
|
+
end
|
14
|
+
orig_fields = tsv.fields
|
15
|
+
tsv = tsv.annotate new
|
16
|
+
new.fields = new.fields.collect{|f| "TMP-" << f }
|
11
17
|
|
12
18
|
orig_type = tsv.type
|
13
19
|
tsv = tsv.to_double if orig_type != :double
|
@@ -18,12 +24,14 @@ module TSV
|
|
18
24
|
tsv = tsv.attach identifiers, :fields => [format], :persist_input => true
|
19
25
|
end
|
20
26
|
|
21
|
-
tsv = tsv.reorder(format, tsv.fields
|
27
|
+
tsv = tsv.reorder(format, tsv.fields[0..-2])
|
22
28
|
|
23
29
|
tsv = tsv.to_flat if orig_type == :flat
|
24
30
|
|
25
31
|
tsv = tsv.to_list(&block) if orig_type == :list
|
26
32
|
|
33
|
+
tsv.fields = orig_fields
|
34
|
+
|
27
35
|
tsv
|
28
36
|
else
|
29
37
|
tsv.reorder(format)
|
@@ -15,8 +15,9 @@ module NamedArray
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.setup(array, fields, key = nil, entity_options = nil, entity_templates = nil)
|
18
|
+
return array if array.nil?
|
18
19
|
array.extend NamedArray unless NamedArray === array
|
19
|
-
array.fields = fields
|
20
|
+
array.fields = Annotated.purge fields
|
20
21
|
array.key = key
|
21
22
|
array.entity_options = entity_options unless entity_options.nil?
|
22
23
|
array.entity_templates = entity_templates unless entity_templates.nil?
|
@@ -112,9 +113,12 @@ module NamedArray
|
|
112
113
|
|
113
114
|
def each(&block)
|
114
115
|
if defined?(Entity) and not @fields.nil? and not @fields.empty?
|
115
|
-
|
116
|
+
i = 0
|
117
|
+
super do |elem|
|
118
|
+
field = @fields[i]
|
116
119
|
elem = prepare_entity(elem, field, entity_options)
|
117
120
|
yield(elem)
|
121
|
+
i += 1
|
118
122
|
elem
|
119
123
|
end
|
120
124
|
else
|
@@ -499,12 +499,13 @@ module Workflow
|
|
499
499
|
real_dependencies << case dependency
|
500
500
|
when Array
|
501
501
|
inputs = inputs.dup
|
502
|
+
workflow, task, options = dependency
|
502
503
|
options = dependency.last if Hash === dependency.last
|
503
504
|
options.each{|i,v|
|
504
505
|
case v
|
505
506
|
when Symbol
|
506
507
|
rec_dependency = real_dependencies.collect{|d| [d, d.dependencies].flatten}.flatten.select{|d| d.task.name == v }.first
|
507
|
-
rec_dependency = rec_dependency.run unless (dependency.first.tasks[dependency[1]].input_options[i] || {})[:stream]
|
508
|
+
rec_dependency = rec_dependency.run(true).grace.join.load unless (dependency.first.tasks[dependency[1]].input_options[i] || {})[:stream]
|
508
509
|
inputs[i] = rec_dependency
|
509
510
|
else
|
510
511
|
inputs[i] = v
|
@@ -14,11 +14,12 @@ Access workflow knowledge base
|
|
14
14
|
|
15
15
|
-h--help Show this help:
|
16
16
|
-cl--clean Clean the last step of the job so that it gets recomputed:
|
17
|
+
-s--source_entities* Source entities
|
17
18
|
-sf--source_format* Source format
|
18
|
-
-
|
19
|
+
-t--target_entities* Target entities
|
19
20
|
-tf--target_format* Target format
|
20
|
-
-
|
21
|
-
-i--
|
21
|
+
-d--details Print details on matches
|
22
|
+
-i--identify Attempt to identify entities by identifier translation
|
22
23
|
EOF
|
23
24
|
|
24
25
|
workflow = ARGV.shift
|
@@ -34,12 +35,14 @@ workflow = Workflow.require_workflow workflow
|
|
34
35
|
action = :list_databases if database.nil?
|
35
36
|
action ||= :summary
|
36
37
|
|
38
|
+
knowledge_base = workflow.knowledge_base
|
39
|
+
|
37
40
|
case action.to_sym
|
38
41
|
when :list_databases
|
39
|
-
dbs =
|
42
|
+
dbs = knowledge_base.registry.keys
|
40
43
|
puts dbs * "\n"
|
41
44
|
when :summary
|
42
|
-
db =
|
45
|
+
db = knowledge_base.get_database(database)
|
43
46
|
puts db.summary
|
44
47
|
when :subset
|
45
48
|
source_format = options[:source_format] || :source
|
@@ -50,12 +53,16 @@ when :subset
|
|
50
53
|
source_entities = source_entities.split(/,\|/) if String === source_entities
|
51
54
|
target_entities = target_entities.split(/,\|/) if String === target_entities
|
52
55
|
|
56
|
+
if options[:identify]
|
57
|
+
source_entities = knowledge_base.identify(database, source_entities)
|
58
|
+
target_entities = knowledge_base.identify(database, target_entities)
|
59
|
+
end
|
53
60
|
entities = {source_format => source_entities, target_format => target_entities}
|
54
61
|
|
55
|
-
matches =
|
62
|
+
matches = knowledge_base.subset(database, entities)
|
56
63
|
matches.each do |item|
|
57
64
|
puts Log.color :magenta, item
|
58
|
-
if options[:
|
65
|
+
if options[:details]
|
59
66
|
source = item.source_entity
|
60
67
|
target = item.target_entity
|
61
68
|
source = source.name if source.respond_to? :name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.14.
|
4
|
+
version: 5.14.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|