rbbt-util 5.40.4 → 5.41.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/persist.rb +2 -2
- data/lib/rbbt/resource/path.rb +10 -1
- data/lib/rbbt/util/migrate.rb +1 -0
- data/lib/rbbt/util/misc/omics.rb +9 -1
- data/lib/rbbt/workflow/dependencies.rb +16 -10
- data/lib/rbbt/workflow/doc.rb +1 -1
- data/lib/rbbt/workflow/step/accessor.rb +15 -0
- data/lib/rbbt/workflow/step/info.rb +5 -1
- data/lib/rbbt/workflow/step.rb +0 -3
- data/lib/rbbt/workflow.rb +3 -1
- data/python/{rbbt.py → rbbt/__init__.py} +32 -3
- data/share/rbbt_commands/tsv/write_excel +4 -3
- data/share/rbbt_commands/workflow/cmd +8 -3
- data/share/rbbt_commands/workflow/info +1 -0
- data/share/workflow_config.ru +11 -1
- data/test/rbbt/util/misc/test_omics.rb +1 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8c020988e2d5df3aa710ce88fe4d92a2a754363d924a580fcc31b138330258
|
4
|
+
data.tar.gz: b6ee155b7bfb819baa21fac27c8561a3e1332bd9677a081abbe811bbb45c7973
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16d876542942fd0a0e1982dee1e7bf94ccd7bf8c8f4e3bb5310588a2f4587a3abe6d56fb101e1e1352c12225de507d46c18fa6b9109b2328079a999142479fa9
|
7
|
+
data.tar.gz: 6d135e37aa6151b68552a5c9f32f3cc1f1fef20a3f26695c9a033a09e0541a31a60de9b2fac33aea4c69e89a1acff54296264ba8435e9fecdaed5dcd5ee868fb
|
data/lib/rbbt/persist.rb
CHANGED
@@ -412,9 +412,9 @@ module Persist
|
|
412
412
|
repo.delete path if persist_options[:update]
|
413
413
|
repo[path] ||= yield
|
414
414
|
|
415
|
-
when (type.to_sym == :annotations and persist_options.include?
|
415
|
+
when (type.to_sym == :annotations and (persist_options.include?(:annotation_repo) || persist_options.include?(:repo)))
|
416
416
|
|
417
|
-
repo = persist_options[:annotation_repo]
|
417
|
+
repo = persist_options[:annotation_repo] || persist_options[:repo]
|
418
418
|
|
419
419
|
keys = nil
|
420
420
|
subkey = name + ":"
|
data/lib/rbbt/resource/path.rb
CHANGED
@@ -359,7 +359,16 @@ module Path
|
|
359
359
|
end
|
360
360
|
|
361
361
|
def list
|
362
|
-
|
362
|
+
begin
|
363
|
+
path = self.produce
|
364
|
+
rescue Resource::ResourceNotFound => e
|
365
|
+
begin
|
366
|
+
path = self.set_extension('list').produce
|
367
|
+
rescue Resource::ResourceNotFound
|
368
|
+
raise e
|
369
|
+
end
|
370
|
+
end
|
371
|
+
Open.read(path).split("\n")
|
363
372
|
end
|
364
373
|
|
365
374
|
def keys(field = 0, sep = "\t")
|
data/lib/rbbt/util/migrate.rb
CHANGED
data/lib/rbbt/util/misc/omics.rb
CHANGED
@@ -251,12 +251,20 @@ module Misc
|
|
251
251
|
end
|
252
252
|
|
253
253
|
def self.translate_prot_mutation_hgvs2rbbt(mutation)
|
254
|
+
mutation.sub!('p.', '')
|
255
|
+
if m = mutation.match(/([a-z]{3})(\d+)([a-z]{3})/i)
|
256
|
+
ref = m[1]
|
257
|
+
num = m[2]
|
258
|
+
alt = m[3]
|
259
|
+
ref = THREE_TO_ONE_AA_CODE[ref.downcase]
|
260
|
+
alt = THREE_TO_ONE_AA_CODE[alt.downcase]
|
261
|
+
mutation = [ref, num, alt] * ""
|
262
|
+
end
|
254
263
|
one_aa_code = THREE_TO_ONE_AA_CODE.values
|
255
264
|
one_aa_code << "X" << "B" << "Z" << "J" << "*" << "?"
|
256
265
|
one_aa_code_re = one_aa_code*""
|
257
266
|
subs = Regexp.new("^[#{one_aa_code_re}]\\d+[#{one_aa_code_re}]")
|
258
267
|
f_aa = Regexp.new("^[#{one_aa_code_re}]\\d+")
|
259
|
-
mutation.sub!('p.', '')
|
260
268
|
mutation = case
|
261
269
|
when mutation =~ subs
|
262
270
|
mutation
|
@@ -165,7 +165,8 @@ module Workflow
|
|
165
165
|
workflow, dep_task, options = dependency
|
166
166
|
|
167
167
|
if override_dependencies[workflow.to_s] && value = override_dependencies[workflow.to_s][dep_task]
|
168
|
-
overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
168
|
+
overriden = true if (inputs.nil? || ! inputs[:not_overriden]) && (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
169
|
+
#overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
169
170
|
setup_override_dependency(value, workflow, dep_task)
|
170
171
|
else
|
171
172
|
|
@@ -189,21 +190,23 @@ module Workflow
|
|
189
190
|
job = workflow._job(dep_task, jobname, _inputs)
|
190
191
|
ComputeDependency.setup(job, compute) if compute
|
191
192
|
|
192
|
-
overriden = true if
|
193
|
+
overriden = true if Symbol === job.overriden? && (d.nil? || ! d[:not_overriden]) && (inputs.nil? || ! inputs[:not_overriden])
|
193
194
|
|
194
195
|
job
|
195
196
|
end
|
196
197
|
when Step
|
197
198
|
job = dependency
|
198
|
-
overriden = true if
|
199
|
+
overriden = true if Symbol === job.overriden? && (d.nil? || ! d[:not_overriden]) && (inputs.nil? || ! inputs[:not_overriden])
|
199
200
|
job
|
200
201
|
when Symbol
|
201
202
|
if override_dependencies[self.to_s] && value = override_dependencies[self.to_s][dependency]
|
202
|
-
overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
203
|
+
overriden = true if (inputs.nil? || ! inputs[:not_overriden]) && (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
204
|
+
#overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
203
205
|
setup_override_dependency(value, self, dependency)
|
204
206
|
else
|
205
207
|
job = _job(dependency, jobname, _inputs)
|
206
|
-
overriden = true if
|
208
|
+
overriden = true if Symbol === job.overriden && (options.nil? || ! options[:not_overriden]) && (inputs.nil? || ! inputs[:not_overriden])
|
209
|
+
|
207
210
|
job
|
208
211
|
end
|
209
212
|
when Proc
|
@@ -212,7 +215,8 @@ module Workflow
|
|
212
215
|
wf, task_name, options = orig_dep
|
213
216
|
|
214
217
|
if override_dependencies[wf.to_s] && value = override_dependencies[wf.to_s][task_name]
|
215
|
-
overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
218
|
+
overriden = true if (inputs.nil? || ! inputs[:not_overriden]) && (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
219
|
+
#overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
216
220
|
dep = setup_override_dependency(value, wf, task_name)
|
217
221
|
else
|
218
222
|
|
@@ -243,7 +247,8 @@ module Workflow
|
|
243
247
|
d[:task] ||= task_name
|
244
248
|
_override_dependencies = override_dependencies.merge(override_dependencies(d[:inputs] || {}))
|
245
249
|
d = if _override_dependencies[d[:workflow].to_s] && value = _override_dependencies[d[:workflow].to_s][d[:task]]
|
246
|
-
overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
250
|
+
overriden = true if (inputs.nil? || ! inputs[:not_overriden]) && (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
251
|
+
#overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
247
252
|
setup_override_dependency(value, d[:workflow], d[:task])
|
248
253
|
else
|
249
254
|
task_info = d[:workflow].task_info(d[:task])
|
@@ -251,7 +256,7 @@ module Workflow
|
|
251
256
|
_inputs = assign_dep_inputs({}, options.merge(d[:inputs] || {}), real_dependencies, task_info)
|
252
257
|
_jobname = d.include?(:jobname) ? d[:jobname] : jobname
|
253
258
|
job = d[:workflow]._job(d[:task], _jobname, _inputs)
|
254
|
-
overriden = true if
|
259
|
+
overriden = true if Symbol === job.overriden? && (d.nil? || ! d[:not_overriden]) && (inputs.nil? || ! inputs[:not_overriden])
|
255
260
|
job
|
256
261
|
end
|
257
262
|
end
|
@@ -267,14 +272,15 @@ module Workflow
|
|
267
272
|
dep[:workflow] ||= wf || self
|
268
273
|
_override_dependencies = override_dependencies.merge(override_dependencies(dep[:inputs] || {}))
|
269
274
|
if _override_dependencies[dep[:workflow].to_s] && value = _override_dependencies[dep[:workflow].to_s][dep[:task]]
|
270
|
-
overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
275
|
+
overriden = true if (inputs.nil? || ! inputs[:not_overriden]) && (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
276
|
+
#overriden = true if (options.nil? || ! options[:not_overriden]) && ! unlocated_override?(value)
|
271
277
|
setup_override_dependency(value, dep[:workflow], dep[:task])
|
272
278
|
else
|
273
279
|
task_info = (dep[:task] && dep[:workflow]) ? dep[:workflow].task_info(dep[:task]) : nil
|
274
280
|
_inputs = assign_dep_inputs({}, dep[:inputs], real_dependencies, task_info)
|
275
281
|
_jobname = dep.include?(:jobname) ? dep[:jobname] : jobname
|
276
282
|
job = dep[:workflow]._job(dep[:task], _jobname, _inputs)
|
277
|
-
overriden = true if
|
283
|
+
overriden = true if Symbol === job.overriden? && (d.nil? || ! d[:not_overriden]) && (inputs.nil? || ! inputs[:not_overriden])
|
278
284
|
job
|
279
285
|
end
|
280
286
|
end
|
data/lib/rbbt/workflow/doc.rb
CHANGED
@@ -30,7 +30,7 @@ module Workflow
|
|
30
30
|
title = doc_parse_first_line doc
|
31
31
|
description, task_info = doc_parse_up_to doc, /^# Tasks/i
|
32
32
|
task_description, tasks = doc_parse_up_to task_info, /^##/, true
|
33
|
-
tasks = doc_parse_chunks tasks,
|
33
|
+
tasks = doc_parse_chunks tasks, /^## (.*)/
|
34
34
|
{:title => title.strip, :description => description.strip, :task_description => task_description.strip, :tasks => tasks}
|
35
35
|
end
|
36
36
|
|
@@ -16,6 +16,17 @@ class Step
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def relocated
|
20
|
+
if @relocated.nil?
|
21
|
+
if Open.exists?(info_file) and (info[:path] != path)
|
22
|
+
@relocated = true
|
23
|
+
else
|
24
|
+
@relocated = false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
@relocated
|
28
|
+
end
|
29
|
+
|
19
30
|
def self.serialize_info(info)
|
20
31
|
info = info.clean_version if IndiferentHash === info
|
21
32
|
INFO_SERIALIZER.dump(info)
|
@@ -417,4 +428,8 @@ class Step
|
|
417
428
|
end
|
418
429
|
end
|
419
430
|
|
431
|
+
def inspect
|
432
|
+
Misc.fingerprint(self)
|
433
|
+
end
|
434
|
+
|
420
435
|
end
|
@@ -48,7 +48,11 @@ class Step
|
|
48
48
|
IndiferentHash.setup info_inputs
|
49
49
|
@inputs = NamedArray.setup info_inputs.values_at(*task.inputs.collect{|name| name.to_s}), task.inputs
|
50
50
|
else
|
51
|
-
|
51
|
+
if Hash === info_inputs
|
52
|
+
@inputs = NamedArray.setup info_inputs.values, info_inputs.keys
|
53
|
+
else
|
54
|
+
@inputs = info_inputs
|
55
|
+
end
|
52
56
|
end
|
53
57
|
else
|
54
58
|
nil
|
data/lib/rbbt/workflow/step.rb
CHANGED
@@ -51,9 +51,6 @@ class Step
|
|
51
51
|
@info_mutex = Mutex.new
|
52
52
|
@inputs = inputs
|
53
53
|
NamedArray.setup @inputs, task.inputs.collect{|s| s.to_s} if task and task.respond_to? :inputs and task.inputs
|
54
|
-
if Open.exists?(info_file) and (info[:path] != path)
|
55
|
-
@relocated = true
|
56
|
-
end
|
57
54
|
end
|
58
55
|
|
59
56
|
def workflow
|
data/lib/rbbt/workflow.rb
CHANGED
@@ -495,7 +495,8 @@ module Workflow
|
|
495
495
|
end
|
496
496
|
end
|
497
497
|
|
498
|
-
overriden = true if dependencies.select{|d| d.overriden && d.clean_name != d.name }.any?
|
498
|
+
#overriden = true if dependencies.select{|d| d.overriden && d.clean_name != d.name }.any?
|
499
|
+
overriden = true if dependencies.select{|d| Symbol === d.overriden }.any?
|
499
500
|
|
500
501
|
input_values = task.take_input_values(inputs)
|
501
502
|
if real_inputs.empty? && Workflow::TAG != :inputs && ! overriden #&& ! dependencies.select{|d| d.overriden && d.clean_name != d.name }.any?
|
@@ -665,6 +666,7 @@ module Workflow
|
|
665
666
|
step = Step.new path
|
666
667
|
relocated = false
|
667
668
|
dependencies = (step.info[:dependencies] || []).collect do |task,name,dep_path|
|
669
|
+
dep_path = task if dep_path.nil?
|
668
670
|
if Open.exists?(dep_path) || Open.exists?(dep_path + '.info') || Open.remote?(dep_path) || Open.ssh?(dep_path)
|
669
671
|
Workflow._load_step dep_path
|
670
672
|
else
|
@@ -1,24 +1,53 @@
|
|
1
1
|
import warnings
|
2
2
|
import sys
|
3
3
|
import os
|
4
|
+
import subprocess
|
4
5
|
|
5
|
-
def rbbt():
|
6
|
-
|
6
|
+
def rbbt(cmd = None):
|
7
|
+
if cmd is None:
|
8
|
+
print("Rbbt")
|
9
|
+
else:
|
10
|
+
return subprocess.run('rbbt_exec.rb', input=cmd.encode('utf-8'), capture_output=True).stdout.decode()
|
11
|
+
|
12
|
+
def libdir():
|
13
|
+
return rbbt('puts Rbbt.find(:lib)').rstrip()
|
14
|
+
|
15
|
+
def add_libdir():
|
16
|
+
pythondir = os.path.join(libdir(), 'python')
|
17
|
+
sys.path.insert(0, pythondir)
|
7
18
|
|
8
19
|
def path(subdir = None, base_dir = None):
|
9
20
|
from pathlib import Path
|
10
21
|
import os
|
11
22
|
|
12
|
-
if (base_dir ==
|
23
|
+
if (base_dir == 'base'):
|
13
24
|
base_dir = os.path.join(Path.home(), ".rbbt")
|
25
|
+
elif (base_dir == 'lib'):
|
26
|
+
base_dir = libdir()
|
27
|
+
else:
|
28
|
+
for base_dir in ('lib', 'base'):
|
29
|
+
file = path(subdir, base_dir)
|
30
|
+
if os.path.exists(file):
|
31
|
+
return file
|
32
|
+
return path(subdir, 'base')
|
33
|
+
|
14
34
|
if (subdir == None):
|
15
35
|
return base_dir
|
16
36
|
else:
|
17
37
|
return os.path.join(base_dir, subdir)
|
18
38
|
|
39
|
+
def read(subdir, base_dir = None, encoding='utf-8'):
|
40
|
+
file = path(subdir, base_dir)
|
41
|
+
with open(file, encoding=encoding) as f:
|
42
|
+
return f.read()
|
43
|
+
|
19
44
|
def inspect(obj):
|
20
45
|
print(dir(obj))
|
21
46
|
|
47
|
+
def rich(obj):
|
48
|
+
import rich
|
49
|
+
rich.inspect(obj)
|
50
|
+
|
22
51
|
def log_tsv(tsv):
|
23
52
|
print(tsv)
|
24
53
|
print(tsv.keys())
|
@@ -7,11 +7,12 @@ $0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_c
|
|
7
7
|
|
8
8
|
options = SOPT.setup <<EOF
|
9
9
|
|
10
|
-
|
10
|
+
Write a Excel file with the contents of a TSV
|
11
11
|
|
12
|
-
$ rbbt tsv write_excel [options] <filename.tsv|-> <filename.xls|filename.xlsx>
|
12
|
+
$ rbbt tsv write_excel [options] <filename.tsv|-> [<filename.xls|filename.xlsx>]
|
13
13
|
|
14
|
-
|
14
|
+
If no target file is specified it uses the same input files but replaces extension. Specifying
|
15
|
+
the extension of the excel file select the excel format to use.
|
15
16
|
|
16
17
|
-k--key_field* Key field
|
17
18
|
-f--fields* Fields
|
@@ -70,9 +70,14 @@ begin
|
|
70
70
|
exit 0
|
71
71
|
else
|
72
72
|
if command == 'bootstrap'
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
if wf.libdir["test_workflow.rb"].exists?
|
74
|
+
Log.info "No bootstrap for #{ workflow }, running test_workflow.rb instead"
|
75
|
+
CMD.cmd_log('ruby', wf.libdir["test_workflow.rb"].find)
|
76
|
+
else
|
77
|
+
Log.info "No bootstrap for #{ workflow }, running examples instead"
|
78
|
+
CMD.cmd_log("rbbt workflow example #{ workflow }")
|
79
|
+
exit 0
|
80
|
+
end
|
76
81
|
end
|
77
82
|
|
78
83
|
raise ParameterException, "Error: Command not understood: #{command}"
|
data/share/workflow_config.ru
CHANGED
@@ -46,6 +46,7 @@ app.get '/' do
|
|
46
46
|
begin
|
47
47
|
template_render('main', params, 'main', :cache_type => :asynchronous)
|
48
48
|
rescue TemplateMissing
|
49
|
+
Log.exception $!
|
49
50
|
redirect to(File.join('/', wf.to_s))
|
50
51
|
end
|
51
52
|
end
|
@@ -88,7 +89,16 @@ load_file Rbbt.etc['app.d/semaphores.rb'].find_all
|
|
88
89
|
if etc_dir['target_workflow_exports'].exists?
|
89
90
|
exports = etc_dir['target_workflow_exports'].read.split("\n")
|
90
91
|
exports.each do |task|
|
91
|
-
|
92
|
+
if task.include?('#')
|
93
|
+
wf_name, task_name = task.split("#")
|
94
|
+
begin
|
95
|
+
task_wf = Kernel.const_get wf_name
|
96
|
+
task_wf.export task_name.to_sym
|
97
|
+
rescue
|
98
|
+
end
|
99
|
+
else
|
100
|
+
wf.export task.to_sym
|
101
|
+
end
|
92
102
|
end
|
93
103
|
end
|
94
104
|
|
@@ -35,6 +35,7 @@ class TestMiscOmics < Test::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_translate_prot_mutation_hgvs2rbbt
|
38
|
+
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.Arg2459Gly"), "R2459G"
|
38
39
|
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.E255K"), "E255K"
|
39
40
|
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.E279Z"), "E279Z"
|
40
41
|
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.R132?"), "R132?"
|
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.
|
4
|
+
version: 5.41.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -338,7 +338,7 @@ files:
|
|
338
338
|
- lib/rbbt/workflow/util/orchestrator.rb
|
339
339
|
- lib/rbbt/workflow/util/provenance.rb
|
340
340
|
- lib/rbbt/workflow/util/trace.rb
|
341
|
-
- python/rbbt.py
|
341
|
+
- python/rbbt/__init__.py
|
342
342
|
- share/Rlib/plot.R
|
343
343
|
- share/Rlib/svg.R
|
344
344
|
- share/Rlib/util.R
|
@@ -584,7 +584,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
584
584
|
- !ruby/object:Gem::Version
|
585
585
|
version: '0'
|
586
586
|
requirements: []
|
587
|
-
rubygems_version: 3.
|
587
|
+
rubygems_version: 3.5.0.dev
|
588
588
|
signing_key:
|
589
589
|
specification_version: 4
|
590
590
|
summary: Utilities for the Ruby Bioinformatics Toolkit (rbbt)
|