rbbt-util 5.14.8 → 5.14.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/association.rb +7 -14
- data/lib/rbbt/association/index.rb +6 -7
- data/lib/rbbt/association/item.rb +13 -4
- data/lib/rbbt/knowledge_base.rb +5 -4
- data/share/rbbt_commands/workflow/server +2 -0
- data/test/rbbt/test_association.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2e935c66915d12e54d8a483af1f3ab9c0447c9c
|
4
|
+
data.tar.gz: 014e991d3c4c8769e4ff480e0a9566a65f84a160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19e5dfaf77d8755695c2bed2c0f379eb3421e7b021e93e2caaa551ccc304ad70f1c91c892d096f6d3abe689f84a6a6d43260c2d68c4b0b4c1a9ac8cb946bca81
|
7
|
+
data.tar.gz: 402865585352cc0dfd319d84c40d125ee04eabab5105ea7039c05ea018ed709b27e1efb6d059da3260c8e1f78c47d1e439206cb59cfc79b5de09ce8b36eb2227
|
data/lib/rbbt/association.rb
CHANGED
@@ -14,22 +14,15 @@ module Association
|
|
14
14
|
|
15
15
|
new = tsv.dup
|
16
16
|
tsv.with_unnamed do
|
17
|
-
tsv.through do |
|
18
|
-
Misc.zip_fields(values).each do |
|
19
|
-
target, *
|
20
|
-
|
21
|
-
|
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
|
17
|
+
tsv.through do |source, values|
|
18
|
+
Misc.zip_fields(values).each do |_target_values|
|
19
|
+
target, *target_values = _target_values
|
20
|
+
if new[target].nil?
|
21
|
+
new[target] = [[source]] + target_values.collect{|v| [v] }
|
28
22
|
else
|
29
|
-
|
23
|
+
new[target].first << source
|
24
|
+
new[target][1..-1].zip(target_values).each{|list,elem| list << elem }
|
30
25
|
end
|
31
|
-
|
32
|
-
new[target] = new_values
|
33
26
|
end
|
34
27
|
end
|
35
28
|
end
|
@@ -38,6 +38,8 @@ module Association
|
|
38
38
|
|
39
39
|
Association::Index.setup new
|
40
40
|
|
41
|
+
new.undirected = undirected
|
42
|
+
|
41
43
|
new
|
42
44
|
end
|
43
45
|
end
|
@@ -80,13 +82,12 @@ module Association
|
|
80
82
|
matches = source.uniq.inject([]){|acc,e| acc.concat(match(e)) }
|
81
83
|
end
|
82
84
|
|
83
|
-
return matches if target
|
85
|
+
return matches if target == :all or target == "all"
|
84
86
|
|
85
87
|
target_matches = {}
|
86
88
|
|
87
89
|
matches.each{|code|
|
88
90
|
s,sep,t = code.partition "~"
|
89
|
-
next if (undirected and t > s)
|
90
91
|
target_matches[t] ||= []
|
91
92
|
target_matches[t] << code
|
92
93
|
}
|
@@ -96,11 +97,9 @@ module Association
|
|
96
97
|
|
97
98
|
def subset_entities(entities)
|
98
99
|
source, target = select_entities(entities)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
return if Array === target and target.empty?
|
103
|
-
return if Array === source and source.empty?
|
100
|
+
return [] if source.nil? or target.nil?
|
101
|
+
return [] if Array === target and target.empty?
|
102
|
+
return [] if Array === source and source.empty?
|
104
103
|
subset source, target
|
105
104
|
end
|
106
105
|
end
|
@@ -7,6 +7,10 @@ module AssociationItem
|
|
7
7
|
annotation :database
|
8
8
|
annotation :reverse
|
9
9
|
|
10
|
+
property :namespace => :both do
|
11
|
+
knowledge_base.namespace
|
12
|
+
end
|
13
|
+
|
10
14
|
property :part => :array2single do
|
11
15
|
self.clean_annotations.collect{|p| p.partition("~") }
|
12
16
|
end
|
@@ -19,11 +23,11 @@ module AssociationItem
|
|
19
23
|
self.clean_annotations.collect{|p| p[/[^~]+/] }
|
20
24
|
end
|
21
25
|
|
22
|
-
property :target_type => :
|
23
|
-
reverse ? knowledge_base.source(database) : knowledge_base.target(database)
|
26
|
+
property :target_type => :both do
|
27
|
+
type = reverse ? knowledge_base.source(database) : knowledge_base.target(database)
|
24
28
|
end
|
25
29
|
|
26
|
-
property :source_type => :
|
30
|
+
property :source_type => :both do
|
27
31
|
reverse ? knowledge_base.target(database) : knowledge_base.source(database)
|
28
32
|
end
|
29
33
|
|
@@ -42,8 +46,13 @@ module AssociationItem
|
|
42
46
|
value.collect{|v| NamedArray.setup(v, knowledge_base.get_index(database).fields)}
|
43
47
|
end
|
44
48
|
|
49
|
+
property :info_fields => :both do
|
50
|
+
knowledge_base.index_fields(database)
|
51
|
+
end
|
52
|
+
|
45
53
|
property :info => :array2single do
|
46
|
-
fields =
|
54
|
+
fields = self.info_fields
|
55
|
+
|
47
56
|
return [{}] * self.length if fields.nil? or fields.empty?
|
48
57
|
|
49
58
|
value = self.value
|
data/lib/rbbt/knowledge_base.rb
CHANGED
@@ -15,6 +15,11 @@ class KnowledgeBase
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
|
19
|
+
def setup(name, matches, reverse = false)
|
20
|
+
AssociationItem.setup matches, self, name, reverse
|
21
|
+
end
|
22
|
+
|
18
23
|
attr_accessor :namespace, :dir, :indices, :registry, :format, :databases, :entity_options
|
19
24
|
def initialize(dir, namespace = nil)
|
20
25
|
@dir = Path.setup(dir).find
|
@@ -260,10 +265,6 @@ class KnowledgeBase
|
|
260
265
|
|
261
266
|
#{{{ Query
|
262
267
|
|
263
|
-
def setup(name, matches, reverse = false)
|
264
|
-
AssociationItem.setup matches, self, name, reverse
|
265
|
-
end
|
266
|
-
|
267
268
|
def all(name, options={})
|
268
269
|
repo = get_index name, options
|
269
270
|
setup name, repo.keys
|
@@ -10,6 +10,7 @@ require 'rbbt/rest/main'
|
|
10
10
|
require 'rbbt/rest/entity'
|
11
11
|
require 'rbbt/rest/workflow'
|
12
12
|
require 'rbbt/rest/file_server'
|
13
|
+
require 'rbbt/rest/knowledge_base'
|
13
14
|
require 'rbbt/rest/helpers'
|
14
15
|
|
15
16
|
options = SOPT.get "-e--environment*:-p--port*:-s--server*:-b--bind*:-e--environment*"
|
@@ -34,6 +35,7 @@ class WorkflowRest < Sinatra::Base
|
|
34
35
|
register Sinatra::RbbtRESTMain
|
35
36
|
register Sinatra::RbbtRESTWorkflow
|
36
37
|
register Sinatra::RbbtRESTEntity
|
38
|
+
register Sinatra::RbbtRESTKnowledgeBase
|
37
39
|
helpers Sinatra::RbbtMiscHelpers
|
38
40
|
|
39
41
|
#{{{ DIRECTORIES
|
@@ -57,6 +57,9 @@ class TestAssociations < Test::Unit::TestCase
|
|
57
57
|
assert_equal ["aa"], database["TP53"].first
|
58
58
|
end
|
59
59
|
|
60
|
+
def test_reciprocal
|
61
|
+
end
|
62
|
+
|
60
63
|
|
61
64
|
def __test_ICGC
|
62
65
|
assoc = Association.open(Open.open('ftp://data.dcc.icgc.org/current/Chronic_Lymphocytic_Leukemia-ISC_MICINN-ES/simple_somatic_mutation.CLLE-ES.tsv.gz'),
|