rbbt-util 4.4.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -0
- data/bin/rbbt_exec.rb +6 -1
- data/bin/rbbt_monitor.rb +117 -0
- data/bin/run_workflow.rb +7 -3
- data/lib/rbbt/annotations.rb +147 -81
- data/lib/rbbt/fix_width_table.rb +5 -1
- data/lib/rbbt/persist.rb +51 -34
- data/lib/rbbt/persist/tsv.rb +26 -15
- data/lib/rbbt/resource.rb +14 -9
- data/lib/rbbt/resource/path.rb +5 -5
- data/lib/rbbt/resource/rake.rb +9 -5
- data/lib/rbbt/resource/util.rb +4 -2
- data/lib/rbbt/tsv.rb +23 -8
- data/lib/rbbt/tsv/accessor.rb +18 -5
- data/lib/rbbt/tsv/attach/util.rb +12 -2
- data/lib/rbbt/tsv/manipulate.rb +69 -16
- data/lib/rbbt/tsv/parser.rb +3 -2
- data/lib/rbbt/tsv/util.rb +5 -4
- data/lib/rbbt/util/chain_methods.rb +8 -8
- data/lib/rbbt/util/cmd.rb +1 -1
- data/lib/rbbt/util/misc.rb +118 -13
- data/lib/rbbt/util/open.rb +38 -14
- data/lib/rbbt/util/simpleDSL.rb +1 -1
- data/lib/rbbt/workflow.rb +5 -4
- data/lib/rbbt/workflow/accessor.rb +7 -5
- data/lib/rbbt/workflow/step.rb +50 -7
- data/test/rbbt/test_annotations.rb +29 -3
- data/test/rbbt/test_persist.rb +150 -0
- data/test/rbbt/test_tsv.rb +35 -0
- data/test/rbbt/tsv/test_accessor.rb +9 -0
- data/test/rbbt/util/test_misc.rb +17 -3
- data/test/rbbt/util/test_open.rb +21 -0
- data/test/rbbt/workflow/test_step.rb +41 -1
- metadata +140 -136
data/test/rbbt/test_tsv.rb
CHANGED
@@ -173,12 +173,33 @@ row1 1
|
|
173
173
|
row2 4
|
174
174
|
EOF
|
175
175
|
|
176
|
+
require 'rbbt/sources/organism'
|
176
177
|
TmpFile.with_file(content) do |filename|
|
177
178
|
tsv = TSV.open(filename, :sep => /\s+/, :cast => :to_i, :type => :single, :fields => "Value")
|
178
179
|
assert_equal 1, tsv["row1"]
|
180
|
+
tsv = TSV.open(filename, :sep => /\s+/, :cast => :to_i, :type => :single, :fields => ["Value"])
|
181
|
+
assert_equal 1, tsv["row1"]
|
182
|
+
tsv = TSV.open(filename, :sep => /\s+/, :type => :single, :key_field => "Value", :fields => ["Id"])
|
183
|
+
assert_equal "row1", tsv["1"]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_tsv_single_from_flat
|
188
|
+
content =<<-EOF
|
189
|
+
#: :type=:flat
|
190
|
+
#Id Value
|
191
|
+
row1 1 2
|
192
|
+
row2 4
|
193
|
+
EOF
|
194
|
+
|
195
|
+
require 'rbbt/sources/organism'
|
196
|
+
TmpFile.with_file(content) do |filename|
|
197
|
+
tsv = TSV.open(filename, :sep => /\s+/, :type => :single, :key_field => "Value", :fields => ["Id"])
|
198
|
+
assert_equal "row1", tsv["1"]
|
179
199
|
end
|
180
200
|
end
|
181
201
|
|
202
|
+
|
182
203
|
def test_tsv_serializer
|
183
204
|
content =<<-EOF
|
184
205
|
#Id Value
|
@@ -312,6 +333,20 @@ b 2
|
|
312
333
|
end
|
313
334
|
end
|
314
335
|
|
336
|
+
def test_grep_invert
|
337
|
+
content =<<-EOF
|
338
|
+
#: :sep=/\\s+/#:type=:single
|
339
|
+
#Id Value
|
340
|
+
a 1
|
341
|
+
b 2
|
342
|
+
EOF
|
343
|
+
|
344
|
+
TmpFile.with_file(content) do |filename|
|
345
|
+
tsv = TSV.open(filename, :key_field => "Value", :grep => "#\\|2", :invert_grep => true)
|
346
|
+
assert(! tsv.include?("2"))
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
315
350
|
def test_grep_header
|
316
351
|
content =<<-EOF
|
317
352
|
#: :sep=/\\s+/#:type=:single#:namespace=Test
|
@@ -175,4 +175,13 @@ row3 A|AA|AAA|AAA B Id3 3
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
+
def test_chunked_values_at
|
179
|
+
tsv = TSV.setup({})
|
180
|
+
10.times do |i|
|
181
|
+
tsv[i] = i
|
182
|
+
end
|
183
|
+
pos = tsv.chunked_values_at (0..10-1).to_a, 2
|
184
|
+
assert_equal (0..10-1).to_a, pos
|
185
|
+
end
|
186
|
+
|
178
187
|
end
|
data/test/rbbt/util/test_misc.rb
CHANGED
@@ -4,6 +4,10 @@ require 'test/unit'
|
|
4
4
|
|
5
5
|
class TestMisc < Test::Unit::TestCase
|
6
6
|
|
7
|
+
def test_humanize
|
8
|
+
assert_equal "mutation_enrichment", Misc.humanize("MutationEnrichment")
|
9
|
+
end
|
10
|
+
|
7
11
|
def test_fixutf8
|
8
12
|
string = "abc\xffdef"
|
9
13
|
string = string.force_encoding("UTF-8") if string.respond_to? :force_encoding
|
@@ -182,9 +186,19 @@ class TestMisc < Test::Unit::TestCase
|
|
182
186
|
assert_equal "--------------------------------TYTIDMKTTQNVNGLSML-------------------------", Misc.fast_align(reference, sequence).last
|
183
187
|
end
|
184
188
|
|
185
|
-
|
186
|
-
|
187
|
-
|
189
|
+
def test_divide
|
190
|
+
assert_equal 2, Misc.divide(%w(1 2 3 4 5 6 7 8 9),2).length
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_ordered_divide
|
194
|
+
assert_equal 5, Misc.ordered_divide(%w(1 2 3 4 5 6 7 8 9),2).length
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_setup
|
198
|
+
require 'rbbt/entity/gene'
|
199
|
+
g = Misc.prepare_entity("TP53", "Gene", :format => "Associated Gene Name", "organism" => "Hsa/jun2011")
|
200
|
+
end
|
201
|
+
|
188
202
|
#
|
189
203
|
# def test_process_to_hash
|
190
204
|
# list = [1,2,3,4]
|
data/test/rbbt/util/test_open.rb
CHANGED
@@ -68,6 +68,27 @@ class TestOpen < Test::Unit::TestCase
|
|
68
68
|
|
69
69
|
end
|
70
70
|
|
71
|
+
def test_read_grep_invert
|
72
|
+
content =<<-EOF
|
73
|
+
1
|
74
|
+
2
|
75
|
+
3
|
76
|
+
4
|
77
|
+
EOF
|
78
|
+
TmpFile.with_file(content) do |file|
|
79
|
+
sum = 0
|
80
|
+
Open.read(file, :grep => '^1\|3', :invert_grep => true) do |line| sum += line.to_i end
|
81
|
+
assert_equal(2 + 4, sum)
|
82
|
+
end
|
83
|
+
|
84
|
+
TmpFile.with_file(content) do |file|
|
85
|
+
sum = 0
|
86
|
+
Open.read(file, :grep => ["1","3"]) do |line| sum += line.to_i end
|
87
|
+
assert_equal(1 + 3, sum)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
71
92
|
|
72
93
|
def test_gzip
|
73
94
|
content =<<-EOF
|
@@ -41,12 +41,52 @@ class TestStep < Test::Unit::TestCase
|
|
41
41
|
step2 = Step.new tmpfile + 'step2', task2, [], step1
|
42
42
|
|
43
43
|
step1.clean
|
44
|
-
sleep 1
|
45
44
|
step2.run
|
46
45
|
assert_equal "TEST2", Open.read(tmpfile + 'step2')
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
49
|
+
def test_dependency_log_relay
|
50
|
+
str = "TEST"
|
51
|
+
TmpFile.with_file do |tmpfile|
|
52
|
+
task1 = Task.setup :result_type => nil, :name => :task1 do
|
53
|
+
log(:starting_task1, "Starting Task1")
|
54
|
+
Open.write(tmpfile, str);
|
55
|
+
end
|
56
|
+
step1 = Step.new tmpfile + 'step1', task1
|
57
|
+
|
58
|
+
task2 = Task.setup :result_type => :string, :name => :task1 do
|
59
|
+
Open.read(tmpfile)
|
60
|
+
end
|
61
|
+
step2 = Step.new tmpfile + 'step2', task2, [], [step1]
|
62
|
+
|
63
|
+
step2.run
|
64
|
+
assert step2.messages.include? "task1>Starting Task1"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_log_relay_step
|
69
|
+
str = "TEST"
|
70
|
+
TmpFile.with_file do |tmpfile|
|
71
|
+
task1 = Task.setup :result_type => nil, :name => :task1 do
|
72
|
+
log(:starting_task1, "Starting Task1")
|
73
|
+
Open.write(tmpfile, str);
|
74
|
+
end
|
75
|
+
step1 = Step.new tmpfile + 'step1', task1
|
76
|
+
|
77
|
+
|
78
|
+
task2 = Task.setup :result_type => :string, :name => :task1 do
|
79
|
+
Open.read(tmpfile)
|
80
|
+
end
|
81
|
+
step2 = Step.new tmpfile + 'step2', task2, [], [step1]
|
82
|
+
|
83
|
+
Step.log_relay_step = step2
|
84
|
+
step2.run
|
85
|
+
assert step2.messages.include? "task1>Starting Task1"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
50
90
|
def test_exec
|
51
91
|
TmpFile.with_file do |lock|
|
52
92
|
task = Task.setup do "TEST" end
|
metadata
CHANGED
@@ -1,163 +1,175 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 5.0.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 4
|
8
|
-
- 4
|
9
|
-
- 0
|
10
|
-
version: 4.4.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Miguel Vazquez
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rake
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: spreadsheet
|
36
23
|
prerelease: false
|
37
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: spreadsheet
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
38
33
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
46
38
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: ruby-prof
|
50
39
|
prerelease: false
|
51
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: ruby-prof
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
52
49
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
version: "0"
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
60
54
|
type: :runtime
|
61
|
-
version_requirements: *id003
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: tokyocabinet
|
64
55
|
prerelease: false
|
65
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: tokyocabinet
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
66
65
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
version: "0"
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
74
70
|
type: :runtime
|
75
|
-
version_requirements: *id004
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: progress-monitor
|
78
71
|
prerelease: false
|
79
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
73
|
none: false
|
81
|
-
requirements:
|
82
|
-
- -
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: progress-monitor
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
88
86
|
type: :runtime
|
89
|
-
version_requirements: *id005
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: lockfile
|
92
87
|
prerelease: false
|
93
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
89
|
none: false
|
95
|
-
requirements:
|
96
|
-
- -
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: lockfile
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
102
|
type: :runtime
|
103
|
-
version_requirements: *id006
|
104
|
-
- !ruby/object:Gem::Dependency
|
105
|
-
name: RubyInline
|
106
103
|
prerelease: false
|
107
|
-
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
105
|
none: false
|
109
|
-
requirements:
|
110
|
-
- -
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: RubyInline
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
116
118
|
type: :runtime
|
117
|
-
version_requirements: *id007
|
118
|
-
- !ruby/object:Gem::Dependency
|
119
|
-
name: narray
|
120
119
|
prerelease: false
|
121
|
-
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
121
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: narray
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
130
134
|
type: :runtime
|
131
|
-
version_requirements: *id008
|
132
|
-
- !ruby/object:Gem::Dependency
|
133
|
-
name: simplews
|
134
135
|
prerelease: false
|
135
|
-
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: simplews
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
136
145
|
none: false
|
137
|
-
requirements:
|
138
|
-
- -
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
|
141
|
-
segments:
|
142
|
-
- 0
|
143
|
-
version: "0"
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
144
150
|
type: :runtime
|
145
|
-
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
146
158
|
description: Utilities for handling tsv files, caches, etc
|
147
159
|
email: miguel.vazquez@cnio.es
|
148
|
-
executables:
|
160
|
+
executables:
|
149
161
|
- tsv.rb
|
150
162
|
- tchash.rb
|
151
163
|
- run_workflow.rb
|
152
164
|
- rbbt_query.rb
|
153
165
|
- rbbt_exec.rb
|
154
166
|
- rbbt_Rutil.rb
|
167
|
+
- rbbt_monitor.rb
|
155
168
|
extensions: []
|
156
|
-
|
157
|
-
extra_rdoc_files:
|
169
|
+
extra_rdoc_files:
|
158
170
|
- LICENSE
|
159
171
|
- README.rdoc
|
160
|
-
files:
|
172
|
+
files:
|
161
173
|
- LICENSE
|
162
174
|
- lib/rbbt-util.rb
|
163
175
|
- lib/rbbt.rb
|
@@ -237,40 +249,32 @@ files:
|
|
237
249
|
- bin/rbbt_query.rb
|
238
250
|
- bin/rbbt_exec.rb
|
239
251
|
- bin/rbbt_Rutil.rb
|
252
|
+
- bin/rbbt_monitor.rb
|
240
253
|
homepage: http://github.com/mikisvaz/rbbt-util
|
241
254
|
licenses: []
|
242
|
-
|
243
255
|
post_install_message:
|
244
256
|
rdoc_options: []
|
245
|
-
|
246
|
-
require_paths:
|
257
|
+
require_paths:
|
247
258
|
- lib
|
248
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
259
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
249
260
|
none: false
|
250
|
-
requirements:
|
251
|
-
- -
|
252
|
-
- !ruby/object:Gem::Version
|
253
|
-
|
254
|
-
|
255
|
-
- 0
|
256
|
-
version: "0"
|
257
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ! '>='
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
265
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
266
|
none: false
|
259
|
-
requirements:
|
260
|
-
- -
|
261
|
-
- !ruby/object:Gem::Version
|
262
|
-
|
263
|
-
segments:
|
264
|
-
- 0
|
265
|
-
version: "0"
|
267
|
+
requirements:
|
268
|
+
- - ! '>='
|
269
|
+
- !ruby/object:Gem::Version
|
270
|
+
version: '0'
|
266
271
|
requirements: []
|
267
|
-
|
268
272
|
rubyforge_project:
|
269
273
|
rubygems_version: 1.8.24
|
270
274
|
signing_key:
|
271
275
|
specification_version: 3
|
272
276
|
summary: Utilities for the Ruby Bioinformatics Toolkit (rbbt)
|
273
|
-
test_files:
|
277
|
+
test_files:
|
274
278
|
- test/test_helper.rb
|
275
279
|
- test/rbbt/util/test_tmpfile.rb
|
276
280
|
- test/rbbt/util/test_filecache.rb
|