rbbt-util 5.19.12 → 5.19.13
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/lib/rbbt/persist/tsv.rb +5 -5
- data/lib/rbbt/util/cmd.rb +77 -82
- data/lib/rbbt/util/misc/bgzf.rb +14 -0
- data/lib/rbbt/util/open.rb +1 -1
- data/lib/rbbt/workflow/usage.rb +1 -1
- data/share/rbbt_commands/system/optimize +3 -1
- data/test/rbbt/util/misc/test_bgzf.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f75831f4615a7e138d5b695bbea6517b889124a
|
4
|
+
data.tar.gz: ccdb744d5b4fcbdecd7123b2ef7be14d4a5ba554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2763af1623f1a361342f9d6ef27612ad638899caee17e706f8488476f3d3d75bc38e01365d50ded9ab9e04565dae86cb79872921654615a550eacc890b9f8e98
|
7
|
+
data.tar.gz: 0cdc819b514319fe59d065d29220eac6f5179c287df8cbca1c9e8ce7d29d2068dc83f726a59794d7c33f69ecebdec660f16a8701cdda34eab285e93845997db0
|
data/lib/rbbt/persist/tsv.rb
CHANGED
@@ -6,31 +6,31 @@ require 'rbbt/persist/tsv/packed_index'
|
|
6
6
|
begin
|
7
7
|
require 'rbbt/persist/tsv/tokyocabinet'
|
8
8
|
rescue Exception
|
9
|
-
Log.warn "The tokyocabinet gem could not be loaded
|
9
|
+
Log.warn "The tokyocabinet gem could not be loaded. Persistence using this engine will fail."
|
10
10
|
end
|
11
11
|
|
12
12
|
begin
|
13
13
|
require 'rbbt/persist/tsv/lmdb'
|
14
14
|
rescue Exception
|
15
|
-
Log.debug "The lmdb gem could not be loaded.
|
15
|
+
Log.debug "The lmdb gem could not be loaded. Persistence using this engine will fail."
|
16
16
|
end
|
17
17
|
|
18
18
|
begin
|
19
19
|
require 'rbbt/persist/tsv/leveldb'
|
20
20
|
rescue Exception
|
21
|
-
Log.debug "The LevelDB gem could not be loaded.
|
21
|
+
Log.debug "The LevelDB gem could not be loaded. Persistence using this engine will fail."
|
22
22
|
end
|
23
23
|
|
24
24
|
begin
|
25
25
|
require 'rbbt/persist/tsv/cdb'
|
26
26
|
rescue Exception
|
27
|
-
Log.debug "The CDB gem could not be loaded.
|
27
|
+
Log.debug "The CDB gem could not be loaded. Persistence using this engine will fail."
|
28
28
|
end
|
29
29
|
|
30
30
|
begin
|
31
31
|
require 'rbbt/persist/tsv/kyotocabinet'
|
32
32
|
rescue Exception
|
33
|
-
Log.debug "The kyotocabinet gem could not be loaded.
|
33
|
+
Log.debug "The kyotocabinet gem could not be loaded. Persistence using this engine will fail."
|
34
34
|
end
|
35
35
|
|
36
36
|
module Persist
|
data/lib/rbbt/util/cmd.rb
CHANGED
@@ -3,78 +3,78 @@ require 'stringio'
|
|
3
3
|
|
4
4
|
module CMD
|
5
5
|
|
6
|
-
module SmartIO
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
6
|
+
#module SmartIO
|
7
|
+
# attr_accessor :pid, :cmd, :post, :in, :out, :err, :log
|
8
|
+
# def self.tie(io, pid = nil, cmd = "", post = nil, sin = nil, out = nil, err = nil, log = true)
|
9
|
+
# io.extend SmartIO
|
10
|
+
# io.pid = pid
|
11
|
+
# io.cmd = cmd
|
12
|
+
# io.in = sin
|
13
|
+
# io.out = out
|
14
|
+
# io.err = err
|
15
|
+
# io.post = post
|
16
|
+
# io.log = log
|
17
|
+
|
18
|
+
# io.class.send(:alias_method, :original_close, :close)
|
19
|
+
# io.class.send(:alias_method, :original_read, :read)
|
20
|
+
# io
|
21
|
+
# end
|
22
|
+
|
23
|
+
# def wait_and_status
|
24
|
+
# if @pid
|
25
|
+
# begin
|
26
|
+
# Process.waitpid(@pid)
|
27
|
+
# rescue
|
28
|
+
# end
|
29
|
+
|
30
|
+
# Log.debug{"Process #{ cmd } succeded" if $? and $?.success? and log}
|
31
|
+
|
32
|
+
# if $? and not $?.success?
|
33
|
+
# Log.debug{"Raising exception" if log}
|
34
|
+
# exception = ProcessFailed.new "Command [#{@pid}] '#{@cmd}' failed with error status #{$?.exitstatus}"
|
35
|
+
# begin
|
36
|
+
# original_close
|
37
|
+
# ensure
|
38
|
+
# raise exception
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
|
44
|
+
# def close
|
45
|
+
# self.original_read unless self.closed? or self.eof?
|
46
|
+
|
47
|
+
# wait_and_status
|
48
|
+
|
49
|
+
# @post.call if @post
|
50
|
+
|
51
|
+
# original_close unless self.closed?
|
52
|
+
# end
|
53
|
+
|
54
|
+
# def force_close
|
55
|
+
# if @pid
|
56
|
+
# Log.debug{"Forcing close by killing '#{@pid}'" if log}
|
57
|
+
# begin
|
58
|
+
# Process.kill("KILL", @pid)
|
59
|
+
# Process.waitpid(@pid)
|
60
|
+
# rescue
|
61
|
+
# Log.low{"Exception in forcing close of command [#{ @pid }, #{cmd}]: #{$!.message}"}
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
|
65
|
+
# @post.call if @post
|
66
|
+
|
67
|
+
# original_close unless self.closed?
|
68
|
+
# end
|
69
|
+
|
70
|
+
# def read(*args)
|
71
|
+
# data = original_read(*args) unless self.closed? #or self.eof?
|
72
|
+
|
73
|
+
# self.close if not self.closed? and self.eof?
|
74
|
+
|
75
|
+
# data #|| ""
|
76
|
+
# end
|
77
|
+
#end
|
78
78
|
|
79
79
|
|
80
80
|
def self.process_cmd_options(options = {})
|
@@ -105,6 +105,7 @@ module CMD
|
|
105
105
|
post = options.delete(:post)
|
106
106
|
log = options.delete(:log)
|
107
107
|
no_fail = options.delete(:no_fail)
|
108
|
+
no_wait = options.delete(:no_wait)
|
108
109
|
dont_close_in = options.delete(:dont_close_in)
|
109
110
|
|
110
111
|
log = true if log.nil?
|
@@ -132,15 +133,9 @@ module CMD
|
|
132
133
|
|
133
134
|
io = in_content
|
134
135
|
while IO === io
|
135
|
-
if
|
136
|
-
|
137
|
-
|
138
|
-
io.err.close unless io.err.nil? or io.err.closed?
|
139
|
-
io = io.in
|
140
|
-
else
|
141
|
-
io.close unless io.closed?
|
142
|
-
io = nil
|
143
|
-
end
|
136
|
+
io.join if io.respond_to?(:join) and not io.joined?
|
137
|
+
io.close if io.respond_to?(:close) and not io.closed?
|
138
|
+
io = nil
|
144
139
|
end
|
145
140
|
|
146
141
|
STDIN.reopen sin.first
|
@@ -206,7 +201,7 @@ module CMD
|
|
206
201
|
end
|
207
202
|
|
208
203
|
#SmartIO.tie sout, pid, cmd, post, in_content, sin, serr
|
209
|
-
ConcurrentStream.setup sout, :pids => [pid], :autojoin => true, :no_fail => no_fail
|
204
|
+
ConcurrentStream.setup sout, :pids => [pid], :autojoin => true, :no_fail => no_fail unless no_wait
|
210
205
|
|
211
206
|
sout
|
212
207
|
else
|
data/lib/rbbt/util/misc/bgzf.rb
CHANGED
@@ -1,9 +1,23 @@
|
|
1
|
+
|
1
2
|
require 'rbbt/persist'
|
2
3
|
require 'set'
|
3
4
|
|
4
5
|
module Bgzf
|
5
6
|
attr_accessor :data_offset, :compressed_stream, :block_cache_size
|
6
7
|
|
8
|
+
def self.bgzip_cmd
|
9
|
+
@@bgzip_cmd ||= begin
|
10
|
+
path = `bash -c "type -p bgzips"`.strip
|
11
|
+
if path.empty?
|
12
|
+
Rbbt.claim Rbbt.software.opt.htslib, :install, Rbbt.share.install.software.HTSLIB
|
13
|
+
Rbbt.software.opt.htslib.produce
|
14
|
+
Rbbt.software.opt.htslib.bin.bgzip.find
|
15
|
+
else
|
16
|
+
path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
7
21
|
def self.setup(compressed_stream)
|
8
22
|
require 'bio-bgzf'
|
9
23
|
reader = Bio::BGZF::Reader.new(compressed_stream)
|
data/lib/rbbt/util/open.rb
CHANGED
@@ -294,7 +294,7 @@ module Open
|
|
294
294
|
|
295
295
|
def self.gunzip(stream)
|
296
296
|
#Zlib::GzipReader.new(stream)
|
297
|
-
CMD.cmd('zcat', :in => stream, :pipe => true)
|
297
|
+
CMD.cmd('zcat', :in => stream, :pipe => true, :no_fail => true, :no_wait => true)
|
298
298
|
end
|
299
299
|
|
300
300
|
def self.unzip(stream)
|
data/lib/rbbt/workflow/usage.rb
CHANGED
@@ -44,7 +44,7 @@ module Task
|
|
44
44
|
puts
|
45
45
|
|
46
46
|
if selects.any?
|
47
|
-
puts Log.color(:magenta, "Input options
|
47
|
+
puts Log.color(:magenta, "Input select options")
|
48
48
|
puts
|
49
49
|
selects.each do |input,options|
|
50
50
|
puts Log.color(:blue, input.to_s + ": ") << Misc.format_paragraph(options.collect{|o| o.to_s} * ", ") << "\n"
|
@@ -35,13 +35,15 @@ raise ParameterException, "Not a valid directory" unless File.directory? directo
|
|
35
35
|
directory = Path.setup directory.dup
|
36
36
|
keep = options[:keep]
|
37
37
|
|
38
|
+
require 'rbbt/util/misc/bgzf'
|
39
|
+
|
38
40
|
Log.info Log.color(:magenta, "Processing chromosomes")
|
39
41
|
chromosome_files = directory.glob('**/chromosome_*')
|
40
42
|
TSV.traverse chromosome_files, :type => :array, :bar => "Processing chromosomes" do |chr_file|
|
41
43
|
next if chr_file =~ /.bgz$/
|
42
44
|
compressed_file = chr_file + '.bgz'
|
43
45
|
Log.info "Compressing #{ chr_file } into #{ compressed_file }"
|
44
|
-
CMD.cmd("
|
46
|
+
CMD.cmd("#{Bgzf.bgzip_cmd} '#{ chr_file }' -c > #{ compressed_file }")
|
45
47
|
begin
|
46
48
|
Open.read(compressed_file)
|
47
49
|
if keep
|
@@ -2,7 +2,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_he
|
|
2
2
|
require 'rbbt/util/misc/bgzf'
|
3
3
|
|
4
4
|
class TestBgzf < Test::Unit::TestCase
|
5
|
-
def
|
5
|
+
def test_Bgzf
|
6
6
|
content = "1234567890" * 1000000
|
7
7
|
TmpFile.with_file(content) do |file|
|
8
8
|
compressed = file + '.gz'
|
@@ -35,5 +35,10 @@ class TestBgzf < Test::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
def test_bgzip
|
40
|
+
assert File.exists?(Bgzf.bgzip_cmd)
|
41
|
+
assert 'bgzip', File.basename(Bgzf.bgzip_cmd)
|
42
|
+
end
|
38
43
|
end
|
39
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.19.
|
4
|
+
version: 5.19.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: 2016-
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|