rbbt-util 5.6.12 → 5.6.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbbt +12 -0
- data/lib/rbbt/persist/tsv.rb +3 -3
- data/lib/rbbt/tsv/accessor.rb +12 -0
- data/lib/rbbt/util/misc.rb +8 -0
- data/share/rbbt_commands/alias +23 -0
- data/share/rbbt_commands/workflow/example +55 -0
- data/share/rbbt_commands/workflow/task +25 -4
- data/test/rbbt/tsv/test_accessor.rb +12 -0
- data/test/rbbt/util/test_misc.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b656db59e4d0eca0665f2f66988894887643c65a
|
4
|
+
data.tar.gz: ad90d4cf34155c405e418306f9376716c514db4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd6c1cf896bcbd16e00f35064b764789a0d35e6e5ef3db98d93bbe86ab55a1de92a5a72fe2c5559cfeba9cd06c645d20ec5f1a62cd4dca482a3f8f2aa9ff8678
|
7
|
+
data.tar.gz: 2909d49e91db24d697b445256475b6066bf807018394eb1560f1161fd8fd1966483db16f7c222bde72cfc54b90869a1bdf794e662bd4dd73f29ecafd3516d793
|
data/bin/rbbt
CHANGED
@@ -78,10 +78,22 @@ def print_error(error, backtrace = nil)
|
|
78
78
|
end
|
79
79
|
puts
|
80
80
|
end
|
81
|
+
|
82
|
+
def aliases
|
83
|
+
@aliases ||= Rbbt.etc.cmd_alias.exists? ? Rbbt.etc.cmd_alias.yaml : {}
|
84
|
+
end
|
85
|
+
|
86
|
+
def cmd_alias
|
87
|
+
while aliases.include? ARGV[0]
|
88
|
+
ARGV.replace Misc.parse_cmd_params(aliases[ARGV[0]]) + ARGV[1..-1]
|
89
|
+
end
|
90
|
+
end
|
81
91
|
|
82
92
|
dir = $rbbt_command_dir
|
83
93
|
prev = []
|
84
94
|
|
95
|
+
cmd_alias
|
96
|
+
|
85
97
|
begin
|
86
98
|
while ARGV.any?
|
87
99
|
command = ARGV.shift
|
data/lib/rbbt/persist/tsv.rb
CHANGED
@@ -81,15 +81,15 @@ module Persist
|
|
81
81
|
|
82
82
|
lock_filename = Persist.persistence_path(path, {:dir => TSV.lock_dir})
|
83
83
|
|
84
|
-
if is_persisted?
|
84
|
+
if is_persisted?(path) and not persist_options[:update]
|
85
85
|
Log.debug "TSV persistence up-to-date: #{ path }"
|
86
86
|
return open_database(path, false, nil, persist_options[:engine] || TokyoCabinet::HDB)
|
87
87
|
end
|
88
88
|
|
89
89
|
Misc.lock lock_filename do
|
90
90
|
begin
|
91
|
-
if is_persisted?
|
92
|
-
Log.debug "TSV persistence up-to-date: #{ path }"
|
91
|
+
if is_persisted?(path) and not persist_options[:update]
|
92
|
+
Log.debug "TSV persistence (suddenly) up-to-date: #{ path }"
|
93
93
|
return open_database(path, false, nil, persist_options[:engine] || TokyoCabinet::HDB)
|
94
94
|
end
|
95
95
|
|
data/lib/rbbt/tsv/accessor.rb
CHANGED
@@ -193,6 +193,18 @@ module TSV
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
|
+
def zip_new(key, values)
|
197
|
+
if self.include? key
|
198
|
+
new = []
|
199
|
+
self[key, true].each_with_index do |v,i|
|
200
|
+
new << (v << values[i])
|
201
|
+
end
|
202
|
+
self[key] == new
|
203
|
+
else
|
204
|
+
self[key] = values.collect{|v| [v] }
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
196
208
|
def keys
|
197
209
|
keys = super - ENTRY_KEYS.to_a
|
198
210
|
return keys if @unnamed or key_field.nil?
|
data/lib/rbbt/util/misc.rb
CHANGED
@@ -29,6 +29,14 @@ end
|
|
29
29
|
Lockfile.refresh = false if ENV["RBBT_NO_LOCKFILE_REFRESH"] == "true"
|
30
30
|
module Misc
|
31
31
|
|
32
|
+
def self.parse_cmd_params(str)
|
33
|
+
return str if Array === str
|
34
|
+
str.scan(/
|
35
|
+
(?:["']([^"']*?)["']) |
|
36
|
+
([^"'\s]+)
|
37
|
+
/x).flatten.compact
|
38
|
+
end
|
39
|
+
|
32
40
|
def self.correct_icgc_mutation(pos, ref, mut_str)
|
33
41
|
mut = mut_str
|
34
42
|
mut = '-' * (mut_str.length - 1) if mut =~/^-[ACGT]/
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbbt'
|
4
|
+
|
5
|
+
|
6
|
+
cmd, *rest = ARGV
|
7
|
+
|
8
|
+
aliases ||= Rbbt.etc.cmd_alias.exists? ? Rbbt.etc.cmd_alias.yaml : {}
|
9
|
+
|
10
|
+
if cmd.nil?
|
11
|
+
require 'pp'
|
12
|
+
pp aliases
|
13
|
+
exit 0
|
14
|
+
end
|
15
|
+
|
16
|
+
if rest.empty?
|
17
|
+
aliases.delete cmd
|
18
|
+
else
|
19
|
+
aliases[cmd] = rest
|
20
|
+
end
|
21
|
+
|
22
|
+
Open.write(Rbbt.etc.cmd_alias.find,(aliases.to_yaml))
|
23
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbbt/util/simpleopt'
|
4
|
+
require 'rbbt/workflow'
|
5
|
+
require 'rbbt/workflow/usage'
|
6
|
+
|
7
|
+
def run_task(workflow, task, name)
|
8
|
+
Log.info "Running example #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
|
9
|
+
|
10
|
+
example_dir = workflow.libdir.examples[task][name].find
|
11
|
+
Log.debug "Using #{example_dir}"
|
12
|
+
|
13
|
+
ARGV.replace([workflow.to_s, task, '--load_inputs', example_dir, '--jobname', name,'--O','/dev/null'] + $saved_args)
|
14
|
+
|
15
|
+
@pid = Process.fork{
|
16
|
+
load Rbbt.share.rbbt_commands.workflow.task.find
|
17
|
+
}
|
18
|
+
Signal.trap(:INT) do
|
19
|
+
begin
|
20
|
+
Process.kill "INT", @pid
|
21
|
+
ensure
|
22
|
+
exit -1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
Process.wait @pid
|
26
|
+
|
27
|
+
if $?.success?
|
28
|
+
Log.info "#{Log.color :green, "SUCCESS"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
|
29
|
+
else
|
30
|
+
Log.info "#{Log.color :red, "ERROR"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
workflow = ARGV.shift
|
35
|
+
raise ParameterException if workflow.nil?
|
36
|
+
|
37
|
+
task = ARGV.shift
|
38
|
+
task = nil if task == '--'
|
39
|
+
|
40
|
+
name = ARGV.shift if task
|
41
|
+
name = nil if name == '--'
|
42
|
+
|
43
|
+
$saved_args = ARGV.dup
|
44
|
+
|
45
|
+
|
46
|
+
workflow = Workflow.require_workflow workflow
|
47
|
+
|
48
|
+
tasks = task ? [task] : workflow.libdir.examples.glob('*').collect{|file| File.basename file }
|
49
|
+
|
50
|
+
tasks.each do |task|
|
51
|
+
names = name ? [name] : workflow.libdir.examples[task].glob('*').collect{|file| File.basename file }
|
52
|
+
names.each do |name|
|
53
|
+
run_task workflow, task, name
|
54
|
+
end
|
55
|
+
end
|
@@ -9,17 +9,30 @@ def load_inputs(dir, task)
|
|
9
9
|
dir = Path.setup(dir.dup)
|
10
10
|
task.inputs.each do |input|
|
11
11
|
file = dir[input].find
|
12
|
+
Log.debug "Trying #{ input }: #{file}"
|
12
13
|
next unless file.exists?
|
13
14
|
case task.input_types[input]
|
14
15
|
when :tsv, :array, :text
|
16
|
+
Log.debug "Pointing #{ input } to #{file}"
|
15
17
|
inputs[input.to_sym] = file
|
16
18
|
else
|
19
|
+
Log.debug "Loading #{ input } from #{file}"
|
17
20
|
inputs[input.to_sym] = file.read
|
18
21
|
end
|
19
22
|
end
|
20
23
|
inputs
|
21
24
|
end
|
22
25
|
|
26
|
+
def report_options(options)
|
27
|
+
if options.nil? or options.empty?
|
28
|
+
puts "No options"
|
29
|
+
else
|
30
|
+
options.each do |key, value|
|
31
|
+
puts [Log.color(:cyan, key), Misc.fingerprint(value)] * ": "
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
23
36
|
def usage(workflow = nil, task = nil, exception=nil)
|
24
37
|
puts SOPT.doc
|
25
38
|
puts Log.color :magenta, "## WORKFLOW"
|
@@ -42,7 +55,8 @@ def usage(workflow = nil, task = nil, exception=nil)
|
|
42
55
|
end
|
43
56
|
|
44
57
|
print_error(exception.message, exception.backtrace) if exception
|
45
|
-
|
58
|
+
|
59
|
+
true
|
46
60
|
end
|
47
61
|
|
48
62
|
def SOPT_options(workflow, task)
|
@@ -135,7 +149,7 @@ options = SOPT.get <<EOF
|
|
135
149
|
EOF
|
136
150
|
|
137
151
|
workflow = ARGV.shift
|
138
|
-
usage if workflow.nil?
|
152
|
+
usage and exit -1 if workflow.nil?
|
139
153
|
|
140
154
|
task = ARGV.shift
|
141
155
|
|
@@ -171,7 +185,7 @@ namespace = nil, nil
|
|
171
185
|
|
172
186
|
case
|
173
187
|
when task.nil?
|
174
|
-
usage workflow
|
188
|
+
usage workflow and exit 0
|
175
189
|
# Can not remember what this was
|
176
190
|
#when (task =~ /\./)
|
177
191
|
# namespace, task = options.delete(:task).split('.')
|
@@ -182,7 +196,7 @@ else
|
|
182
196
|
raise ParameterException, "Task not found: #{ task_name }" if task.nil?
|
183
197
|
end
|
184
198
|
|
185
|
-
usage workflow, task if help
|
199
|
+
usage workflow, task and exit 0 if help
|
186
200
|
|
187
201
|
name = options.delete(:jobname) || "Default"
|
188
202
|
|
@@ -194,6 +208,7 @@ else
|
|
194
208
|
job_options = SOPT.get sopt_option_string
|
195
209
|
end
|
196
210
|
job_options = fix_options(workflow, task, job_options)
|
211
|
+
saved_job_options = job_options
|
197
212
|
|
198
213
|
workflow.workdir = Path.setup(File.expand_path(options.delete(:workdir))) if options[:workdir]
|
199
214
|
|
@@ -222,6 +237,7 @@ begin
|
|
222
237
|
pp job.info
|
223
238
|
exit 0
|
224
239
|
end
|
240
|
+
|
225
241
|
if do_exec
|
226
242
|
res = job.exec
|
227
243
|
case
|
@@ -265,6 +281,11 @@ begin
|
|
265
281
|
rescue ParameterException
|
266
282
|
SOPT.delete_inputs(workflow.rec_inputs(task.name))
|
267
283
|
usage(workflow, task, $!)
|
284
|
+
puts Log.color :magenta, "Options:"
|
285
|
+
puts
|
286
|
+
report_options saved_job_options
|
287
|
+
puts
|
288
|
+
exit -1
|
268
289
|
end
|
269
290
|
|
270
291
|
|
@@ -19,6 +19,18 @@ row2 A B Id3
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def test_zip_new
|
23
|
+
content =<<-EOF
|
24
|
+
#Id ValueA ValueB OtherID
|
25
|
+
row1 a|aa|aaa b|bb|bbb Id1|Id2|Id3
|
26
|
+
EOF
|
27
|
+
|
28
|
+
TmpFile.with_file(content) do |filename|
|
29
|
+
tsv = TSV.open(filename, :sep => /\s+/)
|
30
|
+
tsv.zip_new("row1", %w(aaaa bbbb Id4))
|
31
|
+
assert_equal %w(b bb bbb bbbb), tsv["row1"]["ValueB"]
|
32
|
+
end
|
33
|
+
end
|
22
34
|
|
23
35
|
def test_tsv
|
24
36
|
content =<<-EOF
|
data/test/rbbt/util/test_misc.rb
CHANGED
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.13
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- share/Rlib/util.R
|
202
202
|
- share/config.ru
|
203
203
|
- share/install/software/lib/install_helpers
|
204
|
+
- share/rbbt_commands/alias
|
204
205
|
- share/rbbt_commands/app/install
|
205
206
|
- share/rbbt_commands/app/start
|
206
207
|
- share/rbbt_commands/app/template
|
@@ -225,6 +226,7 @@ files:
|
|
225
226
|
- share/rbbt_commands/tsv/unzip
|
226
227
|
- share/rbbt_commands/tsv/values
|
227
228
|
- share/rbbt_commands/workflow/cmd
|
229
|
+
- share/rbbt_commands/workflow/example
|
228
230
|
- share/rbbt_commands/workflow/install
|
229
231
|
- share/rbbt_commands/workflow/list
|
230
232
|
- share/rbbt_commands/workflow/monitor
|