rbbt-util 5.6.5 → 5.6.6
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/bin/rbbt +1 -1
- data/lib/rbbt/tsv.rb +1 -1
- data/lib/rbbt/util/misc.rb +13 -0
- data/lib/rbbt/workflow.rb +48 -21
- data/lib/rbbt/workflow/accessor.rb +18 -4
- data/lib/rbbt/workflow/step.rb +9 -3
- data/lib/rbbt/workflow/task.rb +0 -1
- data/share/rbbt_commands/system/report +8 -3
- data/share/rbbt_commands/tsv/attach +1 -0
- data/share/rbbt_commands/tsv/info +11 -5
- data/share/rbbt_commands/workflow/list +31 -0
- data/test/rbbt/test_workflow.rb +2 -0
- data/test/rbbt/util/test_misc.rb +8 -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: dfcdf5fe55d3a3ddb6a46648fd5a7d378b2eb692
|
4
|
+
data.tar.gz: f7a1a8275c767cb3347e3ac8856be2353014f4f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2caa0e4bb980ef419ba0390c2d2b34eec883e88f71e24979e837b3e2720198f5ea7a1dc053583fa0941a8e3071d3a31e7db897fd0fec03cf8f64664d3e119924
|
7
|
+
data.tar.gz: c51c7c567113673fca18fa95dae7bf2722e6a0d0bdd75f5236fa4fd2a89109bfa72a3fc648d212540ebf4c2d89e4f5435afdd01a66ca9b060e44a386aa82afce
|
data/bin/rbbt
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'rbbt'
|
4
4
|
require 'rbbt/util/simpleopt'
|
5
5
|
|
6
|
-
options = SOPT.get("--log* Log level from 0 (debug) 6 (errors)
|
6
|
+
options = SOPT.get("--log* Log level from 0 (debug) 6 (errors):-cd--command_dir* Directory from where to load commands:--profile Profile execution")
|
7
7
|
|
8
8
|
if options[:log]
|
9
9
|
Log.severity = options[:log].to_i
|
data/lib/rbbt/tsv.rb
CHANGED
@@ -96,7 +96,7 @@ module TSV
|
|
96
96
|
stream.open do |f|
|
97
97
|
Parser.new f, options
|
98
98
|
end
|
99
|
-
when (String === stream and stream.length < 300 and Open.exists? stream or Open.remote? stream)
|
99
|
+
when (String === stream and stream.length < 300 and (Open.exists? stream or Open.remote? stream))
|
100
100
|
Open.open(stream) do |f|
|
101
101
|
Parser.new f, options
|
102
102
|
end
|
data/lib/rbbt/util/misc.rb
CHANGED
@@ -1366,6 +1366,19 @@ end
|
|
1366
1366
|
array[0].zip(*array[1..-1])
|
1367
1367
|
end
|
1368
1368
|
|
1369
|
+
def self.camel_case(string)
|
1370
|
+
return string if string !~ /_/ && string =~ /[A-Z]+.*/
|
1371
|
+
string.split(/_|(\d+)/).map{|e|
|
1372
|
+
(e =~ /^[A-Z]{2,}$/ ? e : e.capitalize)
|
1373
|
+
}.join
|
1374
|
+
end
|
1375
|
+
|
1376
|
+
def self.camel_case_lower(string)
|
1377
|
+
string.split('_').inject([]){ |buffer,e|
|
1378
|
+
buffer.push(buffer.empty? ? e.downcase : (e =~ /^[A-Z]{2,}$/ ? e : e.capitalize))
|
1379
|
+
}.join
|
1380
|
+
end
|
1381
|
+
|
1369
1382
|
def self.snake_case(string)
|
1370
1383
|
return nil if string.nil?
|
1371
1384
|
string = string.to_s if Symbol === string
|
data/lib/rbbt/workflow.rb
CHANGED
@@ -37,6 +37,19 @@ module Workflow
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
def self.workflow_dir
|
41
|
+
case
|
42
|
+
when (defined?(Rbbt) and Rbbt.etc.workflow_dir.exists?)
|
43
|
+
dir = Rbbt.etc.workflow_dir.read.strip
|
44
|
+
Path.setup(dir)
|
45
|
+
when defined?(Rbbt)
|
46
|
+
Rbbt.workflows
|
47
|
+
else
|
48
|
+
dir = File.join(ENV['HOME'], '.workflows')
|
49
|
+
Path.setup(dir)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
40
53
|
def self.require_local_workflow(wf_name)
|
41
54
|
filename = nil
|
42
55
|
|
@@ -52,21 +65,27 @@ module Workflow
|
|
52
65
|
end
|
53
66
|
|
54
67
|
else
|
55
|
-
|
56
|
-
# Points to workflow file
|
57
|
-
when ((File.exists?(wf_name) and not File.directory?(wf_name)) or File.exists?(wf_name + '.rb'))
|
68
|
+
if ((File.exists?(wf_name) and not File.directory?(wf_name)) or File.exists?(wf_name + '.rb'))
|
58
69
|
filename = (wf_name =~ /\.?\//) ? wf_name : "./" << wf_name
|
59
|
-
when (defined?(Rbbt) and Rbbt.etc.workflow_dir.exists?)
|
60
|
-
dir = Rbbt.etc.workflow_dir.read.strip
|
61
|
-
dir = File.join(dir, wf_name)
|
62
|
-
filename = File.join(dir, 'workflow.rb')
|
63
|
-
when defined?(Rbbt)
|
64
|
-
path = Rbbt.workflows[wf_name].find
|
65
|
-
filename = File.join(path, 'workflow.rb')
|
66
70
|
else
|
67
|
-
|
68
|
-
filename = File.join(dir, 'workflow.rb')
|
71
|
+
filename = workflow_dir[wf_name]['workflow.rb'].find
|
69
72
|
end
|
73
|
+
|
74
|
+
#case
|
75
|
+
# # Points to workflow file
|
76
|
+
#when ((File.exists?(wf_name) and not File.directory?(wf_name)) or File.exists?(wf_name + '.rb'))
|
77
|
+
# filename = (wf_name =~ /\.?\//) ? wf_name : "./" << wf_name
|
78
|
+
#when (defined?(Rbbt) and Rbbt.etc.workflow_dir.exists?)
|
79
|
+
# dir = Rbbt.etc.workflow_dir.read.strip
|
80
|
+
# dir = File.join(dir, wf_name)
|
81
|
+
# filename = File.join(dir, 'workflow.rb')
|
82
|
+
#when defined?(Rbbt)
|
83
|
+
# path = Rbbt.workflows[wf_name].find
|
84
|
+
# filename = File.join(path, 'workflow.rb')
|
85
|
+
#else
|
86
|
+
# path = File.join(ENV['HOME'], '.workflows', wf_name)
|
87
|
+
# filename = File.join(dir, 'workflow.rb')
|
88
|
+
#end
|
70
89
|
end
|
71
90
|
|
72
91
|
if filename and File.exists? filename
|
@@ -119,6 +138,11 @@ module Workflow
|
|
119
138
|
attr_accessor :asynchronous_exports, :synchronous_exports, :exec_exports
|
120
139
|
|
121
140
|
#{{{ ATTR DEFAULTS
|
141
|
+
|
142
|
+
def workdir=(path)
|
143
|
+
path = Path.setup path.dup unless Path === path
|
144
|
+
@workdir = path
|
145
|
+
end
|
122
146
|
|
123
147
|
def workdir
|
124
148
|
@workdir ||= if defined? Rbbt
|
@@ -239,16 +263,19 @@ module Workflow
|
|
239
263
|
step
|
240
264
|
end
|
241
265
|
|
242
|
-
def
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
path = File.join(task_dir, query + "*.info")
|
248
|
-
end
|
266
|
+
def load_name(task, name)
|
267
|
+
task = tasks[task.to_sym] if String === task or Symbol === task
|
268
|
+
path = step_path task.name, name, [], [], task.extension
|
269
|
+
Step.new path, task
|
270
|
+
end
|
249
271
|
|
250
|
-
|
251
|
-
|
272
|
+
def jobs(taskname, query = nil)
|
273
|
+
task_dir = File.join(workdir.find, taskname.to_s)
|
274
|
+
pattern = File.join(task_dir, '**/*')
|
275
|
+
job_info_files = Dir.glob(Step.info_file(pattern)).collect{|f| Misc.path_relative_to task_dir, f }
|
276
|
+
job_info_files = job_info_files.select{|f| f.index(query) == 0 } if query
|
277
|
+
job_info_files.collect{|f|
|
278
|
+
job_name = Step.job_name_for_info_file(f, tasks[taskname].extension)
|
252
279
|
}
|
253
280
|
end
|
254
281
|
|
@@ -5,6 +5,22 @@ class Step
|
|
5
5
|
|
6
6
|
INFO_SERIALIAZER = Marshal
|
7
7
|
|
8
|
+
def self.files_dir(path)
|
9
|
+
path.nil? ? nil : path + '.files'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.info_file(path)
|
13
|
+
path.nil? ? nil : path + '.info'
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.job_name_for_info_file(info_file, extension = nil)
|
17
|
+
if extension and not extension.empty?
|
18
|
+
info_file.sub(/\.#{extension}\.info$/,'')
|
19
|
+
else
|
20
|
+
info_file.sub(/\.info$/,'')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
8
24
|
def name
|
9
25
|
path.sub(/.*\/#{Regexp.quote task.name.to_s}\/(.*)/, '\1')
|
10
26
|
end
|
@@ -20,9 +36,7 @@ class Step
|
|
20
36
|
# {{{ INFO
|
21
37
|
|
22
38
|
def info_file
|
23
|
-
@info_file ||=
|
24
|
-
path.nil? ? nil : path + '.info'
|
25
|
-
end
|
39
|
+
@info_file ||= Step.info_file(path)
|
26
40
|
end
|
27
41
|
|
28
42
|
def info
|
@@ -117,7 +131,7 @@ class Step
|
|
117
131
|
# {{{ INFO
|
118
132
|
|
119
133
|
def files_dir
|
120
|
-
|
134
|
+
@files_dir ||= Step.files_dir path
|
121
135
|
end
|
122
136
|
|
123
137
|
def files
|
data/lib/rbbt/workflow/step.rb
CHANGED
@@ -92,8 +92,7 @@ class Step
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def checks
|
95
|
-
|
96
|
-
deps.select!{|p| p.exists? }
|
95
|
+
rec_dependencies.collect{|dependency| dependency.path }.uniq
|
97
96
|
end
|
98
97
|
|
99
98
|
def run(no_load = false)
|
@@ -276,7 +275,14 @@ class Step
|
|
276
275
|
end
|
277
276
|
|
278
277
|
def rec_dependencies
|
279
|
-
|
278
|
+
|
279
|
+
# A step result with no info_file means that it was manually
|
280
|
+
# placed. In that case, do not consider its dependencies
|
281
|
+
return [] if self.done? and not Open.exists? self.info_file
|
282
|
+
|
283
|
+
@dependencies.collect{|step|
|
284
|
+
step.rec_dependencies
|
285
|
+
}.flatten.concat @dependencies
|
280
286
|
end
|
281
287
|
|
282
288
|
def recursive_clean
|
data/lib/rbbt/workflow/task.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
options = SOPT.get("-a--app*")
|
3
|
+
options = SOPT.get("-a--app* Apps to add:-wd--workdir* Workflow workdir:-h--help Help")
|
4
4
|
|
5
|
-
|
5
|
+
if options[:help]
|
6
|
+
puts SOPT.doc
|
7
|
+
exit 0
|
8
|
+
end
|
9
|
+
|
10
|
+
workflow_dir = options[:workdir] || Rbbt.var.jobs.find
|
6
11
|
|
7
12
|
def report_jobs(workflow_dir, title = "WORKFLOW")
|
8
13
|
error = {}
|
@@ -50,7 +55,7 @@ end if options[:app]
|
|
50
55
|
|
51
56
|
puts <<EOF
|
52
57
|
|
53
|
-
#{ report_jobs
|
58
|
+
#{ report_jobs workflow_dir}
|
54
59
|
#{ app_dirs.collect{|d,report| report } * "\n" }
|
55
60
|
|
56
61
|
# LOCKED TSV
|
@@ -3,7 +3,10 @@
|
|
3
3
|
require 'rbbt-util'
|
4
4
|
require 'rbbt/util/simpleopt'
|
5
5
|
|
6
|
-
options = SOPT.get("-tch--tokyocabinet:-tcb--tokyocabinet_bd")
|
6
|
+
options = SOPT.get("-tch--tokyocabinet:-tcb--tokyocabinet_bd:-t--type*:-h--header_hash*:-k--key_field*:-f--fields*")
|
7
|
+
|
8
|
+
options[:fields] = options[:fields].split(/,\|/) if options[:fields]
|
9
|
+
options[:header_hash] = options["header_hash"]
|
7
10
|
|
8
11
|
file = ARGV.shift
|
9
12
|
|
@@ -19,16 +22,19 @@ when options[:tokyocabinet_bd]
|
|
19
22
|
tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB)
|
20
23
|
puts tsv.summary
|
21
24
|
else
|
22
|
-
header = TSV.parse_header(Open.open(file))
|
25
|
+
header = TSV.parse_header(Open.open(file), options)
|
23
26
|
|
24
27
|
puts "File: #{ file }"
|
25
28
|
puts "Type: #{header.type}"
|
26
29
|
puts "Key: #{header.key_field}"
|
27
30
|
puts "Fields: "
|
28
|
-
header.fields.
|
29
|
-
|
31
|
+
if header.fields.nil?
|
32
|
+
else
|
33
|
+
header.fields.each_with_index do |f,i|
|
34
|
+
puts " - #{i + 1}: " << f
|
35
|
+
end
|
30
36
|
end
|
31
|
-
puts "Rows: #{`wc -l #{ file }|cut -f 1 -d' '`}"
|
37
|
+
puts "Rows: #{`wc -l #{ file }|cut -f 1 -d' '`}" unless Open.remote? file
|
32
38
|
puts "First line:"
|
33
39
|
parts = []
|
34
40
|
header.first_line.split(header.sep).each_with_index{|p,i| parts << "(#{i}) #{p}"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbbt-util'
|
4
|
+
require 'rbbt/workflow'
|
5
|
+
require 'rbbt/util/simpleopt'
|
6
|
+
|
7
|
+
options = SOPT.get('-wd--workflow_dir*:-d--describe')
|
8
|
+
|
9
|
+
workflow_dir = options[:workflow_dir] || Workflow.workflow_dir
|
10
|
+
|
11
|
+
Path.setup(workflow_dir) unless Path === workflow_dir
|
12
|
+
|
13
|
+
files = workflow_dir.find_all.collect{|p| p.glob("*") }.flatten.select{|f| File.directory? f }
|
14
|
+
|
15
|
+
puts defined? COSMIC
|
16
|
+
if options[:describe]
|
17
|
+
files.each do |file|
|
18
|
+
workflow = File.basename(file)
|
19
|
+
Workflow.require_workflow workflow
|
20
|
+
ddd Workflow.workflows
|
21
|
+
workflow = Workflow.workflows.select{|w| Misc.camel_case(w.to_s) == Misc.camel_case(workflow)}.first
|
22
|
+
ddd workflow
|
23
|
+
puts [Misc.camel_case(workflow.to_s), workflow.description] * ":"
|
24
|
+
puts defined? COSMIC
|
25
|
+
end
|
26
|
+
else
|
27
|
+
files.each do |file|
|
28
|
+
workflow = File.basename(file)
|
29
|
+
puts Misc.camel_case(workflow.to_s)
|
30
|
+
end
|
31
|
+
end
|
data/test/rbbt/test_workflow.rb
CHANGED
@@ -106,6 +106,8 @@ class TestWorkflow < Test::Unit::TestCase
|
|
106
106
|
assert TestWF.jobs(:repeat2).include?(job1.name)
|
107
107
|
assert TestWF.jobs(:repeat2).include?(job2.name)
|
108
108
|
assert TestWF.jobs(:repeat2).include?(job3.name)
|
109
|
+
assert TestWF.load_name(:repeat2, TestWF.jobs(:repeat2).first).done?
|
110
|
+
assert_equal "TEST\nTEST\nTEST\nTEST\nTEST\nTEST", TestWF.load_name(:repeat2, TestWF.jobs(:repeat2).first).load
|
109
111
|
end
|
110
112
|
|
111
113
|
def test_double_dep
|
data/test/rbbt/util/test_misc.rb
CHANGED
@@ -254,6 +254,14 @@ class TestMisc < Test::Unit::TestCase
|
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
|
+
def test_camel_case
|
258
|
+
assert_equal "DbSNP", Misc.camel_case("db_SNP")
|
259
|
+
assert_equal "D3Js", Misc.camel_case("D3Js")
|
260
|
+
assert_equal "Structure", Misc.camel_case("Structure")
|
261
|
+
assert_equal "MutEval", Misc.camel_case("mut_eval")
|
262
|
+
assert_equal "COSMIC", Misc.camel_case("COSMIC")
|
263
|
+
end
|
264
|
+
|
257
265
|
def test_pipe
|
258
266
|
t = 5
|
259
267
|
stream = Misc.open_pipe do |sin|
|
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.6.
|
4
|
+
version: 5.6.6
|
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-02-
|
11
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -239,6 +239,7 @@ files:
|
|
239
239
|
- share/rbbt_commands/tsv/values
|
240
240
|
- share/rbbt_commands/workflow/cmd
|
241
241
|
- share/rbbt_commands/workflow/install
|
242
|
+
- share/rbbt_commands/workflow/list
|
242
243
|
- share/rbbt_commands/workflow/monitor
|
243
244
|
- share/rbbt_commands/workflow/remote/add
|
244
245
|
- share/rbbt_commands/workflow/remote/list
|