rbbt-util 5.21.127 → 5.21.128
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/workflow.rb +5 -3
- data/lib/rbbt/workflow/accessor.rb +33 -2
- data/lib/rbbt/workflow/step/dependencies.rb +45 -4
- data/lib/rbbt/workflow/step/run.rb +10 -1
- data/share/Rlib/util.R +38 -1
- data/share/rbbt_commands/stat/density +3 -5
- data/share/rbbt_commands/stat/heatmap +58 -0
- data/share/rbbt_commands/workflow/cmd +20 -1
- data/test/rbbt/test_workflow.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2e38a07f3d52f96131185d87edc11c40f7a5ea5
|
4
|
+
data.tar.gz: 920dab12666bcce73c7121959c22d99a0c2b2b57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98919775334053530f302b4e98d31cefcec11bc38f3b1809c27ffec15befccd2a6819841aaa15389334fb2813fdf95253037696c0488de33f7d3b50c5ec98715
|
7
|
+
data.tar.gz: 1e2eae9c61741de2c300b935efd98009ba9babb8e5947d7b4c048a4be1eabfc28c2f2e79021f1b77df442340a7ed7cbbf3bf414501408141b00129c5e41df556
|
data/lib/rbbt/workflow.rb
CHANGED
@@ -355,9 +355,11 @@ module Workflow
|
|
355
355
|
|
356
356
|
def set_step_dependencies(step)
|
357
357
|
if step.info.include? :dependencies
|
358
|
-
|
359
|
-
|
360
|
-
|
358
|
+
Misc.insist do
|
359
|
+
step.dependencies = step.info[:dependencies].collect do |task, job, path|
|
360
|
+
next if job.nil?
|
361
|
+
load_step(path)
|
362
|
+
end
|
361
363
|
end
|
362
364
|
end
|
363
365
|
end
|
@@ -367,12 +367,12 @@ class Step
|
|
367
367
|
end
|
368
368
|
|
369
369
|
def dirty_files
|
370
|
+
canfail_paths = self.canfail_paths
|
370
371
|
dirty_files = rec_dependencies.reject{|dep|
|
371
372
|
(defined?(WorkflowRESTClient) && WorkflowRESTClient::RemoteStep === dep) ||
|
372
373
|
(dep.path && (Open.exists?(dep.path) || Open.remote?(dep.path))) ||
|
373
|
-
(dep.error? && ! dep.recoverable_error?)
|
374
|
+
((dep.error? || dep.aborted?) && (! dep.recoverable_error? || canfail_paths.include?(dep.path)))
|
374
375
|
}
|
375
|
-
|
376
376
|
end
|
377
377
|
|
378
378
|
def dirty?
|
@@ -550,6 +550,7 @@ module Workflow
|
|
550
550
|
inputs = rec_inputs(name).uniq
|
551
551
|
input_types = rec_input_types(name)
|
552
552
|
input_descriptions = rec_input_descriptions(name)
|
553
|
+
input_use = rec_input_use(name)
|
553
554
|
input_defaults = rec_input_defaults(name)
|
554
555
|
input_options = rec_input_options(name)
|
555
556
|
export = case
|
@@ -575,6 +576,7 @@ module Workflow
|
|
575
576
|
:input_descriptions => input_descriptions,
|
576
577
|
:input_defaults => input_defaults,
|
577
578
|
:input_options => input_options,
|
579
|
+
:input_use => input_use,
|
578
580
|
:result_type => result_type,
|
579
581
|
:result_description => result_description,
|
580
582
|
:dependencies => dependencies
|
@@ -696,6 +698,35 @@ module Workflow
|
|
696
698
|
acc
|
697
699
|
}.tap{|h| IndiferentHash.setup(h)}
|
698
700
|
end
|
701
|
+
|
702
|
+
def rec_input_use(taskname)
|
703
|
+
task = task_from_dep(taskname)
|
704
|
+
deps = rec_dependencies(taskname)
|
705
|
+
inputs = {}
|
706
|
+
task.inputs.each do |input|
|
707
|
+
name = task.name
|
708
|
+
workflow = (task.workflow || self).to_s
|
709
|
+
|
710
|
+
inputs[input] ||= {}
|
711
|
+
inputs[input][workflow] ||= []
|
712
|
+
inputs[input][workflow] << name
|
713
|
+
end
|
714
|
+
|
715
|
+
dep_inputs = Task.dep_inputs deps, self
|
716
|
+
|
717
|
+
dep_inputs.each do |dep,is|
|
718
|
+
name = dep.name
|
719
|
+
workflow = dep.workflow
|
720
|
+
|
721
|
+
is.each do |input|
|
722
|
+
inputs[input] ||= {}
|
723
|
+
inputs[input][workflow] ||= []
|
724
|
+
inputs[input][workflow] << name
|
725
|
+
end
|
726
|
+
end
|
727
|
+
|
728
|
+
inputs
|
729
|
+
end
|
699
730
|
|
700
731
|
def rec_input_descriptions(taskname)
|
701
732
|
rec_inputs = rec_inputs(taskname)
|
@@ -126,11 +126,12 @@ class Step
|
|
126
126
|
end
|
127
127
|
|
128
128
|
if dependency.aborted? or (dependency.error? and dependency.recoverable_error?) or (!Open.remote?(dependency.path) && dependency.missing?)
|
129
|
+
Log.warn "Cleaning dep. #{Log.color :red, dependency.task_name.to_s}"
|
129
130
|
dependency.clean
|
130
131
|
raise TryAgain
|
131
132
|
end
|
132
133
|
|
133
|
-
if
|
134
|
+
if ! dependency.started? && ! dependency.error?
|
134
135
|
log_dependency_exec(dependency, :starting)
|
135
136
|
dependency.run(true)
|
136
137
|
raise TryAgain
|
@@ -157,6 +158,7 @@ class Step
|
|
157
158
|
end
|
158
159
|
|
159
160
|
rescue TryAgain
|
161
|
+
Log.low "Retrying dep. #{Log.color :yellow, dependency.task_name.to_s} -- [#{dependency.status}] #{dependency.messages.last}"
|
160
162
|
retry
|
161
163
|
rescue Aborted, Interrupt
|
162
164
|
Log.error "Aborted dep. #{Log.color :red, dependency.task_name.to_s}"
|
@@ -267,6 +269,24 @@ class Step
|
|
267
269
|
end
|
268
270
|
end
|
269
271
|
|
272
|
+
def canfail_paths
|
273
|
+
if info[:canfail_paths]
|
274
|
+
Set.new(info[:canfail_paths])
|
275
|
+
else
|
276
|
+
canfail_paths = Set.new
|
277
|
+
all_deps = rec_dependencies + [self]
|
278
|
+
all_deps.each do |dep|
|
279
|
+
next if canfail_paths.include? dep.path
|
280
|
+
next unless ComputeDependency === dep && dep.canfail?
|
281
|
+
canfail_paths << dep.path
|
282
|
+
canfail_paths += dep.rec_dependencies.collect{|d| d.path }
|
283
|
+
end
|
284
|
+
canfail_paths
|
285
|
+
set_info :canfail_paths, canfail_paths.to_a
|
286
|
+
canfail_paths
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
270
290
|
def run_dependencies
|
271
291
|
dep_step = {}
|
272
292
|
|
@@ -281,11 +301,17 @@ class Step
|
|
281
301
|
dep.rec_dependencies
|
282
302
|
end.compact.flatten.uniq
|
283
303
|
|
304
|
+
canfail_paths = self.canfail_paths
|
305
|
+
|
284
306
|
seen_paths = Set.new
|
285
307
|
all_deps.uniq.each do |step|
|
286
308
|
next if seen_paths.include? step.path
|
287
309
|
seen_paths << step.path
|
288
|
-
|
310
|
+
begin
|
311
|
+
Step.prepare_for_execution(step) unless step == self
|
312
|
+
rescue DependencyError
|
313
|
+
raise $! unless canfail_paths.include? step.path
|
314
|
+
end
|
289
315
|
next unless step.dependencies and step.dependencies.any?
|
290
316
|
step.dependencies.each do |step_dep|
|
291
317
|
next if step_dep.done? or step_dep.running? or (ComputeDependency === step_dep and step_dep.compute == :nodup)
|
@@ -346,7 +372,11 @@ class Step
|
|
346
372
|
Log.medium "Processing pre dependencies: #{Misc.fingerprint(pre_deps)} - #{Log.color :blue, self.path}" if pre_deps.any?
|
347
373
|
pre_deps.each do |step|
|
348
374
|
next if compute_deps.include? step
|
349
|
-
|
375
|
+
begin
|
376
|
+
execute_and_dup(step, dep_step, false)
|
377
|
+
rescue Exception
|
378
|
+
raise $! unless canfail_paths.include?(step.path)
|
379
|
+
end
|
350
380
|
end
|
351
381
|
|
352
382
|
Log.medium "Computing pre dependencies: #{Misc.fingerprint(compute_pre_deps)} - #{Log.color :blue, self.path}" if compute_pre_deps.any?
|
@@ -357,7 +387,11 @@ class Step
|
|
357
387
|
Log.medium "Processing last dependencies: #{Misc.fingerprint(last_deps)} - #{Log.color :blue, self.path}" if last_deps.any?
|
358
388
|
last_deps.each do |step|
|
359
389
|
next if compute_deps.include? step
|
360
|
-
|
390
|
+
begin Exception
|
391
|
+
execute_and_dup(step, dep_step)
|
392
|
+
rescue
|
393
|
+
raise $! unless canfail_paths.include? step.path
|
394
|
+
end
|
361
395
|
end
|
362
396
|
|
363
397
|
Log.medium "Computing last dependencies: #{Misc.fingerprint(compute_last_deps)} - #{Log.color :blue, self.path}" if compute_last_deps.any?
|
@@ -365,6 +399,13 @@ class Step
|
|
365
399
|
run_compute_dependencies(type, list, dep_step)
|
366
400
|
end
|
367
401
|
|
402
|
+
Log.medium "Aborting waiting dangling dependencies"
|
403
|
+
all_deps.each do |dep|
|
404
|
+
next if dep.done?
|
405
|
+
next unless canfail_paths.include? dep.path
|
406
|
+
dep.abort if dep.waiting?
|
407
|
+
end
|
408
|
+
|
368
409
|
end
|
369
410
|
|
370
411
|
def stop_dependencies
|
@@ -24,6 +24,14 @@ class Step
|
|
24
24
|
new_inputs = inputs.collect do |i|
|
25
25
|
begin
|
26
26
|
if Step === i
|
27
|
+
if i.error?
|
28
|
+
e = i.get_exception
|
29
|
+
if e
|
30
|
+
raise e
|
31
|
+
else
|
32
|
+
raise DependencyError, "Error in dep. #{Log.blue e.path}"
|
33
|
+
end
|
34
|
+
end
|
27
35
|
step = true
|
28
36
|
i.produce unless i.done? || i.error? || i.started?
|
29
37
|
if i.done?
|
@@ -106,11 +114,12 @@ class Step
|
|
106
114
|
|
107
115
|
outdated_time = []
|
108
116
|
outdated_dep = []
|
117
|
+
canfail_paths = self.canfail_paths
|
109
118
|
checks.each do |dep|
|
110
119
|
if dep.done? && self.done? && (File.mtime(dep.path) > File.mtime(self.path))
|
111
120
|
outdated_time << dep
|
112
121
|
end
|
113
|
-
if ! dep.done? || ! dep.updated?
|
122
|
+
if (! dep.done? && ! canfail_paths.include?(dep.path)) || ! dep.updated?
|
114
123
|
outdated_dep << dep
|
115
124
|
end
|
116
125
|
end
|
data/share/Rlib/util.R
CHANGED
@@ -523,7 +523,44 @@ rbbt.png_plot <- function(filename, p, width=500, height=500, ...){
|
|
523
523
|
eval(parse(text=p));
|
524
524
|
}
|
525
525
|
|
526
|
-
rbbt.
|
526
|
+
rbbt.pheatmap <- function(filename, data, width=800, height=800, take_log=FALSE, stdize=FALSE, positive=FALSE, ...){
|
527
|
+
rbbt.require('pheatmap')
|
528
|
+
|
529
|
+
opar = par()
|
530
|
+
png(filename=filename, width=width, height=height);
|
531
|
+
|
532
|
+
data = as.matrix(data)
|
533
|
+
data[is.nan(data)] = NA
|
534
|
+
|
535
|
+
data = data[rowSums(is.na(data))==0, ]
|
536
|
+
|
537
|
+
if (take_log){
|
538
|
+
for (study in colnames(data)){
|
539
|
+
skip = sum(data[, study] <= 0) != 0
|
540
|
+
if (!skip){
|
541
|
+
data[, study] = log(data[, study])
|
542
|
+
}
|
543
|
+
}
|
544
|
+
data = data[, colSums(is.na(data))==0]
|
545
|
+
}
|
546
|
+
|
547
|
+
|
548
|
+
if (stdize){
|
549
|
+
rbbt.require('pls')
|
550
|
+
data = stdize(data)
|
551
|
+
}
|
552
|
+
|
553
|
+
if (positive){
|
554
|
+
pheatmap(data,color= colorRampPalette(c("white", "red"))(100), ...)
|
555
|
+
}else{
|
556
|
+
pheatmap(data, ...)
|
557
|
+
}
|
558
|
+
|
559
|
+
dev.off();
|
560
|
+
par(opar)
|
561
|
+
}
|
562
|
+
|
563
|
+
rbbt.heatmap <- function(filename, data, width=800, height=800, take_log=FALSE, stdize=FALSE, ...){
|
527
564
|
opar = par()
|
528
565
|
png(filename=filename, width=width, height=height);
|
529
566
|
|
@@ -24,15 +24,13 @@ end
|
|
24
24
|
|
25
25
|
values = file.read.split("\n").collect{|v| v.to_f}
|
26
26
|
|
27
|
-
res = TmpFile.with_file do |tmp|
|
27
|
+
res = TmpFile.with_file nil, :extension => 'png' do |tmp|
|
28
28
|
R.run <<-EOF
|
29
29
|
values = #{R.ruby2R values}
|
30
30
|
d = density(values)
|
31
|
-
|
32
|
-
rbbt.tsv.write(file='#{ tmp }', df)
|
31
|
+
rbbt.png_plot(filename = '#{tmp}', 'plot(d)')
|
33
32
|
EOF
|
34
33
|
|
35
|
-
|
34
|
+
`op '#{tmp}'`
|
36
35
|
end
|
37
36
|
|
38
|
-
puts res.split("\n")[1..-1].collect{|l| l.split("\t")[1,2] * "\t"} * "\n"
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbbt-util'
|
4
|
+
require 'rbbt/util/simpleopt'
|
5
|
+
|
6
|
+
$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
|
7
|
+
|
8
|
+
options = SOPT.setup <<EOF
|
9
|
+
|
10
|
+
Produce a heatmap
|
11
|
+
|
12
|
+
$ rbbt stat heatmap [options] <filename.tsv> [file.png]
|
13
|
+
|
14
|
+
-h--help Print this help
|
15
|
+
-w--width* Image Width
|
16
|
+
-h--height* Image Height
|
17
|
+
-s--size* Image Size (Height and Width)
|
18
|
+
-l--logs Take logs
|
19
|
+
-p--positive single color heatmap (positive values
|
20
|
+
|
21
|
+
EOF
|
22
|
+
if options[:help]
|
23
|
+
if defined? rbbt_usage
|
24
|
+
rbbt_usage
|
25
|
+
else
|
26
|
+
puts SOPT.usage
|
27
|
+
end
|
28
|
+
exit 0
|
29
|
+
end
|
30
|
+
|
31
|
+
file, png = ARGV
|
32
|
+
|
33
|
+
raise "No file" if file.nil?
|
34
|
+
|
35
|
+
width, height, size, logs, positive = options.values_at :width, :height, :size, :logs, :positive
|
36
|
+
|
37
|
+
size = 800 if size.nil?
|
38
|
+
width = size if width.nil?
|
39
|
+
height = size if height.nil?
|
40
|
+
logs = false if logs.nil?
|
41
|
+
positive = false if positive.nil?
|
42
|
+
|
43
|
+
|
44
|
+
require 'rbbt/util/R'
|
45
|
+
if png
|
46
|
+
R.run <<-EOF
|
47
|
+
data = rbbt.tsv('#{file}')
|
48
|
+
rbbt.pheatmap('#{png}', data, positive=#{R.ruby2R positive})
|
49
|
+
EOF
|
50
|
+
else
|
51
|
+
TmpFile.with_file(nil, :extension => 'png') do |png|
|
52
|
+
R.run <<-EOF
|
53
|
+
data = rbbt.tsv('#{file}')
|
54
|
+
rbbt.pheatmap('#{png}', data, width=#{ width }, height=#{ height }, take_log=#{R.ruby2R logs}, positive=#{R.ruby2R positive})
|
55
|
+
EOF
|
56
|
+
`op #{png}`
|
57
|
+
end
|
58
|
+
end
|
@@ -9,8 +9,18 @@ workflow = ARGV.shift
|
|
9
9
|
wf = Workflow.require_workflow workflow
|
10
10
|
dir = $command_dir = wf.libdir.share.rbbt_commands
|
11
11
|
|
12
|
+
def prev_dir(prev)
|
13
|
+
rbbt_command_dir = $rbbt_command_dir
|
14
|
+
|
15
|
+
prev.each do |previous_command|
|
16
|
+
rbbt_command_dir = rbbt_command_dir[previous_command]
|
17
|
+
end
|
18
|
+
|
19
|
+
rbbt_command_dir
|
20
|
+
end
|
21
|
+
|
12
22
|
def commands(prev)
|
13
|
-
rbbt_command_dir =
|
23
|
+
rbbt_command_dir = prev_dir(prev)
|
14
24
|
|
15
25
|
command_file_dirs = rbbt_command_dir.find_all
|
16
26
|
command_files = command_file_dirs.collect{|d| d.glob('*') }.flatten
|
@@ -24,6 +34,9 @@ begin
|
|
24
34
|
while ARGV.any?
|
25
35
|
command = ARGV.shift
|
26
36
|
case
|
37
|
+
when File.directory?(dir[command].find)
|
38
|
+
prev << command
|
39
|
+
dir = dir[command]
|
27
40
|
when File.directory?(dir[command].find)
|
28
41
|
prev << command
|
29
42
|
dir = dir[command]
|
@@ -54,7 +67,13 @@ puts " #{File.basename($0)} #{$previous_commands * " "} cmd"
|
|
54
67
|
puts
|
55
68
|
puts Log.color :magenta, "Subcommands:"
|
56
69
|
puts
|
70
|
+
|
57
71
|
commands(prev).each do |command|
|
72
|
+
directory = File.directory? dir[command].find
|
73
|
+
if directory
|
74
|
+
puts " " << Log.color(:blue, command)
|
75
|
+
else
|
58
76
|
puts " " << command
|
77
|
+
end
|
59
78
|
end
|
60
79
|
|
data/test/rbbt/test_workflow.rb
CHANGED
@@ -222,5 +222,10 @@ class TestWorkflow < Test::Unit::TestCase
|
|
222
222
|
end
|
223
223
|
end
|
224
224
|
|
225
|
+
def test_rec_input_use
|
226
|
+
assert TestWF.rec_input_use(:double_dep).include?(:times)
|
227
|
+
assert TestWF.rec_input_use(:double_dep)[:times].include?(TestWF)
|
228
|
+
assert TestWF.rec_input_use(:double_dep)[:times][TestWF].include?(:repeat)
|
229
|
+
end
|
225
230
|
|
226
231
|
end
|
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.128
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -358,6 +358,7 @@ files:
|
|
358
358
|
- share/rbbt_commands/rsync
|
359
359
|
- share/rbbt_commands/stat/abs
|
360
360
|
- share/rbbt_commands/stat/density
|
361
|
+
- share/rbbt_commands/stat/heatmap
|
361
362
|
- share/rbbt_commands/stat/log
|
362
363
|
- share/rbbt_commands/stat/pvalue.qqplot
|
363
364
|
- share/rbbt_commands/study/maf2study
|