rbbt-util 5.13.26 → 5.13.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/monitor.rb +6 -1
- data/lib/rbbt/tsv/parallel/traverse.rb +2 -0
- data/lib/rbbt/util/concurrency/processes.rb +3 -3
- data/lib/rbbt/util/log/progress/report.rb +1 -1
- data/lib/rbbt/util/misc/concurrent_stream.rb +1 -1
- data/lib/rbbt/util/misc/format.rb +7 -0
- data/lib/rbbt/util/misc/lock.rb +8 -3
- data/share/rbbt_commands/system/clean +9 -9
- data/share/rbbt_commands/system/status +19 -14
- data/test/rbbt/util/misc/test_lock.rb +31 -0
- data/test/rbbt/util/test_misc.rb +43 -37
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5b4e97dff70829b6c281c60b2ab9ef251448997
|
4
|
+
data.tar.gz: 7ed1a51ccbaad554e8240cdfc155eefcd0113637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f91cf30ebefac18ff92fd44950744d83e083a50a85e4451104f7b664bee9a1863ed8c43c95d9f0a9863e4b2ff61e92f5eb963816eff2ae25be0b6cc3f8fa7752
|
7
|
+
data.tar.gz: 08e361e740c52d30de3711cc142b87ebd2692e357edd3fccca917b2973b7d25dbb16a4a3d5a4db2f02180bd028b413499a775d89f27fc69069366c0a663230b0
|
data/lib/rbbt/monitor.rb
CHANGED
@@ -102,7 +102,7 @@ class RbbtProcessQueue
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def clean
|
105
|
-
if @process_monitor.alive? or @callback_thread.alive?
|
105
|
+
if (@process_monitor and @process_monitor.alive?) or (@callback_thread and @callback_thread.alive?)
|
106
106
|
self.abort
|
107
107
|
else
|
108
108
|
self.join
|
@@ -111,8 +111,8 @@ class RbbtProcessQueue
|
|
111
111
|
|
112
112
|
def abort
|
113
113
|
begin
|
114
|
-
@process_monitor.raise(Aborted.new); @process_monitor.join if @process_monitor and @process_monitor.alive?
|
115
|
-
@callback_thread.raise(Aborted.new); @callback_thread.join if @callback_thread and @callback_thread.alive?
|
114
|
+
(@process_monitor.raise(Aborted.new); @process_monitor.join) if @process_monitor and @process_monitor.alive?
|
115
|
+
(@callback_thread.raise(Aborted.new); @callback_thread.join) if @callback_thread and @callback_thread.alive?
|
116
116
|
ensure
|
117
117
|
join
|
118
118
|
end
|
@@ -70,7 +70,7 @@ module Log
|
|
70
70
|
eta = (@max - @ticks) / (@ticks/used)
|
71
71
|
end
|
72
72
|
|
73
|
-
used =
|
73
|
+
used = Misc.format_seconds(used)
|
74
74
|
eta = [eta/3600, eta/60 % 60, eta % 60].map{|t| "%02i" % t }.join(':')
|
75
75
|
|
76
76
|
indicator << " #{Log.color :yellow, used} used #{Log.color :yellow, eta} left"
|
@@ -18,6 +18,13 @@ module Misc
|
|
18
18
|
[colors, used]
|
19
19
|
end
|
20
20
|
|
21
|
+
def self.format_seconds(time, extended = false)
|
22
|
+
seconds = time.to_i
|
23
|
+
str = [seconds/3600, seconds/60 % 60, seconds % 60].map{|t| "%02i" % t }.join(':')
|
24
|
+
str << ".%02i" % ((time - seconds) * 100) if extended
|
25
|
+
str
|
26
|
+
end
|
27
|
+
|
21
28
|
def self.format_paragraph(text, size = 80, indent = 0, offset = 0)
|
22
29
|
i = 0
|
23
30
|
re = /((?:\n\s*\n\s*)|(?:\n\s*(?=\*)))/
|
data/lib/rbbt/util/misc/lock.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
|
2
|
-
Lockfile.
|
3
|
-
Lockfile.
|
1
|
+
if ENV["RBBT_NO_LOCKFILE_REFRESH"] == "true"
|
2
|
+
Lockfile.refresh = false
|
3
|
+
Lockfile.max_age = 60 * 60 * 5
|
4
|
+
else
|
5
|
+
Lockfile.refresh = 3
|
6
|
+
Lockfile.max_age = 10
|
7
|
+
Lockfile.suspend = 3
|
8
|
+
end
|
4
9
|
|
5
10
|
module Misc
|
6
11
|
|
@@ -29,7 +29,7 @@ if locks.any?
|
|
29
29
|
pid, ppid, time = Rbbt.load_lock(lock)
|
30
30
|
if not Misc.pid_exists? pid
|
31
31
|
puts " Removing #{ lock }"
|
32
|
-
FileUtils.rm lock
|
32
|
+
FileUtils.rm lock if File.exists? lock
|
33
33
|
end
|
34
34
|
end
|
35
35
|
puts
|
@@ -42,8 +42,8 @@ if persists.any?
|
|
42
42
|
pid, ppid, time = Rbbt.load_lock(lf)
|
43
43
|
if not Misc.pid_exists? pid
|
44
44
|
puts " Removing #{ persist }"
|
45
|
-
FileUtils.rm persists
|
46
|
-
FileUtils.rm lf
|
45
|
+
FileUtils.rm persists if File.exists? persists
|
46
|
+
FileUtils.rm lf if File.exists? lf
|
47
47
|
end
|
48
48
|
end
|
49
49
|
puts
|
@@ -56,8 +56,8 @@ if sensiblewrites.any?
|
|
56
56
|
pid, ppid, time = Rbbt.load_lock(lf)
|
57
57
|
if not Misc.pid_exists? pid
|
58
58
|
puts " Removing #{ sensiblewrite }"
|
59
|
-
FileUtils.rm sensiblewrite
|
60
|
-
FileUtils.rm lf
|
59
|
+
FileUtils.rm sensiblewrite if File.exists? sensiblewrite
|
60
|
+
FileUtils.rm lf if File.exists? lf
|
61
61
|
end
|
62
62
|
end
|
63
63
|
puts
|
@@ -69,10 +69,10 @@ puts Log.color(:magenta, "# Workflows:")
|
|
69
69
|
puts
|
70
70
|
jobs.each do |workflow, tasks|
|
71
71
|
tasks.each do |task, jobs|
|
72
|
-
puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:yellow, task) << ": #{jobs.length}"
|
73
72
|
done = []
|
74
73
|
other = {}
|
75
74
|
jobs.each do |file,h|
|
75
|
+
#puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:yellow, task) << ": #{jobs.length}"
|
76
76
|
status = h[:status]
|
77
77
|
if h[:status] == :done
|
78
78
|
done << file
|
@@ -85,9 +85,9 @@ jobs.each do |workflow, tasks|
|
|
85
85
|
list.each do |f,p|
|
86
86
|
if not Misc.pid_exists?(p) or status.to_s =~ /error|aborted|missing/
|
87
87
|
puts " Removing #{ f }"
|
88
|
-
FileUtils.rm_rf f
|
89
|
-
FileUtils.rm_rf f + '.info'
|
90
|
-
FileUtils.rm_rf f + '.files'
|
88
|
+
FileUtils.rm_rf f if File.exists? f
|
89
|
+
FileUtils.rm_rf f + '.info' if File.exists? f + '.info'
|
90
|
+
FileUtils.rm_rf f + '.files' if File.exists? f + '.files'
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -13,18 +13,20 @@ Report the status of the system
|
|
13
13
|
|
14
14
|
$ rbbt system status
|
15
15
|
|
16
|
+
-u--uncomplete Print only uncompleted or error jobs
|
16
17
|
-h--help Print this help
|
17
18
|
EOF
|
18
19
|
rbbt_usage and exit 0 if options[:help]
|
19
20
|
|
21
|
+
uncomplete = options.delete :uncomplete
|
20
22
|
|
21
23
|
def pid_msg(pid)
|
22
|
-
color = if Misc.pid_exists? pid
|
24
|
+
color = if pid and Misc.pid_exists? pid
|
23
25
|
:green
|
24
26
|
else
|
25
27
|
:red
|
26
28
|
end
|
27
|
-
Log.color(color, pid)
|
29
|
+
Log.color(color, pid || "missing")
|
28
30
|
end
|
29
31
|
|
30
32
|
def status_msg(status)
|
@@ -42,7 +44,7 @@ def status_msg(status)
|
|
42
44
|
nil
|
43
45
|
end
|
44
46
|
end
|
45
|
-
Log.color(color, status)
|
47
|
+
Log.color(color, status.to_s)
|
46
48
|
end
|
47
49
|
|
48
50
|
locks = Rbbt.locks
|
@@ -53,38 +55,39 @@ puts Log.color(:magenta, "# System report")
|
|
53
55
|
puts
|
54
56
|
if locks.any?
|
55
57
|
puts Log.color(:magenta, "Locks:")
|
56
|
-
locks.each do |lock|
|
58
|
+
locks.sort_by{|f| File.exists?(f) ? File.ctime(f) : Time.now}.each do |lock|
|
57
59
|
pid, ppid, time = Rbbt.load_lock(lock)
|
58
|
-
time
|
59
|
-
puts " " << lock + Log.color(:blue, " -- time: #{Time.now - time}; ppid: #{ppid}; pid: #{pid_msg pid}")
|
60
|
+
time = File.exists?(lock) ? File.ctime(lock) : Time.now
|
61
|
+
puts " " << lock + Log.color(:blue, " -- time: #{Misc.format_seconds(Time.now - time)}; ppid: #{ppid}; pid: #{pid_msg pid}")
|
60
62
|
end
|
61
63
|
puts
|
62
64
|
end
|
63
65
|
|
64
66
|
if persists.any?
|
65
67
|
puts Log.color(:magenta, "Persist:")
|
66
|
-
persists.each do |persist|
|
67
|
-
|
68
|
+
persists.sort_by{|f| File.exists?(f) ? File.ctime(f) : Time.now}.each do |persist|
|
69
|
+
time = File.exists?(persist) ? File.ctime(persist) : Time.now
|
70
|
+
puts " " << persist + Log.color(:blue, " -- time: #{Misc.format_seconds(Time.now - time)})")
|
68
71
|
end
|
69
72
|
puts
|
70
73
|
end
|
71
74
|
|
72
75
|
if sensiblewrites.any?
|
73
76
|
puts Log.color(:magenta, "Writing:")
|
74
|
-
sensiblewrites.each do |sensiblewrite|
|
77
|
+
sensiblewrites.sort_by{|f| File.exists?(f) ? File.ctime(f) : Time.now}.each do |sensiblewrite|
|
75
78
|
pid, ppid, time = Rbbt.load_lock(sensiblewrite + '.lock')
|
76
|
-
|
79
|
+
time = File.exists?(sensiblewrite) ? File.ctime(sensiblewrite) : Time.now
|
80
|
+
puts " " << sensiblewrite + Log.color(:blue, " -- time: #{Misc.format_seconds(Time.now - time)}; ppid: #{ppid}; pid: #{pid_msg pid}")
|
77
81
|
end
|
78
82
|
puts
|
79
83
|
end
|
80
84
|
|
81
85
|
jobs = Rbbt.jobs
|
82
86
|
|
83
|
-
puts Log.color(:magenta, "# Workflows
|
87
|
+
puts Log.color(:magenta, "# Workflows")
|
84
88
|
puts
|
85
89
|
jobs.each do |workflow, tasks|
|
86
90
|
tasks.each do |task, jobs|
|
87
|
-
puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:yellow, task) << ": "
|
88
91
|
done = []
|
89
92
|
other = {}
|
90
93
|
jobs.each do |file,h|
|
@@ -96,9 +99,11 @@ jobs.each do |workflow, tasks|
|
|
96
99
|
other[status||"missing"] << [file, h[:pid]]
|
97
100
|
end
|
98
101
|
end
|
99
|
-
|
102
|
+
next if uncomplete and other.empty?
|
103
|
+
puts "* " << Log.color(:magenta, workflow) << "#" << Log.color(:yellow, task) << ": " << Log.color(:green, "done") << " " << done.length.to_s
|
100
104
|
other.each do |status, list|
|
101
|
-
|
105
|
+
files_txt = list.collect{|f,p| p.nil? ? f : (f + " (#{pid_msg p})") }
|
106
|
+
puts " " << status_msg(status) << ": " << (files_txt * ", ")
|
102
107
|
end
|
103
108
|
end
|
104
109
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
|
2
|
+
|
3
|
+
require 'rbbt-util'
|
4
|
+
require 'rbbt/util/misc/lock'
|
5
|
+
|
6
|
+
class TestLock < Test::Unit::TestCase
|
7
|
+
def __test_stress
|
8
|
+
size = 1000000
|
9
|
+
num = 50
|
10
|
+
cpus = 200
|
11
|
+
TmpFile.with_file do |dir|
|
12
|
+
TSV.traverse (0..size).to_a, :cpus => cpus, :type => :array, :bar => true do |i|
|
13
|
+
begin
|
14
|
+
v = rand(num)
|
15
|
+
file = File.join(dir, "file-" << v.to_s)
|
16
|
+
Persist.persist("foo", :string, :file => file, :update => true) do
|
17
|
+
Process.pid.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
txt = `ls -la /proc/#{Process.pid}/fd |grep deleted`
|
21
|
+
Open.write(file, txt)
|
22
|
+
puts [Process.pid, txt.split("\n").length] * ": "
|
23
|
+
rescue Exception
|
24
|
+
Log.exception $!
|
25
|
+
raise $!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/test/rbbt/util/test_misc.rb
CHANGED
@@ -6,7 +6,13 @@ require 'rbbt/entity'
|
|
6
6
|
|
7
7
|
class TestMisc < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_format_seconds
|
10
|
+
t = 61.3232
|
11
|
+
assert_equal "00:01:01", Misc.format_seconds(t)
|
12
|
+
assert_equal "00:01:01.32", Misc.format_seconds(t, true)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_format_paragraph
|
10
16
|
p = <<-EOF
|
11
17
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
|
12
18
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
@@ -26,7 +32,7 @@ in culpa qui officia deserunt mollit anim id est laborum.
|
|
26
32
|
assert Misc.format_paragraph(p, 70, 10, 5) =~ /\n\s*\* two/sm
|
27
33
|
end
|
28
34
|
|
29
|
-
def
|
35
|
+
def test_format_dl
|
30
36
|
p1 = <<-EOF
|
31
37
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
|
32
38
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
@@ -56,13 +62,13 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
56
62
|
assert Misc.format_definition_list({:paragraph_first => p1, :paragraph_second => p2}) =~ / /
|
57
63
|
end
|
58
64
|
|
59
|
-
def
|
65
|
+
def test_parse_cmd_params
|
60
66
|
assert_equal ["workflow", "task", "Translation", "translate", "-f", "Associated Gene Name", "-l", "-"],
|
61
67
|
Misc.parse_cmd_params("workflow task Translation translate -f 'Associated Gene Name' -l -")
|
62
68
|
end
|
63
69
|
|
64
70
|
|
65
|
-
def
|
71
|
+
def test_fixutf8
|
66
72
|
string = "abc\xffdef"
|
67
73
|
string = string.force_encoding("UTF-8") if string.respond_to? :force_encoding
|
68
74
|
assert(! string.valid_encoding?) if string.respond_to? :valid_encoding?
|
@@ -71,37 +77,37 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
71
77
|
assert( Misc.fixutf8(string).valid_encoding) if string.respond_to? :valid_encoding
|
72
78
|
end
|
73
79
|
|
74
|
-
def
|
80
|
+
def test_colors_for
|
75
81
|
colors, used = Misc.colors_for([1,2,2,1,2,1,2,2,3,3,2,3,2])
|
76
82
|
assert_equal Misc::COLOR_LIST[1], used[2]
|
77
83
|
end
|
78
84
|
|
79
|
-
def
|
85
|
+
def test_total_length
|
80
86
|
ranges = [(0..100), (50..150), (120..160)]
|
81
87
|
ranges = [(0..100), (50..150), (120..160), (51..70)]
|
82
88
|
assert_equal 161, Misc.total_length(ranges)
|
83
89
|
end
|
84
90
|
|
85
|
-
def
|
91
|
+
def test_id_filename?
|
86
92
|
TmpFile.with_file("") do |file|
|
87
93
|
assert Misc.is_filename?(file)
|
88
94
|
assert ! Misc.is_filename?("TEST STRING")
|
89
95
|
end
|
90
96
|
end
|
91
97
|
|
92
|
-
def
|
98
|
+
def test_merge_sorted_arrays
|
93
99
|
assert_equal [1,2,3,4], Misc.merge_sorted_arrays([1,3], [2,4])
|
94
100
|
end
|
95
101
|
|
96
|
-
def
|
102
|
+
def test_intersect_sorted_arrays
|
97
103
|
assert_equal [2,4], Misc.intersect_sorted_arrays([1,2,3,4], [2,4])
|
98
104
|
end
|
99
105
|
|
100
|
-
def
|
106
|
+
def test_sorted_array_matches
|
101
107
|
assert_equal [1,3], Misc.sorted_array_hits(%w(a b c d e), %w(b d))
|
102
108
|
end
|
103
109
|
|
104
|
-
def
|
110
|
+
def test_binary_include?
|
105
111
|
a = %w(a b c d e).sort
|
106
112
|
assert Misc.binary_include?(a, "a")
|
107
113
|
assert(!Misc.binary_include?(a, "z"))
|
@@ -110,12 +116,12 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
110
116
|
assert(Misc.binary_include?(a, "d"))
|
111
117
|
end
|
112
118
|
|
113
|
-
def
|
119
|
+
def test_process_to_hash
|
114
120
|
list = [1,2,3,4]
|
115
121
|
assert_equal 4, Misc.process_to_hash(list){|l| l.collect{|e| e * 2}}[2]
|
116
122
|
end
|
117
123
|
|
118
|
-
def
|
124
|
+
def test_pipe_fork
|
119
125
|
sout, sin = Misc.pipe
|
120
126
|
pid = Process.fork do
|
121
127
|
Misc.purge_pipes(sin)
|
@@ -127,7 +133,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
127
133
|
Process.kill :INT, pid
|
128
134
|
end
|
129
135
|
|
130
|
-
def
|
136
|
+
def test_open_pipe
|
131
137
|
t = 5
|
132
138
|
stream = Misc.open_pipe do |sin|
|
133
139
|
t.times do |i|
|
@@ -148,7 +154,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
148
154
|
assert_equal (0..t-1).to_a.collect{|i| "LINE #{ i }"}, lines
|
149
155
|
end
|
150
156
|
|
151
|
-
def
|
157
|
+
def test_open_pipe_fork
|
152
158
|
t = 5
|
153
159
|
stream = Misc.open_pipe(true) do |sin|
|
154
160
|
t.times do |i|
|
@@ -169,7 +175,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
169
175
|
assert_equal (0..t-1).to_a.collect{|i| "LINE #{ i }"}, lines
|
170
176
|
end
|
171
177
|
|
172
|
-
def
|
178
|
+
def test_open_pipe_fork_cascade
|
173
179
|
t = 500
|
174
180
|
sleep_time = 2.0 / t
|
175
181
|
time = Time.now
|
@@ -205,7 +211,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
205
211
|
assert_equal (0..t-1).to_a.collect{|i| "LINE #{ i }".reverse.downcase}, lines
|
206
212
|
end
|
207
213
|
|
208
|
-
def
|
214
|
+
def test_tee_stream
|
209
215
|
t = 500
|
210
216
|
sleep_time = 2.0 / t
|
211
217
|
time = Time.now
|
@@ -255,7 +261,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
255
261
|
end
|
256
262
|
|
257
263
|
|
258
|
-
def
|
264
|
+
def test_string2hash
|
259
265
|
assert(Misc.string2hash("--user-agent=firefox").include? "--user-agent")
|
260
266
|
assert_equal(true, Misc.string2hash(":true")[:true])
|
261
267
|
assert_equal(true, Misc.string2hash("true")["true"])
|
@@ -266,16 +272,16 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
266
272
|
assert_equal(:j, Misc.string2hash("a=b#c=d#:h=:j")[:h])
|
267
273
|
end
|
268
274
|
|
269
|
-
def
|
275
|
+
def test_named_array
|
270
276
|
a = NamedArray.setup([1,2,3,4], %w(a b c d))
|
271
277
|
assert_equal(1, a['a'])
|
272
278
|
end
|
273
279
|
|
274
|
-
def
|
280
|
+
def test_path_relative_to
|
275
281
|
assert_equal "test/foo", Misc.path_relative_to('/test', '/test/test/foo')
|
276
282
|
end
|
277
283
|
|
278
|
-
def
|
284
|
+
def test_hash2string
|
279
285
|
hash = {}
|
280
286
|
assert_equal hash, Misc.string2hash(Misc.hash2string(hash))
|
281
287
|
|
@@ -293,14 +299,14 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
293
299
|
|
294
300
|
end
|
295
301
|
|
296
|
-
def
|
302
|
+
def test_merge
|
297
303
|
a = [[1],[2]]
|
298
304
|
a = NamedArray.setup a, %w(1 2)
|
299
305
|
a.merge [3,4]
|
300
306
|
assert_equal [1,3], a[0]
|
301
307
|
end
|
302
308
|
|
303
|
-
def
|
309
|
+
def test_indiferent_hash
|
304
310
|
a = {:a => 1, "b" => 2}
|
305
311
|
a.extend IndiferentHash
|
306
312
|
|
@@ -310,7 +316,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
310
316
|
assert_equal 2, a[:b]
|
311
317
|
end
|
312
318
|
|
313
|
-
def
|
319
|
+
def test_lockfile
|
314
320
|
|
315
321
|
TmpFile.with_file do |tmpfile|
|
316
322
|
pids = []
|
@@ -334,7 +340,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
334
340
|
end
|
335
341
|
end
|
336
342
|
|
337
|
-
def
|
343
|
+
def test_positions2hash
|
338
344
|
inputs = Misc.positional2hash([:one, :two, :three], 1, :two => 2, :four => 4)
|
339
345
|
assert_equal 1, inputs[:one]
|
340
346
|
assert_equal 2, inputs[:two]
|
@@ -342,12 +348,12 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
342
348
|
assert_equal nil, inputs[:four]
|
343
349
|
end
|
344
350
|
|
345
|
-
def
|
351
|
+
def test_mean
|
346
352
|
assert_equal 2, Misc.mean([1,2,3])
|
347
353
|
assert_equal 3, Misc.mean([1,2,3,4,5])
|
348
354
|
end
|
349
355
|
|
350
|
-
def
|
356
|
+
def test_zip_fields
|
351
357
|
current = [[:a,1], [:b,2]]
|
352
358
|
assert_equal [[:a, :b],[1,2]], Misc.zip_fields(current)
|
353
359
|
assert_equal current, Misc.zip_fields(Misc.zip_fields(current))
|
@@ -359,7 +365,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
359
365
|
assert_equal current, Misc.zip_fields(Misc.zip_fields(current)).collect{|v| v.compact }
|
360
366
|
end
|
361
367
|
|
362
|
-
def
|
368
|
+
def test_add_zipped
|
363
369
|
current = [[:a,1], [:b,2]]
|
364
370
|
new = %w(A B)
|
365
371
|
Misc.append_zipped current, new
|
@@ -370,20 +376,20 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
370
376
|
assert_equal Math.sqrt(2), Misc.sd([1,3])
|
371
377
|
end
|
372
378
|
|
373
|
-
def
|
379
|
+
def test_divide
|
374
380
|
assert_equal 2, Misc.divide(%w(1 2 3 4 5 6 7 8 9),2).length
|
375
381
|
end
|
376
382
|
|
377
|
-
def
|
383
|
+
def test_ordered_divide
|
378
384
|
assert_equal 5, Misc.ordered_divide(%w(1 2 3 4 5 6 7 8 9),2).length
|
379
385
|
end
|
380
386
|
|
381
|
-
def
|
387
|
+
def test_collapse_ranges
|
382
388
|
ranges = [(0..100), (50..150), (51..61),(200..250), (300..324),(320..350)]
|
383
389
|
assert_equal [(0..150),(200..250), (300..350)], Misc.collapse_ranges(ranges)
|
384
390
|
end
|
385
391
|
|
386
|
-
def
|
392
|
+
def test_humanize
|
387
393
|
str1 = "test_string"
|
388
394
|
str2 = "TEST_string"
|
389
395
|
str3 = "test"
|
@@ -395,22 +401,22 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
395
401
|
assert_equal "mutation_enrichment", Misc.snake_case("MutationEnrichment")
|
396
402
|
end
|
397
403
|
|
398
|
-
def
|
404
|
+
def test_snake_case
|
399
405
|
str1 = "ACRONIMTest"
|
400
406
|
str2 = "ACRONIM_test"
|
401
407
|
assert_equal "ACRONIM_test", Misc.snake_case(str1)
|
402
408
|
assert_equal "ACRONIM_test", Misc.snake_case(str2)
|
403
409
|
end
|
404
410
|
|
405
|
-
def
|
411
|
+
def test_correct_vcf_mutations
|
406
412
|
assert_equal [737407, ["-----", "-----G", "-----GTTAAT"]], Misc.correct_vcf_mutation(737406, "GTTAAT", "G,GG,GGTTAAT")
|
407
413
|
end
|
408
414
|
|
409
|
-
def
|
415
|
+
def test_fingerprint
|
410
416
|
assert_equal '{a=>1}', Misc.fingerprint({:a => 1})
|
411
417
|
end
|
412
418
|
|
413
|
-
def
|
419
|
+
def test_tarize
|
414
420
|
path = File.expand_path('/home/mvazquezg/git/rbbt-util/lib')
|
415
421
|
stream = Misc.tarize(path)
|
416
422
|
TmpFile.with_file do |res|
|
@@ -420,7 +426,7 @@ eum fugiat quo voluptas nulla pariatur?"
|
|
420
426
|
end
|
421
427
|
end
|
422
428
|
|
423
|
-
def
|
429
|
+
def test_camel_case
|
424
430
|
assert_equal "DbSNP", Misc.camel_case("db_SNP")
|
425
431
|
assert_equal "D3Js", Misc.camel_case("D3Js")
|
426
432
|
assert_equal "Structure", Misc.camel_case("Structure")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.13.
|
4
|
+
version: 5.13.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
@@ -313,6 +313,7 @@ files:
|
|
313
313
|
- test/rbbt/util/concurrency/test_processes.rb
|
314
314
|
- test/rbbt/util/concurrency/test_threads.rb
|
315
315
|
- test/rbbt/util/log/test_progress.rb
|
316
|
+
- test/rbbt/util/misc/test_lock.rb
|
316
317
|
- test/rbbt/util/misc/test_pipes.rb
|
317
318
|
- test/rbbt/util/simpleopt/test_get.rb
|
318
319
|
- test/rbbt/util/simpleopt/test_parse.rb
|
@@ -370,6 +371,7 @@ test_files:
|
|
370
371
|
- test/rbbt/util/test_simpleDSL.rb
|
371
372
|
- test/rbbt/util/test_log.rb
|
372
373
|
- test/rbbt/util/test_open.rb
|
374
|
+
- test/rbbt/util/misc/test_lock.rb
|
373
375
|
- test/rbbt/util/misc/test_pipes.rb
|
374
376
|
- test/rbbt/util/test_concurrency.rb
|
375
377
|
- test/rbbt/util/test_R.rb
|