rbbt-util 5.26.84 → 5.26.85

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: a7a03e9e9cec9f84ea91902fe393037932b4bc155abc38ef4145573dea832171
4
- data.tar.gz: dc7030fb86e929d468bd8481eea26a8fd55e679c99cc8709507b9cff3a1044b8
3
+ metadata.gz: b150d8b85d7565e2ec820343f002c8bfc80e46302d5a35d83b10f132d2ebfc94
4
+ data.tar.gz: 66359a6ec5533d41ab1bb2344bf6795844e0f4ca46332523647ba13319a7d6e8
5
5
  SHA512:
6
- metadata.gz: c67e91543978c2b151b1bfc77083de1decd53e2912da81beaac2925190db85531255fcca48056f6c7a2b02ee91a03017b74390531ae44bec6777bfea1b23c100
7
- data.tar.gz: 285ba9a06af9cec0377b828a24949250ee5cc62825a0ad59fd207fdd7f44acc1e3469a495773e2818198eb414dc8090283117021276b5b2525c7f5e3f2e6d783
6
+ metadata.gz: 1cf80ad89a6007b291518458b7eb995b2a589ce34230a8fea9b03e83cf196df787f7c46376dfb80d0c8a4d3fdbb83cc906a8a1240ac26bbee25c8bebc67c606c
7
+ data.tar.gz: 6a9fc1eee7bf113ccefa6aef14d704406fbe68a07a24f0c603102e2cfe3e9863ec4b88a01a3029885b2e98754ad85c215956e2a267b71d894659c041da62ae43
@@ -402,6 +402,11 @@ module Path
402
402
  self.annotate(new_path)
403
403
  end
404
404
 
405
+ def remove_extension(new_extension = nil)
406
+ self.sub(/\.[^\.\/]{1,5}$/,'')
407
+ end
408
+
409
+
405
410
  def self.get_extension(path)
406
411
  path.match(/\.([^\.\/]{1,5})$/)[1]
407
412
  end
@@ -138,6 +138,7 @@ module R
138
138
  options[:R_open] ||= "colClasses=c('character'," + field_classes * ", " + ')'
139
139
 
140
140
  data.R <<-EOF, :plot, options
