rbbt-util 5.21.96 → 5.21.97
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/tsv/attach/util.rb +1 -1
- data/lib/rbbt/tsv/parallel/traverse.rb +3 -0
- data/lib/rbbt/tsv/parser.rb +5 -0
- data/lib/rbbt/tsv/util.rb +1 -1
- data/lib/rbbt/util/R.rb +2 -1
- data/lib/rbbt/util/R/plot.rb +1 -1
- data/lib/rbbt/util/log/progress/report.rb +1 -1
- data/lib/rbbt/util/misc/format.rb +2 -1
- data/lib/rbbt/util/misc/math.rb +17 -6
- data/lib/rbbt/util/open.rb +3 -0
- data/lib/rbbt/util/simpleopt/parse.rb +3 -0
- data/lib/rbbt/workflow/accessor.rb +2 -1
- data/lib/rbbt/workflow/step/dependencies.rb +5 -8
- data/lib/rbbt/workflow/step/run.rb +14 -0
- data/lib/rbbt/workflow/usage.rb +1 -1
- data/share/Rlib/svg.R +8 -8
- data/share/Rlib/util.R +3 -2
- 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: 10ef32da69366f0d5db85823d95e5e2461817656
|
4
|
+
data.tar.gz: 7db675c42bfb34aae38611247d22cc5c3c6e4572
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db31f57eaa344bbbcac12c5a85dad2e46b555f6d19545a55854017c6dc8147d8d321d84f0a2578c29104b1d70b6de322ff5d49dd44c01452fb36fb2ebb59aa0b
|
7
|
+
data.tar.gz: 36f1dbc9bdf5242b02ce9944ce5ae0b93b7b51df4a1a2c68a6370498f7571ca2a9523b5867ce6a637367d26c431d4738a0159de17285f34310a9b0a29d62107a
|
data/lib/rbbt/tsv/attach/util.rb
CHANGED
@@ -276,6 +276,9 @@ module TSV
|
|
276
276
|
traverse_obj(obj.stream, options, &block)
|
277
277
|
when (defined? Step and Step)
|
278
278
|
|
279
|
+
obj.clean if obj.aborted? or obj.recoverable_error?
|
280
|
+
obj.run(true) unless obj.done? or obj.started?
|
281
|
+
|
279
282
|
stream = obj.get_stream
|
280
283
|
|
281
284
|
if stream
|
data/lib/rbbt/tsv/parser.rb
CHANGED
@@ -639,6 +639,11 @@ module TSV
|
|
639
639
|
TSV.identify_field(key_field, fields, field)
|
640
640
|
end
|
641
641
|
|
642
|
+
def rewind
|
643
|
+
stream.reopen(filename, "r") if stream.closed? and filename
|
644
|
+
stream.rewind
|
645
|
+
end
|
646
|
+
|
642
647
|
def self.traverse(stream, options = {}, &block)
|
643
648
|
parser = Parser.new(stream, options)
|
644
649
|
parser.traverse(options, &block)
|
data/lib/rbbt/tsv/util.rb
CHANGED
data/lib/rbbt/util/R.rb
CHANGED
@@ -23,6 +23,7 @@ source('#{UTIL}');
|
|
23
23
|
|
24
24
|
require_sources = source.collect{|source|
|
25
25
|
source = R::LIB_DIR["plot.R"] if source == :plot
|
26
|
+
source = R::LIB_DIR["svg.R"] if source == :svg
|
26
27
|
"source('#{source}')"
|
27
28
|
} * ";\n" if Array === source and source.any?
|
28
29
|
|
@@ -64,7 +65,7 @@ source('#{UTIL}');
|
|
64
65
|
f.puts
|
65
66
|
f.puts script
|
66
67
|
end
|
67
|
-
CMD.cmd("env R_PROFILE='#{init_file}' xterm \"$
|
68
|
+
CMD.cmd("env R_PROFILE='#{init_file}' xterm \"$R_HOME/bin/R\"")
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
data/lib/rbbt/util/R/plot.rb
CHANGED
@@ -165,7 +165,7 @@ module Log
|
|
165
165
|
ellapsed = 0
|
166
166
|
end
|
167
167
|
ellapsed = [ellapsed/3600, ellapsed/60 % 60, ellapsed % 60].map{|t| "%02i" % t }.join(':')
|
168
|
-
done_msg << " " << Log.color(:blue, (@ticks).to_s) << " in " << Log.color(:green, ellapsed)
|
168
|
+
done_msg << " " << Log.color(:blue, (@ticks).to_s) << " #{bytes ? 'bytes' : 'items'} in " << Log.color(:green, ellapsed)
|
169
169
|
@last_count = 0
|
170
170
|
@last_time = @start
|
171
171
|
done_msg << " (" << thr_msg << ")"
|
@@ -165,7 +165,8 @@ module Misc
|
|
165
165
|
(string.respond_to? :valid_encoding and string.valid_encoding)
|
166
166
|
|
167
167
|
if string.respond_to?(:encode)
|
168
|
-
string.encode("UTF-16BE", :invalid => :replace, :undef => :replace, :replace => "?").encode('UTF-8')
|
168
|
+
#string.encode("UTF-16BE", :invalid => :replace, :undef => :replace, :replace => "?").encode('UTF-8')
|
169
|
+
string.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
|
169
170
|
else
|
170
171
|
require 'iconv'
|
171
172
|
@@ic ||= Iconv.new('UTF-8//IGNORE', 'UTF-8')
|
data/lib/rbbt/util/misc/math.rb
CHANGED
@@ -43,7 +43,7 @@ module Misc
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.mean(list)
|
46
|
-
sum(list) / list.compact.length
|
46
|
+
sum(list).to_f / list.compact.length
|
47
47
|
end
|
48
48
|
|
49
49
|
def self.median(array)
|
@@ -52,22 +52,27 @@ module Misc
|
|
52
52
|
(sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
|
-
def self.sd(list)
|
55
|
+
def self.variance(list)
|
57
56
|
return nil if list.length < 3
|
58
57
|
mean = mean(list)
|
59
58
|
list = list.compact
|
60
59
|
list_length = list.length
|
61
60
|
|
62
|
-
total_square_distance = 0
|
61
|
+
total_square_distance = 0.0
|
63
62
|
list.each do |value|
|
64
|
-
distance = value - mean
|
63
|
+
distance = value.to_f - mean
|
65
64
|
total_square_distance += distance * distance
|
66
65
|
end
|
67
66
|
|
68
67
|
variance = total_square_distance / (list_length - 1)
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
def self.sd(list)
|
73
|
+
return nil if list.length < 3
|
74
|
+
variance = self.variance(list)
|
69
75
|
Math.sqrt(variance)
|
70
|
-
#Math.sqrt(list.compact.inject(0.0){|acc,e| d = e - mean; acc += d * d; acc}) / (list.compact.length - 1)
|
71
76
|
end
|
72
77
|
|
73
78
|
def self.counts(array)
|
@@ -124,4 +129,10 @@ module Misc
|
|
124
129
|
def self.in_delta?(a, b, delta = 0.0001)
|
125
130
|
(a.to_f - b.to_f).abs < delta
|
126
131
|
end
|
132
|
+
|
133
|
+
def self.zscore(e, list)
|
134
|
+
m = Misc.mean(list)
|
135
|
+
sd = Misc.sd(list)
|
136
|
+
(e.to_f - m) / sd
|
137
|
+
end
|
127
138
|
end
|
data/lib/rbbt/util/open.rb
CHANGED
@@ -311,14 +311,17 @@ module Open
|
|
311
311
|
end
|
312
312
|
|
313
313
|
def self.gzip?(file)
|
314
|
+
file = file.find if Path === file
|
314
315
|
!! (file =~ /\.gz$/)
|
315
316
|
end
|
316
317
|
|
317
318
|
def self.bgzip?(file)
|
319
|
+
file = file.find if Path === file
|
318
320
|
!! (file =~ /\.bgz$/)
|
319
321
|
end
|
320
322
|
|
321
323
|
def self.zip?(file)
|
324
|
+
file = file.find if Path === file
|
322
325
|
!! (file =~ /\.zip$/)
|
323
326
|
end
|
324
327
|
|
@@ -4,6 +4,9 @@ module SOPT
|
|
4
4
|
def self.fix_shortcut(short, long)
|
5
5
|
return short unless short and shortcuts.include?(short)
|
6
6
|
|
7
|
+
current = shortcuts.select{|s,l| l == long}.collect{|s,l| s }.first
|
8
|
+
return current if current
|
9
|
+
|
7
10
|
chars = long.chars.to_a
|
8
11
|
current = [chars.shift]
|
9
12
|
short = current * ""
|
@@ -774,7 +774,8 @@ module Workflow
|
|
774
774
|
new_=[]
|
775
775
|
dep.each{|d|
|
776
776
|
if Hash === d
|
777
|
-
|
777
|
+
d[:workflow] ||= self
|
778
|
+
inputs = assign_dep_inputs({}, options.merge(d[:inputs] || {}), real_dependencies, d[:workflow].task_info(d[:task]))
|
778
779
|
d = d[:workflow].job(d[:task], d[:jobname], inputs)
|
779
780
|
end
|
780
781
|
ComputeDependency.setup(d, compute) if compute
|
@@ -6,11 +6,6 @@ class Step
|
|
6
6
|
def self.purge_stream_cache
|
7
7
|
Log.debug "Purging dup. stream cache"
|
8
8
|
STREAM_CACHE_MUTEX.synchronize do
|
9
|
-
#STREAM_CACHE.collect{|k,s|
|
10
|
-
# Thread.new do
|
11
|
-
# Misc.consume_stream s
|
12
|
-
# end
|
13
|
-
#}
|
14
9
|
STREAM_CACHE.clear
|
15
10
|
end
|
16
11
|
end
|
@@ -43,17 +38,18 @@ class Step
|
|
43
38
|
new
|
44
39
|
end
|
45
40
|
end
|
46
|
-
when TSV::Dumper
|
41
|
+
when TSV::Dumper, TSV::Parser
|
42
|
+
orig_stream = stream
|
47
43
|
stream = stream.stream
|
48
44
|
return stream if stream.closed?
|
49
45
|
|
50
46
|
STREAM_CACHE_MUTEX.synchronize do
|
51
47
|
if STREAM_CACHE[stream].nil?
|
52
|
-
Log.high "Not duplicating
|
48
|
+
Log.high "Not duplicating #{Misc.fingerprint orig_stream} #{ stream.inspect }"
|
53
49
|
STREAM_CACHE[stream] = stream
|
54
50
|
else
|
55
51
|
new = Misc.dup_stream(STREAM_CACHE[stream])
|
56
|
-
Log.high "Duplicating
|
52
|
+
Log.high "Duplicating #{Misc.fingerprint orig_stream} #{ stream.inspect } into #{new.inspect}"
|
57
53
|
new
|
58
54
|
end
|
59
55
|
end
|
@@ -64,6 +60,7 @@ class Step
|
|
64
60
|
|
65
61
|
def dup_inputs
|
66
62
|
return if @dupped or ENV["RBBT_NO_STREAM"] == 'true'
|
63
|
+
return if ComputeDependency === self and self.compute == :produce
|
67
64
|
Log.low "Dupping inputs for #{path}"
|
68
65
|
dupped_inputs = @inputs.collect do |input|
|
69
66
|
Step.dup_stream input
|
@@ -51,8 +51,22 @@ class Step
|
|
51
51
|
@inputs.replace new_inputs if step
|
52
52
|
end
|
53
53
|
|
54
|
+
def rewind_inputs
|
55
|
+
return if @inputs.nil?
|
56
|
+
Log.debug "Rewinding inputs for #{path}"
|
57
|
+
@inputs.each do |input|
|
58
|
+
next unless input.respond_to? :rewind
|
59
|
+
begin
|
60
|
+
input.rewind
|
61
|
+
Log.debug "Rewinded #{Misc.fingerprint input}"
|
62
|
+
rescue
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
54
67
|
def _exec
|
55
68
|
resolve_input_steps
|
69
|
+
rewind_inputs
|
56
70
|
@exec = true if @exec.nil?
|
57
71
|
begin
|
58
72
|
old = Signal.trap("INT"){ Thread.current.raise Aborted }
|
data/lib/rbbt/workflow/usage.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rbbt/util/simpleopt'
|
|
3
3
|
module Task
|
4
4
|
def doc(workflow = nil, deps = nil)
|
5
5
|
puts Log.color(:yellow, "## #{ name }") << ":"
|
6
|
-
puts "\n" << description << "\n" if description and not description.empty?
|
6
|
+
puts "\n" << Misc.format_paragraph(description.strip) << "\n" if description and not description.empty?
|
7
7
|
puts
|
8
8
|
|
9
9
|
case
|
data/share/Rlib/svg.R
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
rbbt.require('plyr')
|
2
|
+
rbbt.require('proto')
|
3
|
+
rbbt.require('ggplot2')
|
4
|
+
rbbt.require('gridSVG')
|
5
|
+
rbbt.require('grid')
|
6
|
+
rbbt.require('XML')
|
7
|
+
rbbt.require('ggthemes')
|
8
|
+
rbbt.require('Cairo')
|
9
9
|
|
10
10
|
# Modified from http://aaronecay.com/blog/2014/02/tooltips-in-ggplot/
|
11
11
|
|
data/share/Rlib/util.R
CHANGED
@@ -636,12 +636,13 @@ rbbt.plot.text_scatter <- function(formula, data) {
|
|
636
636
|
|
637
637
|
rbbt.install.CRAN <- function(pkg){
|
638
638
|
res = FALSE
|
639
|
-
tryCatch({ install.packages(pkg); res = TRUE }, error = function(e){ warning(paste("Could not install CRAN ", pkg)); res = FALSE })
|
639
|
+
tryCatch({ install.packages(pkg); library(pkg); res = TRUE }, error = function(e){ warning(paste("Could not install CRAN ", pkg)); res = FALSE })
|
640
640
|
return(res)
|
641
641
|
}
|
642
|
+
|
642
643
|
rbbt.install.bioc <-function(pkg){
|
643
644
|
res = FALSE
|
644
|
-
tryCatch({ source("http://bioconductor.org/biocLite.R"); biocLite(pkg); res = TRUE }, error = function(e){ warning(paste("Could not install Bioconductor ", pkg)); res = FALSE })
|
645
|
+
tryCatch({ source("http://bioconductor.org/biocLite.R"); biocLite(pkg, ask=FALSE, suppressUpdates = TRUE); res = TRUE }, error = function(e){ warning(paste("Could not install Bioconductor ", pkg)); res = FALSE })
|
645
646
|
return(res)
|
646
647
|
}
|
647
648
|
|
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.21.
|
4
|
+
version: 5.21.97
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|