rbbt-util 5.14.38 → 5.14.39
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/etc/app.d/grid_system.rb +1 -0
- data/etc/app.d/resources.rb +3 -0
- data/lib/rbbt/association/database.rb +4 -2
- data/lib/rbbt/association/index.rb +20 -10
- data/lib/rbbt/association/open.rb +7 -4
- data/lib/rbbt/association/util.rb +12 -0
- data/lib/rbbt/knowledge_base/registry.rb +6 -5
- data/lib/rbbt/knowledge_base.rb +2 -2
- data/lib/rbbt/persist.rb +12 -8
- data/lib/rbbt/tsv/change_id.rb +10 -5
- data/lib/rbbt/tsv/manipulate.rb +3 -2
- data/lib/rbbt/tsv/matrix.rb +0 -1
- data/lib/rbbt/tsv/parallel/traverse.rb +2 -0
- data/lib/rbbt/tsv/util.rb +18 -0
- data/lib/rbbt/util/R/eval.rb +1 -1
- data/lib/rbbt/util/R/model.rb +28 -4
- data/lib/rbbt/util/R.rb +6 -0
- data/lib/rbbt/util/concurrency/processes/socket.rb +7 -1
- data/lib/rbbt/util/concurrency/processes/worker.rb +15 -7
- data/lib/rbbt/util/concurrency/processes.rb +8 -4
- data/lib/rbbt/util/log/progress/report.rb +3 -3
- data/lib/rbbt/util/log/progress.rb +20 -15
- data/lib/rbbt/util/misc/concurrent_stream.rb +2 -1
- data/lib/rbbt/util/misc/development.rb +11 -3
- data/lib/rbbt/util/misc/objects.rb +1 -1
- data/lib/rbbt/workflow/accessor.rb +19 -16
- data/lib/rbbt/workflow/step/run.rb +7 -0
- data/share/rbbt_commands/app/start +3 -2
- data/test/rbbt/knowledge_base/test_entity.rb +2 -1
- data/test/rbbt/knowledge_base/test_query.rb +2 -1
- data/test/rbbt/test_entity.rb +12 -13
- data/test/rbbt/test_knowledge_base.rb +13 -1
- data/test/rbbt/tsv/test_util.rb +15 -0
- data/test/rbbt/util/R/test_model.rb +25 -1
- data/test/rbbt/util/test_misc.rb +43 -40
- metadata +16 -2
|
@@ -51,7 +51,7 @@ module Misc
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def self.zip_fields(array)
|
|
54
|
-
return [] if array.empty? or (first = array.first).nil?
|
|
54
|
+
return [] if array.nil? or array.empty? or (first = array.first).nil?
|
|
55
55
|
max = array.collect{|l| l.length}.max
|
|
56
56
|
rest = array[1..-1].collect{|v|
|
|
57
57
|
v.length == 1 & max > 1 ? v * max : v
|
|
@@ -74,29 +74,32 @@ class Step
|
|
|
74
74
|
def info(check_lock = true)
|
|
75
75
|
return {} if info_file.nil? or not Open.exists? info_file
|
|
76
76
|
begin
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
Misc.insist do
|
|
78
|
+
begin
|
|
79
|
+
return @info_cache if @info_cache and File.ctime(info_file) < @info_cache_time
|
|
80
|
+
rescue Exception
|
|
81
|
+
raise $!
|
|
82
|
+
end
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
begin
|
|
85
|
+
@info_cache = Misc.insist(3, 1.6, info_file) do
|
|
86
|
+
Misc.insist(2, 1, info_file) do
|
|
87
|
+
Misc.insist(3, 0.2, info_file) do
|
|
88
|
+
raise TryAgain, "Info locked" if check_lock and info_lock.locked?
|
|
89
|
+
Open.open(info_file) do |file|
|
|
90
|
+
INFO_SERIALIAZER.load(file) #|| {}
|
|
91
|
+
end
|
|
90
92
|
end
|
|
91
93
|
end
|
|
92
94
|
end
|
|
95
|
+
@info_cache_time = Time.now
|
|
96
|
+
@info_cache
|
|
93
97
|
end
|
|
94
|
-
@info_cache_time = Time.now
|
|
95
|
-
@info_cache
|
|
96
98
|
end
|
|
97
99
|
rescue Exception
|
|
98
100
|
Log.debug{"Error loading info file: " + info_file}
|
|
99
101
|
Log.exception $!
|
|
102
|
+
Open.rm info_file
|
|
100
103
|
Misc.sensiblewrite(info_file, INFO_SERIALIAZER.dump({:status => :error, :messages => ["Info file lost"]}))
|
|
101
104
|
raise $!
|
|
102
105
|
end
|
|
@@ -167,7 +170,7 @@ class Step
|
|
|
167
170
|
end
|
|
168
171
|
end
|
|
169
172
|
|
|
170
|
-
def self.log_block(
|
|
173
|
+
def self.log_block(status, message, path, &block)
|
|
171
174
|
start = Time.now
|
|
172
175
|
status = status.to_s
|
|
173
176
|
status_color = self.status_color status
|
|
@@ -185,7 +188,7 @@ class Step
|
|
|
185
188
|
eend = Time.now
|
|
186
189
|
Log.info do
|
|
187
190
|
now = Time.now
|
|
188
|
-
str = "#{ Log.color :cyan, status.to_s } +#{Log.color :green, "%.
|
|
191
|
+
str = "#{ Log.color :cyan, status.to_s } +#{Log.color :green, "%.2f" % (eend - start)}"
|
|
189
192
|
str << " -- #{Log.color :blue, path.to_s}" if path
|
|
190
193
|
str << " #{Log.color :yellow, Process.pid}"
|
|
191
194
|
str
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
require 'rbbt-util'
|
|
4
4
|
require 'rbbt/util/simpleopt'
|
|
5
5
|
|
|
6
|
-
options = SOPT.get "-e--environment*:-p--port*:-s--server*:-f--finder:-R--Rserve_session*"
|
|
6
|
+
options = SOPT.get "-e--environment*:-p--port*:-s--server*:-f--finder:-R--Rserve_session*:-ho--host*"
|
|
7
7
|
options[:Port] ||= options[:port]
|
|
8
|
-
|
|
8
|
+
options[:Host] ||= "0.0.0.0"
|
|
9
|
+
options[:Bind] ||= "0.0.0.0"
|
|
9
10
|
|
|
10
11
|
app = ARGV.shift
|
|
11
12
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '../../../test_helper')
|
|
2
|
+
require 'rbbt-util'
|
|
2
3
|
require 'rbbt/util/tmpfile'
|
|
3
4
|
require 'test/unit'
|
|
4
5
|
require 'rbbt/knowledge_base'
|
|
@@ -28,7 +29,7 @@ TP53 NFKB1|GLI1 activation|activation true|true
|
|
|
28
29
|
|
|
29
30
|
EFFECT_TSV = TSV.open EFFECT, EFFECT_OPTIONS.dup
|
|
30
31
|
|
|
31
|
-
KNOWLEDGE_BASE = KnowledgeBase.new '/tmp/kb.
|
|
32
|
+
KNOWLEDGE_BASE = KnowledgeBase.new '/tmp/kb.foo3', "Hsa"
|
|
32
33
|
KNOWLEDGE_BASE.format = {"Gene" => "Associated Gene Name"}
|
|
33
34
|
|
|
34
35
|
KNOWLEDGE_BASE.register :effects, EFFECT_TSV, EFFECT_OPTIONS.dup
|
|
@@ -14,7 +14,7 @@ TP53 NFKB1|GLI1 activation|activation true|true
|
|
|
14
14
|
END
|
|
15
15
|
|
|
16
16
|
EFFECT_OPTIONS = {
|
|
17
|
-
:source => "SG=~Associated Gene Name",
|
|
17
|
+
:source => "SG=~Associated Gene Name=>Ensembl Gene ID",
|
|
18
18
|
:target => "TG=~Associated Gene Name=>Ensembl Gene ID",
|
|
19
19
|
:persist => false,
|
|
20
20
|
:identifiers => datafile_test('identifiers'),
|
|
@@ -32,6 +32,7 @@ TP53 NFKB1|GLI1 activation|activation true|true
|
|
|
32
32
|
def test_subset_all_persist
|
|
33
33
|
Misc.benchmark(1000) do
|
|
34
34
|
assert_equal 6, KNOWLEDGE_BASE.subset(:effects, :all).length
|
|
35
|
+
|
|
35
36
|
assert_equal 4, KNOWLEDGE_BASE.subset(:effects, :all).target_entity.uniq.length
|
|
36
37
|
assert_equal %w(Effect), KNOWLEDGE_BASE.subset(:effects, :all).info.first.keys
|
|
37
38
|
end
|
data/test/rbbt/test_entity.rb
CHANGED
|
@@ -53,9 +53,8 @@ module ReversableString
|
|
|
53
53
|
}
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
persist :reverse_text_ary_p, :
|
|
56
|
+
persist :reverse_text_ary_p, :marshal
|
|
57
57
|
persist :reverse_text_single_p, :memory
|
|
58
|
-
#persist :_single_reverse_text_single_p, :string
|
|
59
58
|
|
|
60
59
|
persist :reverse_text_ary_p_array, :array, :dir => TmpFile.tmp_file
|
|
61
60
|
|
|
@@ -64,7 +63,7 @@ end
|
|
|
64
63
|
|
|
65
64
|
class TestEntity < Test::Unit::TestCase
|
|
66
65
|
|
|
67
|
-
def
|
|
66
|
+
def test_property_ary
|
|
68
67
|
a = ["String1", "String2"]
|
|
69
68
|
ReversableString.setup(a)
|
|
70
69
|
|
|
@@ -84,7 +83,7 @@ class TestEntity < Test::Unit::TestCase
|
|
|
84
83
|
end
|
|
85
84
|
end
|
|
86
85
|
|
|
87
|
-
def
|
|
86
|
+
def test_property_single
|
|
88
87
|
a = ["String1", "String2"]
|
|
89
88
|
ReversableString.setup a
|
|
90
89
|
|
|
@@ -96,7 +95,7 @@ class TestEntity < Test::Unit::TestCase
|
|
|
96
95
|
assert_equal 3, $count
|
|
97
96
|
end
|
|
98
97
|
|
|
99
|
-
def
|
|
98
|
+
def test_property_ary_p
|
|
100
99
|
a = ["String1", "String2"]
|
|
101
100
|
ReversableString.setup a
|
|
102
101
|
|
|
@@ -104,7 +103,7 @@ class TestEntity < Test::Unit::TestCase
|
|
|
104
103
|
|
|
105
104
|
assert_equal "2gnirtS", a.reverse_text_ary_p.last
|
|
106
105
|
assert_equal "2gnirtS", a.collect{|e| e.reverse_text_ary_p }[1]
|
|
107
|
-
assert_equal
|
|
106
|
+
assert_equal 0, $count
|
|
108
107
|
end
|
|
109
108
|
|
|
110
109
|
def test_property_single_p
|
|
@@ -122,10 +121,10 @@ class TestEntity < Test::Unit::TestCase
|
|
|
122
121
|
assert_equal "2gnirtS", a.reverse_text_single_p.last
|
|
123
122
|
assert_equal 0, $count
|
|
124
123
|
assert_equal "2gnirtS", a[1].reverse_text_single_p
|
|
125
|
-
assert_equal
|
|
124
|
+
assert_equal 1, $count
|
|
126
125
|
end
|
|
127
126
|
|
|
128
|
-
def
|
|
127
|
+
def test_property_ary_p_array
|
|
129
128
|
a = ["String1", "String2"]
|
|
130
129
|
ReversableString.setup a
|
|
131
130
|
|
|
@@ -134,12 +133,12 @@ class TestEntity < Test::Unit::TestCase
|
|
|
134
133
|
$count = 0
|
|
135
134
|
|
|
136
135
|
assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
|
|
137
|
-
assert_equal
|
|
136
|
+
assert_equal 0, $count
|
|
138
137
|
assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
|
|
139
|
-
assert_equal
|
|
138
|
+
assert_equal 0, $count
|
|
140
139
|
end
|
|
141
140
|
|
|
142
|
-
def
|
|
141
|
+
def test_unpersist
|
|
143
142
|
a = ["String1", "String2"]
|
|
144
143
|
ReversableString.setup a
|
|
145
144
|
|
|
@@ -168,14 +167,14 @@ class TestEntity < Test::Unit::TestCase
|
|
|
168
167
|
|
|
169
168
|
end
|
|
170
169
|
|
|
171
|
-
def
|
|
170
|
+
def test_persist_annotations
|
|
172
171
|
string = 'aaabbbccc'
|
|
173
172
|
ReversableString.setup(string)
|
|
174
173
|
assert_equal string.length, string.annotation_list.length
|
|
175
174
|
assert_equal string.length, string.annotation_list.length
|
|
176
175
|
end
|
|
177
176
|
|
|
178
|
-
def
|
|
177
|
+
def test_clean_annotations
|
|
179
178
|
|
|
180
179
|
string = "test_string"
|
|
181
180
|
ReversableString.setup string
|
|
@@ -56,6 +56,18 @@ end
|
|
|
56
56
|
|
|
57
57
|
class TestKnowledgeBase < Test::Unit::TestCase
|
|
58
58
|
|
|
59
|
+
def test_knowledge_base_reverse
|
|
60
|
+
organism = Organism.default_code("Hsa")
|
|
61
|
+
TmpFile.with_file do |tmpdir|
|
|
62
|
+
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
|
63
|
+
kb.format = {"Gene" => "Ensembl Gene ID"}
|
|
64
|
+
|
|
65
|
+
kb.register :tfacts, TFacts.regulators, :source =>"=~Associated Gene Name"
|
|
66
|
+
|
|
67
|
+
kb.get_index(:tfacts).reverse
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
59
71
|
def test_knowledge_base
|
|
60
72
|
organism = Organism.default_code("Hsa")
|
|
61
73
|
TmpFile.with_file do |tmpdir|
|
|
@@ -69,7 +81,7 @@ class TestKnowledgeBase < Test::Unit::TestCase
|
|
|
69
81
|
kb.register :kegg, KEGG.gene_pathway, :source_format => "Ensembl Gene ID"
|
|
70
82
|
assert_match "Ensembl Gene ID", kb.get_database(:kegg).key_field
|
|
71
83
|
|
|
72
|
-
gene = Gene.setup("TP53", "Associated Gene Name", organism)
|
|
84
|
+
gene = Gene.setup("TP53", "Associated Gene Name", organism).ensembl
|
|
73
85
|
assert_equal "TP53", gene.name
|
|
74
86
|
assert_equal "ENSG00000141510", gene.ensembl
|
|
75
87
|
|
data/test/rbbt/tsv/test_util.rb
CHANGED
|
@@ -36,4 +36,19 @@ row2 A B Id3
|
|
|
36
36
|
assert_equal({1 => 1}, Marshal.load(Marshal.dump({1 => 1})))
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
|
+
|
|
40
|
+
def test_replicates
|
|
41
|
+
content =<<-EOF
|
|
42
|
+
#Id ValueA ValueB OtherID
|
|
43
|
+
row1 a|aa|aaa b|bb|bbb Id1|Id2|Id3
|
|
44
|
+
row2 A B Id3
|
|
45
|
+
EOF
|
|
46
|
+
|
|
47
|
+
TmpFile.with_file(content) do |filename|
|
|
48
|
+
tsv = TSV.open(filename, :sep => /\s+/)
|
|
49
|
+
|
|
50
|
+
assert_equal 4, tsv.unzip_replicates.length
|
|
51
|
+
assert_equal %w(aa bb Id2), tsv.unzip_replicates["row1(1)"]
|
|
52
|
+
end
|
|
53
|
+
end
|
|
39
54
|
end
|
|
@@ -75,7 +75,7 @@ data = rbbt.model.inpute(data, CI ~ Dose, method=drm, classes='numeric', fct=LL.
|
|
|
75
75
|
rppa = rppa.slice([antibody,"Compound", "Dose"])
|
|
76
76
|
rppa.rename_field antibody, "RPPA"
|
|
77
77
|
|
|
78
|
-
model = R::Model.new "viability", "Effect ~ Dose", "Compound" => :factor
|
|
78
|
+
model = R::Model.new "viability", "Effect ~ Dose", nil, "Compound" => :factor
|
|
79
79
|
|
|
80
80
|
model.fit(viability.select("Compound"){|c| ! c.include? "-"}, 'lm')
|
|
81
81
|
|
|
@@ -85,4 +85,28 @@ data = rbbt.model.inpute(data, CI ~ Dose, method=drm, classes='numeric', fct=LL.
|
|
|
85
85
|
|
|
86
86
|
R::SVG.ggplotSVG rppa, plot_script, 7, 7, :R_method => :eval
|
|
87
87
|
end
|
|
88
|
+
|
|
89
|
+
def test_fit_fast
|
|
90
|
+
data = TSV.setup({}, :key_field => "Dose", :fields => ["Response"], :type => :single)
|
|
91
|
+
10.times do
|
|
92
|
+
x = rand(10)
|
|
93
|
+
y = 10 + 3 * x + rand * 4
|
|
94
|
+
data[x] = y
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
model = R::Model.new "Test fit 2", "Response ~ Dose", data, :fit => 'lm'
|
|
98
|
+
|
|
99
|
+
x = 5
|
|
100
|
+
y = 10 + 3 * x
|
|
101
|
+
|
|
102
|
+
pred = model.predict x
|
|
103
|
+
assert pred > y and pred < y + 4
|
|
104
|
+
|
|
105
|
+
pred = model.predict [x, 2*x, 3*x]
|
|
106
|
+
assert pred.first > y and pred.first < y + 4
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
pred = model.predict "Dose" => x
|
|
110
|
+
assert pred > y and pred < y + 4
|
|
111
|
+
end
|
|
88
112
|
end
|
data/test/rbbt/util/test_misc.rb
CHANGED
|
@@ -6,7 +6,7 @@ require 'rbbt/entity'
|
|
|
6
6
|
|
|
7
7
|
class TestMisc < Test::Unit::TestCase
|
|
8
8
|
|
|
9
|
-
def
|
|
9
|
+
def _test_object_delta
|
|
10
10
|
a = []
|
|
11
11
|
b = nil
|
|
12
12
|
d = Misc.object_delta(String) do
|
|
@@ -16,13 +16,13 @@ class TestMisc < Test::Unit::TestCase
|
|
|
16
16
|
assert_match /^0\.\d+$/, a.first
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def
|
|
19
|
+
def _test_format_seconds
|
|
20
20
|
t = 61.3232
|
|
21
21
|
assert_equal "00:01:01", Misc.format_seconds(t)
|
|
22
22
|
assert_equal "00:01:01.32", Misc.format_seconds(t, true)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def
|
|
25
|
+
def _test_format_paragraph
|
|
26
26
|
p = <<-EOF
|
|
27
27
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
|
|
28
28
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
|
@@ -42,7 +42,7 @@ in culpa qui officia deserunt mollit anim id est laborum.
|
|
|
42
42
|
assert Misc.format_paragraph(p, 70, 10, 5) =~ /\n\s*\* two/sm
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def
|
|
45
|
+
def _test_format_dl
|
|
46
46
|
p1 = <<-EOF
|
|
47
47
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
|
|
48
48
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
|
@@ -72,13 +72,13 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
72
72
|
assert Misc.format_definition_list({:paragraph_first => p1, :paragraph_second => p2}) =~ / /
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
def
|
|
75
|
+
def _test_parse_cmd_params
|
|
76
76
|
assert_equal ["workflow", "task", "Translation", "translate", "-f", "Associated Gene Name", "-l", "-"],
|
|
77
77
|
Misc.parse_cmd_params("workflow task Translation translate -f 'Associated Gene Name' -l -")
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
def
|
|
81
|
+
def _test_fixutf8
|
|
82
82
|
string = "abc\xffdef"
|
|
83
83
|
string = string.force_encoding("UTF-8") if string.respond_to? :force_encoding
|
|
84
84
|
assert(! string.valid_encoding?) if string.respond_to? :valid_encoding?
|
|
@@ -87,37 +87,37 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
87
87
|
assert( Misc.fixutf8(string).valid_encoding) if string.respond_to? :valid_encoding
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
def
|
|
90
|
+
def _test_colors_for
|
|
91
91
|
colors, used = Misc.colors_for([1,2,2,1,2,1,2,2,3,3,2,3,2])
|
|
92
92
|
assert_equal Misc::COLOR_LIST[1], used[2]
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
def
|
|
95
|
+
def _test_total_length
|
|
96
96
|
ranges = [(0..100), (50..150), (120..160)]
|
|
97
97
|
ranges = [(0..100), (50..150), (120..160), (51..70)]
|
|
98
98
|
assert_equal 161, Misc.total_length(ranges)
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
def
|
|
101
|
+
def _test_id_filename?
|
|
102
102
|
TmpFile.with_file("") do |file|
|
|
103
103
|
assert Misc.is_filename?(file)
|
|
104
104
|
assert ! Misc.is_filename?("TEST STRING")
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
def
|
|
108
|
+
def _test_merge_sorted_arrays
|
|
109
109
|
assert_equal [1,2,3,4], Misc.merge_sorted_arrays([1,3], [2,4])
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
def
|
|
112
|
+
def _test_intersect_sorted_arrays
|
|
113
113
|
assert_equal [2,4], Misc.intersect_sorted_arrays([1,2,3,4], [2,4])
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
-
def
|
|
116
|
+
def _test_sorted_array_matches
|
|
117
117
|
assert_equal [1,3], Misc.sorted_array_hits(%w(a b c d e), %w(b d))
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
-
def
|
|
120
|
+
def _test_binary_include?
|
|
121
121
|
a = %w(a b c d e).sort
|
|
122
122
|
assert Misc.binary_include?(a, "a")
|
|
123
123
|
assert(!Misc.binary_include?(a, "z"))
|
|
@@ -126,12 +126,12 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
126
126
|
assert(Misc.binary_include?(a, "d"))
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
def
|
|
129
|
+
def _test_process_to_hash
|
|
130
130
|
list = [1,2,3,4]
|
|
131
131
|
assert_equal 4, Misc.process_to_hash(list){|l| l.collect{|e| e * 2}}[2]
|
|
132
132
|
end
|
|
133
133
|
|
|
134
|
-
def
|
|
134
|
+
def _test_pipe_fork
|
|
135
135
|
sout, sin = Misc.pipe
|
|
136
136
|
pid = Process.fork do
|
|
137
137
|
Misc.purge_pipes(sin)
|
|
@@ -143,7 +143,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
143
143
|
Process.kill :INT, pid
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
-
def
|
|
146
|
+
def _test_open_pipe
|
|
147
147
|
t = 5
|
|
148
148
|
stream = Misc.open_pipe do |sin|
|
|
149
149
|
t.times do |i|
|
|
@@ -164,7 +164,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
164
164
|
assert_equal (0..t-1).to_a.collect{|i| "LINE #{ i }"}, lines
|
|
165
165
|
end
|
|
166
166
|
|
|
167
|
-
def
|
|
167
|
+
def _test_open_pipe_fork
|
|
168
168
|
t = 5
|
|
169
169
|
stream = Misc.open_pipe(true) do |sin|
|
|
170
170
|
t.times do |i|
|
|
@@ -185,7 +185,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
185
185
|
assert_equal (0..t-1).to_a.collect{|i| "LINE #{ i }"}, lines
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
def
|
|
188
|
+
def _test_open_pipe_fork_cascade
|
|
189
189
|
t = 500
|
|
190
190
|
sleep_time = 2.0 / t
|
|
191
191
|
time = Time.now
|
|
@@ -221,7 +221,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
221
221
|
assert_equal (0..t-1).to_a.collect{|i| "LINE #{ i }".reverse.downcase}, lines
|
|
222
222
|
end
|
|
223
223
|
|
|
224
|
-
def
|
|
224
|
+
def _test_tee_stream
|
|
225
225
|
t = 500
|
|
226
226
|
sleep_time = 2.0 / t
|
|
227
227
|
time = Time.now
|
|
@@ -271,7 +271,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
271
271
|
end
|
|
272
272
|
|
|
273
273
|
|
|
274
|
-
def
|
|
274
|
+
def _test_string2hash
|
|
275
275
|
assert(Misc.string2hash("--user-agent=firefox").include? "--user-agent")
|
|
276
276
|
assert_equal(true, Misc.string2hash(":true")[:true])
|
|
277
277
|
assert_equal(true, Misc.string2hash("true")["true"])
|
|
@@ -282,16 +282,16 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
282
282
|
assert_equal(:j, Misc.string2hash("a=b#c=d#:h=:j")[:h])
|
|
283
283
|
end
|
|
284
284
|
|
|
285
|
-
def
|
|
285
|
+
def _test_named_array
|
|
286
286
|
a = NamedArray.setup([1,2,3,4], %w(a b c d))
|
|
287
287
|
assert_equal(1, a['a'])
|
|
288
288
|
end
|
|
289
289
|
|
|
290
|
-
def
|
|
290
|
+
def _test_path_relative_to
|
|
291
291
|
assert_equal "test/foo", Misc.path_relative_to('/test', '/test/test/foo')
|
|
292
292
|
end
|
|
293
293
|
|
|
294
|
-
def
|
|
294
|
+
def _test_hash2string
|
|
295
295
|
hash = {}
|
|
296
296
|
assert_equal hash, Misc.string2hash(Misc.hash2string(hash))
|
|
297
297
|
|
|
@@ -309,14 +309,14 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
309
309
|
|
|
310
310
|
end
|
|
311
311
|
|
|
312
|
-
def
|
|
312
|
+
def _test_merge
|
|
313
313
|
a = [[1],[2]]
|
|
314
314
|
a = NamedArray.setup a, %w(1 2)
|
|
315
315
|
a.merge [3,4]
|
|
316
316
|
assert_equal [1,3], a[0]
|
|
317
317
|
end
|
|
318
318
|
|
|
319
|
-
def
|
|
319
|
+
def _test_indiferent_hash
|
|
320
320
|
a = {:a => 1, "b" => 2}
|
|
321
321
|
a.extend IndiferentHash
|
|
322
322
|
|
|
@@ -326,7 +326,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
326
326
|
assert_equal 2, a[:b]
|
|
327
327
|
end
|
|
328
328
|
|
|
329
|
-
def
|
|
329
|
+
def _test_lockfile
|
|
330
330
|
|
|
331
331
|
TmpFile.with_file do |tmpfile|
|
|
332
332
|
pids = []
|
|
@@ -350,7 +350,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
350
350
|
end
|
|
351
351
|
end
|
|
352
352
|
|
|
353
|
-
def
|
|
353
|
+
def _test_positions2hash
|
|
354
354
|
inputs = Misc.positional2hash([:one, :two, :three], 1, :two => 2, :four => 4)
|
|
355
355
|
assert_equal 1, inputs[:one]
|
|
356
356
|
assert_equal 2, inputs[:two]
|
|
@@ -358,44 +358,44 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
358
358
|
assert_equal nil, inputs[:four]
|
|
359
359
|
end
|
|
360
360
|
|
|
361
|
-
def
|
|
361
|
+
def _test_mean
|
|
362
362
|
assert_equal 2, Misc.mean([1,2,3])
|
|
363
363
|
assert_equal 3, Misc.mean([1,2,3,4,5])
|
|
364
364
|
end
|
|
365
365
|
|
|
366
|
-
def
|
|
366
|
+
def _test_zip_fields
|
|
367
367
|
current = [[:a,1], [:b,2]]
|
|
368
368
|
assert_equal [[:a, :b],[1,2]], Misc.zip_fields(current)
|
|
369
369
|
assert_equal current, Misc.zip_fields(Misc.zip_fields(current))
|
|
370
370
|
end
|
|
371
371
|
|
|
372
|
-
def
|
|
372
|
+
def _test_zip_fields_comp
|
|
373
373
|
current = [[:a,1], [:b,2], [:c]]
|
|
374
374
|
assert_equal [[:a, :b, :c],[1,2,nil]], Misc.zip_fields(current)
|
|
375
375
|
assert_equal current, Misc.zip_fields(Misc.zip_fields(current)).collect{|v| v.compact }
|
|
376
376
|
end
|
|
377
377
|
|
|
378
|
-
def
|
|
378
|
+
def _test_add_zipped
|
|
379
379
|
current = [[:a,1], [:b,2]]
|
|
380
380
|
new = %w(A B)
|
|
381
381
|
Misc.append_zipped current, new
|
|
382
382
|
assert_equal [[:a,1,"A"], [:b,2,"B"]], current
|
|
383
383
|
end
|
|
384
384
|
|
|
385
|
-
def
|
|
385
|
+
def _test_divide
|
|
386
386
|
assert_equal 2, Misc.divide(%w(1 2 3 4 5 6 7 8 9),2).length
|
|
387
387
|
end
|
|
388
388
|
|
|
389
|
-
def
|
|
389
|
+
def _test_ordered_divide
|
|
390
390
|
assert_equal 5, Misc.ordered_divide(%w(1 2 3 4 5 6 7 8 9),2).length
|
|
391
391
|
end
|
|
392
392
|
|
|
393
|
-
def
|
|
393
|
+
def _test_collapse_ranges
|
|
394
394
|
ranges = [(0..100), (50..150), (51..61),(200..250), (300..324),(320..350)]
|
|
395
395
|
assert_equal [(0..150),(200..250), (300..350)], Misc.collapse_ranges(ranges)
|
|
396
396
|
end
|
|
397
397
|
|
|
398
|
-
def
|
|
398
|
+
def _test_humanize
|
|
399
399
|
str1 = "test_string"
|
|
400
400
|
str2 = "TEST_string"
|
|
401
401
|
str3 = "test"
|
|
@@ -407,22 +407,22 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
407
407
|
assert_equal "mutation_enrichment", Misc.snake_case("MutationEnrichment")
|
|
408
408
|
end
|
|
409
409
|
|
|
410
|
-
def
|
|
410
|
+
def _test_snake_case
|
|
411
411
|
str1 = "ACRONIMTest"
|
|
412
412
|
str2 = "ACRONIM_test"
|
|
413
413
|
assert_equal "ACRONIM_test", Misc.snake_case(str1)
|
|
414
414
|
assert_equal "ACRONIM_test", Misc.snake_case(str2)
|
|
415
415
|
end
|
|
416
416
|
|
|
417
|
-
def
|
|
417
|
+
def _test_correct_vcf_mutations
|
|
418
418
|
assert_equal [737407, ["-----", "-----G", "-----GTTAAT"]], Misc.correct_vcf_mutation(737406, "GTTAAT", "G,GG,GGTTAAT")
|
|
419
419
|
end
|
|
420
420
|
|
|
421
|
-
def
|
|
421
|
+
def _test_fingerprint
|
|
422
422
|
assert_equal '{a=>1}', Misc.fingerprint({:a => 1})
|
|
423
423
|
end
|
|
424
424
|
|
|
425
|
-
def
|
|
425
|
+
def _test_tarize
|
|
426
426
|
path = File.expand_path('/home/mvazquezg/git/rbbt-util/lib')
|
|
427
427
|
stream = Misc.tarize(path)
|
|
428
428
|
TmpFile.with_file do |res|
|
|
@@ -432,7 +432,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
432
432
|
end
|
|
433
433
|
end
|
|
434
434
|
|
|
435
|
-
def
|
|
435
|
+
def _test_camel_case
|
|
436
436
|
assert_equal "DbSNP", Misc.camel_case("db_SNP")
|
|
437
437
|
assert_equal "D3Js", Misc.camel_case("D3Js")
|
|
438
438
|
assert_equal "Structure", Misc.camel_case("Structure")
|
|
@@ -440,6 +440,9 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
|
440
440
|
assert_equal "COSMIC", Misc.camel_case("COSMIC")
|
|
441
441
|
end
|
|
442
442
|
|
|
443
|
+
def test_texar
|
|
444
|
+
ppp Misc.html_tag('textarea', "hola\nadios\nagain")
|
|
445
|
+
end
|
|
443
446
|
|
|
444
447
|
def __test_lock_fd
|
|
445
448
|
require 'rbbt/workflow'
|
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.39
|
|
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-
|
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: sass-css-importer
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
111
125
|
description: Utilities for handling tsv files, caches, etc
|
|
112
126
|
email: miguel.vazquez@cnio.es
|
|
113
127
|
executables:
|