rbbt-util 5.40.5 → 5.41.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc59a09644d58c21eb59f643cd04bd50d4fc81a494f024cef8af1ea26197a0e7
4
- data.tar.gz: 84c1669d61fce9e4a239ec7865aee04b67684f99911cc9e378b569517b819388
3
+ metadata.gz: 4bd731f2fb8604116f9baf947e8e0b5f5e8bd1b252773864f5a76e9c4b52126d
4
+ data.tar.gz: 82c364cc76d5921e49197c410d05a919e8b71a96d0499827b0546bf402c401ae
5
5
  SHA512:
6
- metadata.gz: df0ae52fabfa8c84c0d4a18861912972ac44b347867580087842d1856d4558f7dd1d4e2b7d9b0b0ae23f766a7001516445662114e050c3054458190061caab5e
7
- data.tar.gz: 3e5c396193a6423d7c8afbb381c623844bf457d0a34ef329b7bfe6ac29f6a13841f23b9ce7c3bb051fdeeb35a2e72bfed16279aff52fb3a0ff1484b1587bb841
6
+ metadata.gz: 655e499e17ea4806f278ecaf83521c200aa978ace61c27f5aac0490bc99a40cac42498f323155ee3c547a2a98d23271a8fa6d3b424180c87b249b50219fb7235
7
+ data.tar.gz: c3ef8cc5790db9bb5df6d0853542355b267e2f8f26c4b6bc8305729b793eff8832a33479a53339605bcaf8b450a500dc58a9bd5557e1d993f8c8b72228ab1793
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? :annotation_repo)
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/tsv.rb CHANGED
@@ -69,6 +69,7 @@ module TSV
69
69
  options = TSV.str2options(options) if String === options and options.include? "~"
70
70
  options ||= {}
71
71
  options[:type] ||= type unless type.nil?
72
+ options[:zipped] = true if options[:one2one]
72
73
 
73
74
  persist_options = Misc.pull_keys options, :persist
74
75
 
@@ -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
@@ -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
 
@@ -428,4 +428,8 @@ class Step
428
428
  end
429
429
  end
430
430
 
431
+ def inspect
432
+ Misc.fingerprint(self)
433
+ end
434
+
431
435
  end
@@ -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
- print("Rbbt")
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 == None):
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,9 +7,10 @@ options = SOPT.setup <<EOF
7
7
 
8
8
  Query a TSV value
9
9
 
10
- $ rbbt tsv get [options] <filename.tsv|-> <key>
10
+ $ rbbt tsv get [options] <filename.tsv|-> [<key>]
11
11
 
12
- Use - to read from STDIN
12
+ Use - to read from STDIN, 'key' can be the key string or a number representing
13
+ its position. If not specified 'key' defaults to 0, the first entry.
13
14
 
14
15
  -tch--tokyocabinet File is a tokyocabinet hash database
15
16
  -tcb--tokyocabinet_bd File is a tokyocabinet B database
@@ -26,7 +27,7 @@ rbbt_usage and exit 0 if options[:help]
26
27
 
27
28
  file, key = ARGV
28
29
 
29
- raise ParameterException, "Please specify file and key" if key.nil?
30
+ raise ParameterException, "Please specify file" if file.nil?
30
31
 
31
32
  file = STDIN if file == '-'
32
33
 
@@ -48,7 +49,15 @@ key_field = options[:key_field]
48
49
  fields = fields.split(/[,|]/, -1) unless fields.nil?
49
50
 
50
51
  if TSV === tsv
52
+ case key
53
+ when nil
54
+ key = tsv.keys.first if key.nil?
55
+ when /^\d+$/
56
+ key = tsv.keys[key.to_i] unless tsv.include?(key)
57
+ end
58
+
51
59
  v = tsv[key]
60
+
52
61
  fields ||= tsv.fields
53
62
  puts Log.color(:blue, "Key: #{ key }")
54
63
  if fields
@@ -72,8 +81,15 @@ end
72
81
  parser = TSV::Parser.new tsv, :key_field => key_field, :fields => fields, :type => options[:type], :header_hash => options[:header_hash], :sep => options[:sep]
73
82
  fields ||= parser.fields
74
83
 
84
+ i = 0
75
85
  TSV.traverse(parser) do |k,v|
76
- next unless k.include? key
86
+ if key== "#{i}"
87
+ key = k.first
88
+ elsif key.nil?
89
+ key = k.first
90
+ end
91
+ i += 1
92
+ next unless k.include?(key)
77
93
  k = k.first if Array === k
78
94
  puts Log.color(:blue, "Key: #{ k }")
79
95
  if fields
@@ -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
- wf.export task.to_sym
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.40.5
4
+ version: 5.41.1
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-10-26 00:00:00.000000000 Z
11
+ date: 2024-01-12 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