rbbt-rest 1.4.3 → 1.4.4
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/rest/common/table.rb +1 -1
- data/lib/rbbt/rest/knowledge_base.rb +442 -441
- data/lib/rbbt/rest/knowledge_base/helpers.rb +16 -0
- data/lib/rbbt/rest/knowledge_base/locate.rb +41 -0
- data/lib/rbbt/rest/knowledge_base/query.rb +441 -441
- data/lib/rbbt/rest/knowledge_base/render.rb +15 -0
- data/lib/rbbt/rest/workflow.rb +2 -0
- data/lib/rbbt/rest/workflow/jobs.rb +1 -3
- data/share/views/association/Default.haml +9 -0
- data/share/views/compass/layout.sass +15 -0
- data/share/views/compass/rbbt/table.sass +3 -1
- data/share/views/entity_partials/list_container.haml +18 -6
- data/share/views/knowledge_base_partials/association.haml +22 -19
- data/share/views/knowledge_base_partials/association/info.haml +38 -0
- data/share/views/knowledge_base_partials/association/value.haml +13 -0
- data/share/views/public/js/_ajax_replace.js +3 -1
- data/share/views/public/js/rbbt/modal.js +61 -58
- metadata +7 -2
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rbbt/util/open'
|
2
|
+
require 'rbbt/rest/common/render'
|
3
|
+
|
4
|
+
require 'haml'
|
5
|
+
module KnowledgeBaseRESTHelpers
|
6
|
+
|
7
|
+
def association_render(pair, database = nil)
|
8
|
+
database ||= pair.database
|
9
|
+
template_file = locate_association_template(database)
|
10
|
+
|
11
|
+
locals = {:pair => pair, :database => database}
|
12
|
+
|
13
|
+
render(template_file, locals, nil)
|
14
|
+
end
|
15
|
+
end
|
data/lib/rbbt/rest/workflow.rb
CHANGED
@@ -11,6 +11,7 @@ require 'rbbt/rest/workflow/locate'
|
|
11
11
|
require 'rbbt/rest/workflow/render'
|
12
12
|
require 'rbbt/rest/workflow/jobs'
|
13
13
|
|
14
|
+
|
14
15
|
require 'sinatra/base'
|
15
16
|
require 'json'
|
16
17
|
|
@@ -22,6 +23,7 @@ module Sinatra
|
|
22
23
|
views_dir = workflow.respond_to?(:libdir)? workflow.libdir.www.views.find(:lib) : nil
|
23
24
|
if views_dir and views_dir.exists?
|
24
25
|
Log.debug "Registering views for #{ workflow }: #{ views_dir.find }"
|
26
|
+
KnowledgeBaseRESTHelpers.association_resources.unshift views_dir
|
25
27
|
EntityRESTHelpers.entity_resources.unshift views_dir
|
26
28
|
RbbtRESTHelpers.template_resources.unshift views_dir
|
27
29
|
|
@@ -188,12 +188,10 @@ module WorkflowRESTHelpers
|
|
188
188
|
end
|
189
189
|
|
190
190
|
begin
|
191
|
-
job.fork
|
192
|
-
job.grace
|
191
|
+
job.fork unless job.started?
|
193
192
|
|
194
193
|
job_url = to(File.join("/", workflow.to_s, task, job.name))
|
195
194
|
job_url += "?_format=#{@format}" if @format
|
196
|
-
#halt 200, job.name if format == :jobname
|
197
195
|
if format == :jobname
|
198
196
|
content_type :text
|
199
197
|
job.name
|
@@ -0,0 +1,9 @@
|
|
1
|
+
- database ||= pair.database
|
2
|
+
|
3
|
+
- matrix = pair.knowledge_base.get_index(database).fields == ["Value"]
|
4
|
+
|
5
|
+
- if matrix
|
6
|
+
= partial_render('knowledge_base_partials/association/value', :pair => pair, :knowledge_base => pair.knowledge_base, :database => database)
|
7
|
+
- else
|
8
|
+
= partial_render('knowledge_base_partials/association/info', :pair => pair, :knowledge_base => pair.knowledge_base, :database => database)
|
9
|
+
|
@@ -204,3 +204,18 @@ a.fragment
|
|
204
204
|
width: 100%
|
205
205
|
width: 2em
|
206
206
|
|
207
|
+
@media #{$only-large}
|
208
|
+
.row
|
209
|
+
+clearfix()
|
210
|
+
.small_column
|
211
|
+
+span(1 of 3)
|
212
|
+
&:last-child
|
213
|
+
+span(last 1 of 3)
|
214
|
+
&:first-child
|
215
|
+
+span(first 1 of 3)
|
216
|
+
.column
|
217
|
+
+span(1 of 2)
|
218
|
+
&:last-child
|
219
|
+
+span(last 1 of 2)
|
220
|
+
&:first-child
|
221
|
+
+span(first 1 of 2)
|
@@ -5,15 +5,21 @@
|
|
5
5
|
- list = list.call
|
6
6
|
- next if list.nil?
|
7
7
|
%dt.next
|
8
|
-
= list.list_link :length, id
|
8
|
+
= list.respond_to?(:list_link) ? list.list_link(:length, id) : list.length
|
9
9
|
%span.title
|
10
10
|
= text || id
|
11
11
|
%dd
|
12
12
|
- if (defined? force and force) or list.length < 500
|
13
|
-
|
13
|
+
- if list.respond_to? :link
|
14
|
+
= list.link * ", "
|
15
|
+
- else
|
16
|
+
= list * ", "
|
14
17
|
- else
|
15
18
|
= modal_fragment "Too many entities to list" do
|
16
|
-
|
19
|
+
- if list.respond_to? :link
|
20
|
+
= list.link * ", "
|
21
|
+
- else
|
22
|
+
= list * ", "
|
17
23
|
- else
|
18
24
|
- if list.empty?
|
19
25
|
%dt
|
@@ -22,15 +28,21 @@
|
|
22
28
|
= text || id
|
23
29
|
- else
|
24
30
|
%dt.next
|
25
|
-
= list.list_link :length, id
|
31
|
+
= list.respond_to?(:list_link) ? list.list_link(:length, id) : list.length
|
26
32
|
%span.title
|
27
33
|
= text || id
|
28
34
|
%dd
|
29
35
|
- if (defined? force and force) or list.length < 500
|
30
|
-
|
36
|
+
- if list.respond_to? :link
|
37
|
+
= list.link * ", "
|
38
|
+
- else
|
39
|
+
= list * ", "
|
31
40
|
- else
|
32
41
|
= reveal "Too many entities to list" do
|
33
42
|
= fragment do
|
34
|
-
|
43
|
+
- if list.respond_to? :link
|
44
|
+
= list.link * ", "
|
45
|
+
- else
|
46
|
+
= list * ", "
|
35
47
|
|
36
48
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
- require 'rbbt/sources/PSI_MI'
|
1
2
|
- values = index[pair]
|
2
3
|
|
3
4
|
- source = pair.source_entity
|
@@ -9,22 +10,24 @@
|
|
9
10
|
|
10
11
|
%h3== #{name} in #{pair.database} #{kb_name}
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
-
|
21
|
-
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
-
|
30
|
-
|
13
|
+
= association_render(pair, pair.database)
|
14
|
+
|
15
|
+
|
16
|
+
- kb = pair.knowledge_base
|
17
|
+
- other_databases = []
|
18
|
+
|
19
|
+
- kb.registry.each do |database,info|
|
20
|
+
- index = kb.get_index database
|
21
|
+
- next unless index.include? pair
|
22
|
+
- next if database == pair.database
|
23
|
+
- other_databases << database
|
24
|
+
|
25
|
+
- if other_databases.any?
|
26
|
+
%h5 In other databases
|
27
|
+
|
28
|
+
|
29
|
+
%dl.tabs
|
30
|
+
- other_databases.each do |database|
|
31
|
+
%dt.next=database
|
32
|
+
%dd
|
33
|
+
= association_render(pair, database)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
- index = knowledge_base.get_index database
|
2
|
+
|
3
|
+
- kb_name = File.basename pair.knowledge_base.dir
|
4
|
+
|
5
|
+
- if index.include? pair
|
6
|
+
- fields = index.fields
|
7
|
+
- values = index[pair]
|
8
|
+
|
9
|
+
- if fields.any?
|
10
|
+
- tsv = TSV.setup({}, :key_field => "Num", :fields => fields, :type => :list)
|
11
|
+
- values.zip(fields).uniq.each_with_index do |p,i|
|
12
|
+
- value, field = p
|
13
|
+
- value.split(";;").each_with_index do |part,j|
|
14
|
+
- tsv[j] ||= [nil] * fields.length
|
15
|
+
- tsv[j][i] = part
|
16
|
+
- tsv.entity_options = knowledge_base.entity_options
|
17
|
+
- tsv.namespace = knowledge_base.namespace
|
18
|
+
|
19
|
+
- if tsv.fields.include? "PMID"
|
20
|
+
- tsv.add_field "Title" do |k,v|
|
21
|
+
- v["PMID"].title
|
22
|
+
|
23
|
+
- if tsv.fields.include? "Publication"
|
24
|
+
- tsv.add_field "Title" do |k,v|
|
25
|
+
- PMID.setup(v["Publication"]).title if v["Publication"] =~ /^\d+$/
|
26
|
+
|
27
|
+
- if tsv.fields.include? "Method"
|
28
|
+
- tsv.add_field "Evidence" do |k,v|
|
29
|
+
- PSI_MITerm.setup(v["Method"]).name if v["Method"] =~ /^MI:\d+$/
|
30
|
+
|
31
|
+
-#= tsv2html(tsv, :table_id => "#{pair} in #{database} #{kb_name}")
|
32
|
+
= association_table tsv, :table_id => "#{pair} in #{database} #{kb_name}"
|
33
|
+
|
34
|
+
- else
|
35
|
+
No information for #{pair} in #{database}
|
36
|
+
|
37
|
+
- else
|
38
|
+
Pair #{pair} not registered in #{ database }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
- index = knowledge_base.get_index database
|
2
|
+
- fields = index.fields
|
3
|
+
|
4
|
+
- others = index.prefix(pair.source)
|
5
|
+
|
6
|
+
- value = [index[pair]].flatten.first.to_f
|
7
|
+
|
8
|
+
- rest = index.values_at(*others).flatten.compact.collect{|v| v and v =~ /\d/ ? v.to_f : nil}.compact
|
9
|
+
|
10
|
+
%p= value
|
11
|
+
|
12
|
+
= rest.sort * ", "
|
13
|
+
|
@@ -93,6 +93,7 @@ function replace_object(object, href, embedd, complete){
|
|
93
93
|
if (embedd === undefined){ embedd = false; }
|
94
94
|
|
95
95
|
object.addClass("embedded").attr('target-href', href)
|
96
|
+
|
96
97
|
$.ajax({
|
97
98
|
url : href,
|
98
99
|
cache: false,
|
@@ -106,6 +107,7 @@ function replace_object(object, href, embedd, complete){
|
|
106
107
|
error = $('<div>').append(error_span).append(error_message)
|
107
108
|
object.removeClass("reloading").addClass("error").css('height', 0).html(error).css('height', 'auto').attr('target-href', href);
|
108
109
|
},
|
110
|
+
|
109
111
|
success: function( data, stat, req ) {
|
110
112
|
object.removeClass('error');
|
111
113
|
if (req.status == 202){
|
@@ -133,13 +135,13 @@ function replace_object(object, href, embedd, complete){
|
|
133
135
|
href = remove_parameter(href, '_');
|
134
136
|
}
|
135
137
|
object.addClass("embedded").attr('target-href', href).get(0).innerHTML = data;
|
136
|
-
// eval js
|
137
138
|
object.find('script').each(function(){eval(this.text = this.text || $(this).text())} );
|
138
139
|
|
139
140
|
capture_embedded_form(object);
|
140
141
|
update_rbbt();
|
141
142
|
}else{
|
142
143
|
object.replaceWith(data);
|
144
|
+
|
143
145
|
update_rbbt();
|
144
146
|
}
|
145
147
|
}
|
@@ -3,60 +3,62 @@ $.widget("rbbt.modal", {
|
|
3
3
|
},
|
4
4
|
|
5
5
|
_reset_modal: function(modal_title, source_id){
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
var url = $(tool.element).find('> .content').attr('target-href')
|
26
|
-
if (url !== undefined){
|
27
|
-
$('#top_menu li.favourites').favourites('toggle_page', url)
|
28
|
-
}
|
29
|
-
return false
|
30
|
-
})
|
6
|
+
var tool = this
|
7
|
+
|
8
|
+
var modal = this.element
|
9
|
+
modal.html('').addClass('modal')
|
10
|
+
|
11
|
+
var title = $('<div>').addClass('title')
|
12
|
+
if (modal_title !== undefined){ title.html(modal_title) }
|
13
|
+
var controls = $('<div>').addClass('controls')
|
14
|
+
controls.append($('<a>').addClass('toggle_favourite').append($('<i>').addClass('fi-star')))
|
15
|
+
controls.append($('<a>').addClass('link-reveal-modal').append($('<i>').addClass('fi-arrow-right')))
|
16
|
+
controls.append($('<a>').addClass('close-reveal-modal').append($('<i>').addClass('fi-x')))
|
17
|
+
|
18
|
+
var header = $('<div>').addClass('header').append(title).append(controls)
|
19
|
+
|
20
|
+
modal.append(header)
|
21
|
+
var content = $('<div>').addClass('content').html(content)
|
22
|
+
modal.attr('attr-reveal_source_id', source_id)
|
23
|
+
|
24
|
+
modal.on('click', 'a.close-reveal-modal', function(){ tool.close() })
|
31
25
|
|
32
|
-
|
33
|
-
|
26
|
+
modal.on('click', 'a.toggle_favourite', function(){
|
27
|
+
var url = $(tool.element).find('> .content').attr('target-href')
|
28
|
+
if (url !== undefined){
|
29
|
+
$('#top_menu li.favourites').favourites('toggle_page', url)
|
30
|
+
}
|
31
|
+
return false
|
32
|
+
})
|
34
33
|
|
35
|
-
|
34
|
+
var content = $('<div>').addClass('content')
|
35
|
+
modal.append(content)
|
36
36
|
|
37
|
-
|
37
|
+
modal.removeClass('url').removeClass('entity')
|
38
|
+
|
39
|
+
return modal;
|
38
40
|
},
|
39
41
|
|
40
42
|
_shown_url: function(){
|
41
|
-
|
43
|
+
return $(this.element).find('> .content').attr('target-href')
|
42
44
|
},
|
43
45
|
|
44
46
|
update_star: function(){
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
var url = this._shown_url()
|
48
|
+
if ($('#top_menu li.favourites').favourites('is_favourite', url)){
|
49
|
+
$(this.element).find('a.toggle_favourite').addClass('active');
|
50
|
+
}else{
|
51
|
+
$(this.element).find('a.toggle_favourite').removeClass('active');
|
52
|
+
}
|
51
53
|
},
|
52
54
|
|
53
55
|
show: function(content, title, source_id){
|
54
|
-
|
55
|
-
|
56
|
+
var tool = this;
|
57
|
+
var modal = tool._reset_modal(title, source_id)
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
modal.find('> .content').html(content)
|
60
|
+
this.element.show()
|
61
|
+
update_rbbt()
|
60
62
|
},
|
61
63
|
|
62
64
|
ask: function(content, title, complete){
|
@@ -65,31 +67,32 @@ $.widget("rbbt.modal", {
|
|
65
67
|
},
|
66
68
|
|
67
69
|
show_url: function(url, title, source_id, complete){
|
68
|
-
|
69
|
-
|
70
|
+
var tool = this;
|
71
|
+
var modal = this._reset_modal(title, source_id)
|
72
|
+
tool.url = url
|
70
73
|
|
71
|
-
|
74
|
+
$('body').append(modal)
|
72
75
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
+
replace_object(modal.find('> .content'), url, true, function(){
|
77
|
+
var url = tool.url
|
78
|
+
url = remove_parameter(url, '_')
|
76
79
|
|
77
|
-
|
78
|
-
|
80
|
+
modal.addClass('url')
|
81
|
+
modal.find('.link-reveal-modal').attr('href', url)
|
79
82
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
83
|
+
if (url != undefined && url.match(/^\/(?:entity|entity_list|entity_map)\//) != null){
|
84
|
+
modal.addClass('entity')
|
85
|
+
tool.update_star()
|
86
|
+
}
|
84
87
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
88
|
+
tool.element.show()
|
89
|
+
if (undefined !== complete){ complete()}
|
90
|
+
update_rbbt()
|
91
|
+
})
|
89
92
|
},
|
90
93
|
|
91
94
|
close: function(){
|
92
|
-
|
95
|
+
this.element.hide()
|
93
96
|
}
|
94
97
|
})
|
95
98
|
|
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.4.
|
4
|
+
version: 1.4.4
|
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-09-
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -204,7 +204,9 @@ files:
|
|
204
204
|
- lib/rbbt/rest/helpers.rb
|
205
205
|
- lib/rbbt/rest/knowledge_base.rb
|
206
206
|
- lib/rbbt/rest/knowledge_base/helpers.rb
|
207
|
+
- lib/rbbt/rest/knowledge_base/locate.rb
|
207
208
|
- lib/rbbt/rest/knowledge_base/query.rb
|
209
|
+
- lib/rbbt/rest/knowledge_base/render.rb
|
208
210
|
- lib/rbbt/rest/main.rb
|
209
211
|
- lib/rbbt/rest/monitor.rb
|
210
212
|
- lib/rbbt/rest/web_tool.rb
|
@@ -212,6 +214,7 @@ files:
|
|
212
214
|
- lib/rbbt/rest/workflow/jobs.rb
|
213
215
|
- lib/rbbt/rest/workflow/locate.rb
|
214
216
|
- lib/rbbt/rest/workflow/render.rb
|
217
|
+
- share/views/association/Default.haml
|
215
218
|
- share/views/compass/_rbbt.sass
|
216
219
|
- share/views/compass/actions.sass
|
217
220
|
- share/views/compass/app.sass
|
@@ -279,6 +282,8 @@ files:
|
|
279
282
|
- share/views/job_result/tsv.haml
|
280
283
|
- share/views/job_result/yaml.haml
|
281
284
|
- share/views/knowledge_base_partials/association.haml
|
285
|
+
- share/views/knowledge_base_partials/association/info.haml
|
286
|
+
- share/views/knowledge_base_partials/association/value.haml
|
282
287
|
- share/views/knowledge_base_partials/matches.haml
|
283
288
|
- share/views/knowledge_base_partials/subset.haml
|
284
289
|
- share/views/layout.haml
|