rbbt-util 5.14.14 → 5.14.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/etc/app.d/base.rb +2 -2
- data/etc/app.d/entities.rb +4 -4
- data/lib/rbbt/association/index.rb +10 -5
- data/lib/rbbt/association/item.rb +12 -0
- data/lib/rbbt/knowledge_base.rb +4 -2
- data/lib/rbbt/persist.rb +1 -1
- data/lib/rbbt/resource.rb +1 -0
- data/lib/rbbt/resource/path.rb +18 -6
- data/lib/rbbt/resource/util.rb +1 -0
- data/lib/rbbt/util/misc/development.rb +26 -0
- data/lib/rbbt/util/misc/indiferent_hash.rb +5 -0
- data/lib/rbbt/util/named_array.rb +5 -0
- data/lib/rbbt/util/semaphore.rb +9 -23
- data/share/rbbt_commands/app/start +2 -1
- data/share/rbbt_commands/tsv/info +3 -1
- 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: b4562833949296544e288b767589677cdea4cd54
|
4
|
+
data.tar.gz: 50c2d8f06c365b3334ab046671031b4dadff448f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 247c31f35e49849089188684402ae360d88800e4d90cdbe897c36a7d666f00360c10e308a2a5626411f7d917595930efa4213c2af20050e7b8ab235fc4b5f349
|
7
|
+
data.tar.gz: 31d136e11cc112d958568a7607fc673876822f8c350ffd326c9b66b58ca55dc6e48659ee1f80ff660527188eb30ba63d0ddfa703c3cef285c865ae8fbf5ff824
|
data/etc/app.d/base.rb
CHANGED
@@ -19,11 +19,11 @@ helpers Sinatra::RbbtMiscHelpers
|
|
19
19
|
use Rack::Session::Cookie, :key => 'rack.session',
|
20
20
|
:path => '/',
|
21
21
|
:expire_after => 2592000,
|
22
|
-
:secret =>
|
22
|
+
:secret => "#{self.to_s} secret!!"
|
23
23
|
|
24
24
|
|
25
25
|
#{{{ DIRECTORIES
|
26
|
-
local_var = Rbbt.var
|
26
|
+
local_var = Rbbt.var#.find(:current)
|
27
27
|
set :cache_dir , local_var.sinatra.cache.find
|
28
28
|
set :persist_dir , local_var.sinatra.cache.persistence.find
|
29
29
|
set :persist_options , {:persist => true, :persist_dir => :persist_dir}
|
data/etc/app.d/entities.rb
CHANGED
@@ -5,9 +5,9 @@ Rbbt.etc.requires.read.split("\n").each do |file|
|
|
5
5
|
end if Rbbt.etc.requires.exists?
|
6
6
|
|
7
7
|
|
8
|
-
Entity.entity_list_cache = Rbbt.var.find.
|
9
|
-
Entity.entity_map_cache = Rbbt.var.find.
|
10
|
-
Entity.entity_property_cache = Rbbt.var.find.
|
8
|
+
Entity.entity_list_cache = Rbbt.var.sinatra.find.entity_lists
|
9
|
+
Entity.entity_map_cache = Rbbt.var.sinatra.find.entity_maps
|
10
|
+
Entity.entity_property_cache = Rbbt.var.sinatra.find.entity_properties
|
11
11
|
|
12
12
|
Rbbt.etc.entities.read.split("\n").each do |name|
|
13
13
|
next if name.empty?
|
@@ -18,7 +18,7 @@ Rbbt.etc.entities.read.split("\n").each do |name|
|
|
18
18
|
end
|
19
19
|
end if Rbbt.etc.entities.exists?
|
20
20
|
|
21
|
-
$annotation_repo = Rbbt.var.
|
21
|
+
$annotation_repo = Rbbt.var.sinatra.annotation_repo.find
|
22
22
|
(Rbbt.etc.persist_properties.yaml || {}).each do |name,list|
|
23
23
|
next if name.empty?
|
24
24
|
mod = Kernel.const_get name
|
@@ -77,13 +77,18 @@ module Association
|
|
77
77
|
return [] if source.nil? or target.nil?
|
78
78
|
|
79
79
|
if source == :all or source == "all"
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
if target == :all or target == "all"
|
81
|
+
return keys
|
82
|
+
else
|
83
|
+
matches = reverse.subset(target, source)
|
84
|
+
return matches.collect{|m| r = m.partition "~"; r.reverse*"" }
|
85
|
+
end
|
85
86
|
end
|
86
87
|
|
88
|
+
matches = source.uniq.inject([]){|acc,e|
|
89
|
+
acc.concat(match(e))
|
90
|
+
}
|
91
|
+
|
87
92
|
return matches if target == :all or target == "all"
|
88
93
|
|
89
94
|
target_matches = {}
|
@@ -23,6 +23,14 @@ module AssociationItem
|
|
23
23
|
self.clean_annotations.collect{|p| p[/[^~]+/] }
|
24
24
|
end
|
25
25
|
|
26
|
+
property :target_entity_type => :both do
|
27
|
+
Entity.formats[target_type].to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
property :source_entity_type => :both do
|
31
|
+
Entity.formats[source_type].to_s
|
32
|
+
end
|
33
|
+
|
26
34
|
property :target_type => :both do
|
27
35
|
type = reverse ? knowledge_base.source(database) : knowledge_base.target(database)
|
28
36
|
end
|
@@ -69,6 +77,10 @@ module AssociationItem
|
|
69
77
|
self.each do |match|
|
70
78
|
tsv[match] = [match.source, match.target].concat match.info.values_at(*info_fields)
|
71
79
|
end
|
80
|
+
tsv.entity_options = {:organism => namespace}
|
81
|
+
knowledge_base.entity_options.each do |type,options|
|
82
|
+
tsv.entity_options.merge! options
|
83
|
+
end
|
72
84
|
tsv
|
73
85
|
end
|
74
86
|
|
data/lib/rbbt/knowledge_base.rb
CHANGED
@@ -194,7 +194,8 @@ class KnowledgeBase
|
|
194
194
|
end
|
195
195
|
|
196
196
|
def annotate(entities, type, database = nil)
|
197
|
-
|
197
|
+
format = @format[type] || type
|
198
|
+
Misc.prepare_entity(entities, format, entity_options_for(type, database))
|
198
199
|
end
|
199
200
|
|
200
201
|
#{{{ Identify
|
@@ -304,7 +305,8 @@ class KnowledgeBase
|
|
304
305
|
repo = get_index name
|
305
306
|
|
306
307
|
begin
|
307
|
-
|
308
|
+
s = repo.subset_entities(entities)
|
309
|
+
setup(name, s)
|
308
310
|
rescue Exception
|
309
311
|
target = entities[:target]
|
310
312
|
source = entities[:source]
|
data/lib/rbbt/persist.rb
CHANGED
data/lib/rbbt/resource.rb
CHANGED
data/lib/rbbt/resource/path.rb
CHANGED
@@ -39,9 +39,13 @@ module Path
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def glob(pattern = '*')
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
if self.include? "*"
|
43
|
+
Dir.glob(self).collect{|f| Path.setup(f, self.resource, self.pkgdir)}
|
44
|
+
else
|
45
|
+
return [] unless self.exists?
|
46
|
+
exp = File.join(self.find, pattern)
|
47
|
+
Dir.glob(exp).collect{|f| Path.setup(f, self.resource, self.pkgdir)}
|
48
|
+
end
|
45
49
|
end
|
46
50
|
|
47
51
|
def [](name, orig = false)
|
@@ -67,14 +71,16 @@ module Path
|
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
70
|
-
SEARCH_PATHS = {
|
74
|
+
SEARCH_PATHS = IndiferentHash.setup({
|
71
75
|
:current => File.join("{PWD}", "{TOPLEVEL}", "{SUBPATH}"),
|
72
76
|
:user => File.join(ENV['HOME'], ".{PKGDIR}", "{TOPLEVEL}", "{SUBPATH}"),
|
73
77
|
:global => File.join('/', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
|
74
78
|
:local => File.join('/usr/local', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
|
75
79
|
:lib => File.join('{LIBDIR}', "{TOPLEVEL}", "{SUBPATH}"),
|
76
80
|
:default => :user
|
77
|
-
}
|
81
|
+
})
|
82
|
+
|
83
|
+
STANDARD_SEARCH = %w(current user local global lib cache bulk)
|
78
84
|
|
79
85
|
search_path_file = File.join(ENV['HOME'], '.rbbt/etc/search_paths')
|
80
86
|
if File.exists?(search_path_file)
|
@@ -95,7 +101,13 @@ module Path
|
|
95
101
|
|
96
102
|
path = nil
|
97
103
|
if where.nil?
|
98
|
-
|
104
|
+
STANDARD_SEARCH.each do |w|
|
105
|
+
w = w.to_sym
|
106
|
+
next unless paths.include? w
|
107
|
+
path = find(w, caller_lib, paths)
|
108
|
+
return path if File.exists? path
|
109
|
+
end
|
110
|
+
(SEARCH_PATHS.keys - STANDARD_SEARCH).each do |w|
|
99
111
|
w = w.to_sym
|
100
112
|
next unless paths.include? w
|
101
113
|
path = find(w, caller_lib, paths)
|
data/lib/rbbt/resource/util.rb
CHANGED
@@ -259,4 +259,30 @@ module Misc
|
|
259
259
|
Log.info "Delta: #{delta.inspect}"
|
260
260
|
res
|
261
261
|
end
|
262
|
+
|
263
|
+
def self.time_tick
|
264
|
+
if $_last_time_tick.nil?
|
265
|
+
$_last_time_tick = Time.now
|
266
|
+
puts "Tick started: #{Time.now}"
|
267
|
+
else
|
268
|
+
ellapsed = Time.now - $_last_time_tick
|
269
|
+
puts "Tick ellapsed: #{ellapsed.to_i} s. #{(ellapsed * 1000).to_i - ellapsed.to_i * 1000} ms"
|
270
|
+
$_last_time_tick = Time.now
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def self.bootstrap(elems, num = :current, file = nil, &block)
|
275
|
+
cpus = case num
|
276
|
+
when :current
|
277
|
+
4
|
278
|
+
when Integer
|
279
|
+
if num < 100
|
280
|
+
num
|
281
|
+
else
|
282
|
+
32000 / num
|
283
|
+
end
|
284
|
+
end
|
285
|
+
file = caller.first + rand(1000000).to_s if file.nil?
|
286
|
+
RbbtSemaphore.fork_each_on_semaphore elems, cpus, file, &block
|
287
|
+
end
|
262
288
|
end
|
data/lib/rbbt/util/semaphore.rb
CHANGED
@@ -79,34 +79,20 @@ void post_semaphore(char* name){
|
|
79
79
|
|
80
80
|
def self.fork_each_on_semaphore(elems, size, file = nil)
|
81
81
|
with_semaphore(size, file) do |file|
|
82
|
-
begin
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
90
|
-
rescue Interrupt
|
91
|
-
Log.warn "Process #{Process.pid} was aborted"
|
92
|
-
end
|
83
|
+
TSV.traverse elems, :cpus => size*2, :bar => "Fork each on semaphore: #{ file }" do |elem|
|
84
|
+
elems.annotate elem if elems.respond_to? :annotate
|
85
|
+
begin
|
86
|
+
RbbtSemaphore.synchronize(file) do
|
87
|
+
yield elem
|
93
88
|
end
|
89
|
+
rescue Interrupt
|
90
|
+
Log.warn "Process #{Process.pid} was aborted"
|
94
91
|
end
|
95
|
-
|
96
|
-
while pids.any?
|
97
|
-
pid = Process.wait -1
|
98
|
-
pids.delete pid
|
99
|
-
end
|
100
|
-
#pids.each do |pid| Process.waitpid pid end
|
101
|
-
|
102
|
-
rescue Exception
|
103
|
-
Log.warn "Killing children: #{pids.sort * ", " }"
|
104
|
-
pids.each do |pid| begin Process.kill("INT", pid); rescue; end; end
|
105
|
-
pids.each do |pid| begin RbbtSemaphore.post_semaphore(file); rescue; end; end
|
106
|
-
Log.warn "Ensuring children are dead: #{pids.sort * ", " }"
|
107
|
-
pids.each do |pid| begin Process.waitpid pid; rescue; end; end
|
108
92
|
end
|
93
|
+
|
109
94
|
end
|
95
|
+
true
|
110
96
|
end
|
111
97
|
|
112
98
|
def self.thread_each_on_semaphore(elems, size)
|
@@ -23,6 +23,7 @@ Misc.in_dir(app_dir) do
|
|
23
23
|
if server == 'unicorn'
|
24
24
|
`unicorn -c #{ Rbbt.share['unicorn.rb'].find } '#{config_ru_file}' -p #{options[:port] || "2887"}`
|
25
25
|
else
|
26
|
-
|
26
|
+
options[:config] = config_ru_file
|
27
|
+
Rack::Server.start(options)
|
27
28
|
end
|
28
29
|
end
|
@@ -30,7 +30,9 @@ file = STDIN if file == '-'
|
|
30
30
|
|
31
31
|
raise ParameterException, "Please specify the tsv file as argument" if file.nil?
|
32
32
|
|
33
|
-
|
33
|
+
iii options
|
34
|
+
options[:fields] = options[:fields].split(/[,\|]/) if options[:fields]
|
35
|
+
iii options
|
34
36
|
options[:header_hash] = options["header_hash"]
|
35
37
|
options[:sep] = options["sep"]
|
36
38
|
|
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.15
|
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-08-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|