rbbt-rest 1.3.24 → 1.3.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/rest/common/misc.rb +2 -0
- data/lib/rbbt/rest/knowledge_base.rb +99 -0
- data/lib/rbbt/rest/knowledge_base/helpers.rb +6 -1
- data/lib/rbbt/rest/workflow/jobs.rb +1 -0
- data/share/views/knowledge_base_partials/matches.haml +14 -0
- data/share/views/knowledge_base_partials/subset.haml +7 -0
- data/share/views/public/js/helpers.js +0 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff57d6c10b5e72c5c364001762523ac37fd71bee
|
4
|
+
data.tar.gz: b2aa30882aa2b5f97dfc1302f6c2c73d92a9cf86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a747a879a08a4eb86bd2985f877344938b1ea8bb53ca02b4c51843436ae0fcb325ac7851191f415c6924aeb9e3ff58fee3d4084f7f207b81402e76ebf5f58a4
|
7
|
+
data.tar.gz: 9e0e7b4989f2542c7cef4ed99220857d3104f3ae4af3d1a4f6c0f61e258be60ae7afcb0dead43be946baabe266325cb52c159f14e553890d8951087f214a81d8
|
@@ -11,6 +11,105 @@ module Sinatra
|
|
11
11
|
base.module_eval do
|
12
12
|
helpers KnowledgeBaseRESTHelpers
|
13
13
|
|
14
|
+
get '/knowledge_base/:name/:database/children/:entity' do
|
15
|
+
name = consume_parameter :name
|
16
|
+
database = consume_parameter :database
|
17
|
+
entity = consume_parameter :entity
|
18
|
+
|
19
|
+
kb = get_knowledge_base name
|
20
|
+
matches = kb.children(database, entity)
|
21
|
+
case @format
|
22
|
+
when :tsv
|
23
|
+
content_type "text/tab-separated-values"
|
24
|
+
halt 200, matches.tsv.to_s
|
25
|
+
when :html
|
26
|
+
template_render('knowledge_base_partials/matches', {:matches => matches}, "Children: #{ [name, database, entity] }")
|
27
|
+
when :json
|
28
|
+
content_type :json
|
29
|
+
halt 200, matches.target.to_json
|
30
|
+
else
|
31
|
+
content_type :text
|
32
|
+
halt 200, matches.target * "\n"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
get '/knowledge_base/:name/:database/parents/:entity' do
|
37
|
+
name = consume_parameter :name
|
38
|
+
database = consume_parameter :database
|
39
|
+
entity = consume_parameter :entity
|
40
|
+
|
41
|
+
kb = get_knowledge_base name
|
42
|
+
matches = kb.parents(database, entity)
|
43
|
+
case @format
|
44
|
+
when :tsv
|
45
|
+
content_type "text/tab-separated-values"
|
46
|
+
halt 200, matches.tsv.to_s
|
47
|
+
when :html
|
48
|
+
template_render('knowledge_base_partials/matches', {:matches => matches}, "Parents: #{ [name, database, entity] }")
|
49
|
+
when :json
|
50
|
+
content_type :json
|
51
|
+
halt 200, matches.source.to_json
|
52
|
+
else
|
53
|
+
content_type :text
|
54
|
+
halt 200, matches.source * "\n"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
get '/knowledge_base/:name/:database/neighbours/:entity' do
|
59
|
+
name = consume_parameter :name
|
60
|
+
database = consume_parameter :database
|
61
|
+
entity = consume_parameter :entity
|
62
|
+
|
63
|
+
kb = get_knowledge_base name
|
64
|
+
neighbours = kb.neighbours(database, entity)
|
65
|
+
case @format
|
66
|
+
when :tsv
|
67
|
+
content_type "text/tab-separated-values"
|
68
|
+
halt 200, neighbours.values.collect{|m| m.tsv.to_s } * "\n\n"
|
69
|
+
when :html
|
70
|
+
template_render('knowledge_base_partials/matches', {:matches => neighbours}, "Neighbours: #{ [name, database, entity] }")
|
71
|
+
when :json
|
72
|
+
content_type :json
|
73
|
+
neighs = {}
|
74
|
+
neighs[:parents] = neighbours[:parents].source if neighbours[:parents]
|
75
|
+
neighs[:children] = neighbours[:children].target
|
76
|
+
halt 200, neighs.to_json
|
77
|
+
else
|
78
|
+
content_type :text
|
79
|
+
neighs = []
|
80
|
+
neighs.concat neighbours[:parents].source if neighbours[:parents]
|
81
|
+
neighs.concat neighbours[:children].target
|
82
|
+
halt 200, neighs * "\n"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
get '/knowledge_base/:name/:database/subset' do
|
87
|
+
name = consume_parameter :name
|
88
|
+
database = consume_parameter :database
|
89
|
+
source = consume_parameter :source
|
90
|
+
target = consume_parameter :target
|
91
|
+
|
92
|
+
source = source == "all" ? :all : source.split(@array_separator) if source
|
93
|
+
target = target == "all" ? :all : target.split(@array_separator) if target
|
94
|
+
entities = { :source => source, :target => target }
|
95
|
+
|
96
|
+
kb = get_knowledge_base name
|
97
|
+
subset = kb.subset(database, entities)
|
98
|
+
case @format
|
99
|
+
when :tsv
|
100
|
+
content_type "text/tab-separated-values"
|
101
|
+
halt 200, subset.tsv.to_s
|
102
|
+
when :html
|
103
|
+
template_render('knowledge_base_partials/subset', {:subset => subset}, "Subset: #{ [name, database] }")
|
104
|
+
when :json
|
105
|
+
content_type :json
|
106
|
+
halt 200, subset.source.to_json
|
107
|
+
else
|
108
|
+
content_type :text
|
109
|
+
halt 200, subset.source * "\n"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
14
113
|
#{{{ Info
|
15
114
|
|
16
115
|
get '/knowledge_base/info/:name/:database/:pair' do
|
@@ -56,7 +56,12 @@ module KnowledgeBaseRESTHelpers
|
|
56
56
|
def get_knowledge_base(name, namespace = nil)
|
57
57
|
@@knowledge_bases ||= IndiferentHash.setup({})
|
58
58
|
@@knowledge_bases[name] ||= begin
|
59
|
-
|
59
|
+
begin
|
60
|
+
mod = Kernel.const_get name
|
61
|
+
return mod.knowledge_base if mod.respond_to? :knowledge_base
|
62
|
+
rescue Exception
|
63
|
+
end
|
64
|
+
kb = case
|
60
65
|
when [:genomics, "genomics"].include?(name)
|
61
66
|
Genomics.knowledge_base
|
62
67
|
when (Misc.path_relative_to(settings.cache_dir, name) and File.exists?(name))
|
@@ -40,6 +40,7 @@ module WorkflowRESTHelpers
|
|
40
40
|
|
41
41
|
def execution_type(workflow, task)
|
42
42
|
export = type_of_export(workflow, task)
|
43
|
+
return :sync if export == :exec and format == :html
|
43
44
|
return export if export == :exec or cache_type.nil?
|
44
45
|
return cache_type if cache_type
|
45
46
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
- if Hash === matches and matches.keys.length == 2 and matches.values.select{|v| v.any?}.length > 2
|
2
|
+
%h3 Parents
|
3
|
+
= table do
|
4
|
+
- matches = matches[:parents]
|
5
|
+
- matches.tsv
|
6
|
+
|
7
|
+
%h3 Children
|
8
|
+
= table do
|
9
|
+
- matches = matches[:children]
|
10
|
+
- matches.tsv
|
11
|
+
- else
|
12
|
+
= table do
|
13
|
+
- matches = matches.values.sort{|v| v.length}.last if Hash === matches
|
14
|
+
- matches.tsv
|
@@ -0,0 +1,7 @@
|
|
1
|
+
= table do
|
2
|
+
- fields = subset.info_fields
|
3
|
+
- type = [subset.source_type, subset.target_type] * "~"
|
4
|
+
- tsv = TSV.setup({}, :key_field => type, :fields => fields, :type => :list, :namespace => subset.namespace)
|
5
|
+
- subset.each do |match|
|
6
|
+
- tsv[match] = match.info.values_at *fields
|
7
|
+
- tsv
|
@@ -59,7 +59,6 @@ function parse_parameters(params){
|
|
59
59
|
function require_js(url, success){
|
60
60
|
var async = false;
|
61
61
|
var cache = production;
|
62
|
-
console.log("Require js: " + url)
|
63
62
|
if (undefined === success){
|
64
63
|
async = false;
|
65
64
|
}else{
|
@@ -68,9 +67,6 @@ function require_js(url, success){
|
|
68
67
|
|
69
68
|
url = url.replace('/js/', '/js-find/')
|
70
69
|
$.ajax({url: url, cache:cache, dataType:'script', async: async, success: success} ).fail(function(jqxhr, settings, exception){
|
71
|
-
console.log('Exception loading: ' + url)
|
72
|
-
console.log(exception)
|
73
|
-
console.log(jqxhr)
|
74
70
|
})
|
75
71
|
}
|
76
72
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.25
|
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
|
@@ -277,6 +277,8 @@ files:
|
|
277
277
|
- share/views/job_result/tsv.haml
|
278
278
|
- share/views/job_result/yaml.haml
|
279
279
|
- share/views/knowledge_base_partials/association.haml
|
280
|
+
- share/views/knowledge_base_partials/matches.haml
|
281
|
+
- share/views/knowledge_base_partials/subset.haml
|
280
282
|
- share/views/layout.haml
|
281
283
|
- share/views/layout/top_menu.haml
|
282
284
|
- share/views/layout/top_menu/favourites.haml
|