141
+ rbbt.require('ggplot2')
141
142
  plot = { #{script} }
142
143
 
143
144
  ggsave('#{filename}', plot, width = #{R.ruby2R width}, height = #{R.ruby2R height})
data/lib/rbbt/util/cmd.rb CHANGED
@@ -20,7 +20,7 @@ module CMD
20
20
  if test
21
21
  CMD.cmd(test)
22
22
  else
23
- CMD.cmd("#{cmd} --help")
23
+ CMD.cmd("#{tool} --help")
24
24
  end
25
25
  rescue
26
26
  if claim
@@ -24,7 +24,7 @@ module Rbbt::Config
24
24
  end
25
25
 
26
26
  def self.load_config
27
- Rbbt.etc.config.find_all.each do |file|
27
+ Rbbt.etc.config.find_all.reverse.each do |file|
28
28
  self.load_file(file)
29
29
  end
30
30
  end
@@ -110,7 +110,7 @@ module Rbbt::Config
110
110
  end
111
111
  end
112
112
 
113
- value = priorities.empty? ? default : priorities.collect{|p| p }.sort_by{|p,v| p}.first.last.first
113
+ value = priorities.empty? ? default : priorities.collect{|p| p }.sort_by{|p,v| p}.first.last.last
114
114
  value = false if value == 'false'
115
115
 
116
116
  Log.debug "Value #{value.inspect} for config key '#{ key }': #{tokens * ", "}"
@@ -338,6 +338,7 @@ module Open
338
338
  source = source.find if Path === source
339
339
  target = target.find if Path === target
340
340
 
341
+ target = File.join(target, File.basename(source)) if File.directory? target
341
342
  FileUtils.mkdir_p File.dirname(target) unless File.exists?(File.dirname(target))
342
343
  FileUtils.rm target if File.exists?(target)
343
344
  FileUtils.ln_s source, target
@@ -4,19 +4,27 @@ require 'pycall/import'
4
4
 
5
5
  module RbbtPython
6
6
  extend PyCall::Import
7
- def self.run(mod = nil, &block)
7
+ def self.run(mod = nil, imports = nil, &block)
8
8
  begin
9
- pyimport mod unless mod.nil?
10
- case block.arity
11
- when 0
12
- yield
13
- when 1
14
- yield self.send(mod)
15
- else
16
- raise "Unknown arity on block of code #{block.arity}"
9
+ if mod
10
+ if imports
11
+ pyfrom mod, :import => imports
12
+ else
13
+ pyimport mod
14
+ end
17
15
  end
16
+
17
+ module_eval(&block)
18
+
18
19
  rescue
19
20
  Log.exception $!
20
21
  end
21
22
  end
23
+
24
+ def self.add_path(path)
25
+ self.run 'sys' do
26
+ sys.path.append path
27
+ end
28
+ end
29
+
22
30
  end
data/share/Rlib/util.R CHANGED
@@ -485,6 +485,7 @@ rbbt.model.inpute <- function(data, formula, ...){
485
485
  }
486
486
 
487
487
  rbbt.tsv.melt <- function(tsv, variable = NULL, value = NULL, key.field = NULL){
488
+ rbbt.require('reshape2')
488
489
  if (is.null(key.field)){ key.field = attributes(data)$key.field;}
489
490
  if (is.null(key.field)){ key.field = "ID" }
490
491
 
@@ -404,7 +404,7 @@ setup(){
404
404
  else
405
405
  local old_pwd="`expand_path $(pwd)`"
406
406
 
407
- for exe in ` find "$pkg_dir/" "$pkg_dir/source/" "$pkg_dir/src/" -maxdepth 1 -type f -executable`; do
407
+ for exe in ` find "$pkg_dir/" "$pkg_dir/build" "$pkg_dir/source/" "$pkg_dir/src/" -maxdepth 1 -type f -executable`; do
408
408
  orig=$exe
409
409
  exe=$(basename $exe)
410
410
  echo "EXE $exe"
@@ -55,7 +55,7 @@ puts path.glob_all.collect{|p| File.directory?(p) ? p + "/" : p } * "\n"
55
55
  [path, paths.collect{|p| [options[:source], p] * ":"}]
56
56
  else
57
57
  if File.exists?(path)
58
- path = resource.identify(path)
58
+ path = resource.identify(path)
59
59
  else
60
60
  path = Path.setup(path)
61
61
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  options = SOPT.get("-a--app*")
4
4
 
5
-
6
5
  CMD.cmd("rbbt workflow monitor --quick -c -a -d #{Rbbt.var.jobs.find}").read
7
6
  CMD.cmd("rm -f #{ Rbbt.tmp.tsv_open_locks.find.glob("*").collect{|f| "'#{f}'" } * " " }").read
8
7
  CMD.cmd("find #{Rbbt.share.find_all.collect{|f| "'#{f}'" } * " " } -name '*.lock' -delete").read
@@ -0,0 +1,44 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
+ require 'rbbt/util/python'
3
+
4
+ class TestPython < Test::Unit::TestCase
5
+ def test_python
6
+ TmpFile.with_file do |tmpdir|
7
+ code =<<-EOF
8
+ def python_test(a, b):
9
+ c = a + b
10
+ return c
11
+ EOF
12
+ Open.write(File.join(tmpdir, 'file1.py'), code)
13
+ Open.write(File.join(tmpdir, 'file2.py'), code)
14
+ Open.write(File.join(tmpdir, 'file3.py'), code)
15
+ Open.write(File.join(tmpdir, 'file4.py'), code)
16
+ RbbtPython.add_path tmpdir
17
+
18
+ res = nil
19
+
20
+ RbbtPython.run 'file2', :python_test do
21
+ res = python_test(1, 3)
22
+ end
23
+ assert_equal 4, res
24
+
25
+ RbbtPython.run do
26
+ pyfrom :file3, :import => :python_test
27
+ res = python_test(1, 4)
28
+ end
29
+ assert_equal 5, res
30
+
31
+ RbbtPython.run do
32
+ pyimport :file4
33
+ res = file4.python_test(1, 4)
34
+ end
35
+ assert_equal 5, res
36
+
37
+ RbbtPython.run 'file1' do
38
+ res = file1.python_test(1, 2)
39
+ end
40
+ assert_equal 3, res
41
+ end
42
+ end
43
+ end
44
+
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.26.84
4
+ version: 5.26.85
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-25 00:00:00.000000000 Z
11
+ date: 2019-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -502,6 +502,7 @@ files:
502
502
  - test/rbbt/util/test_log.rb
503
503
  - test/rbbt/util/test_misc.rb
504
504
  - test/rbbt/util/test_open.rb
505
+ - test/rbbt/util/test_python.rb
505
506
  - test/rbbt/util/test_semaphore.rb
506
507
  - test/rbbt/util/test_simpleDSL.rb
507
508
  - test/rbbt/util/test_simpleopt.rb
@@ -530,7 +531,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
530
531
  - !ruby/object:Gem::Version
531
532
  version: '0'
532
533
  requirements: []
533
- rubygems_version: 3.0.3
534
+ rubygems_version: 3.0.6
534
535
  signing_key:
535
536
  specification_version: 4
536
537
  summary: Utilities for the Ruby Bioinformatics Toolkit (rbbt)
@@ -565,6 +566,7 @@ test_files:
565
566
  - test/rbbt/util/simpleopt/test_parse.rb
566
567
  - test/rbbt/util/simpleopt/test_setup.rb
567
568
  - test/rbbt/util/simpleopt/test_get.rb
569
+ - test/rbbt/util/test_python.rb
568
570
  - test/rbbt/util/test_filecache.rb
569
571
  - test/rbbt/util/concurrency/test_processes.rb
570
572
  - test/rbbt/util/concurrency/test_threads.rb