rbbt-util 5.43.0 → 5.44.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/association/util.rb +1 -1
  3. data/lib/rbbt/hpc/batch.rb +19 -17
  4. data/lib/rbbt/tsv/accessor.rb +6 -11
  5. data/lib/rbbt/tsv/dumper.rb +21 -10
  6. data/lib/rbbt/tsv/index.rb +2 -1
  7. data/lib/rbbt/util/misc/math.rb +0 -1
  8. data/lib/rbbt/util/open.rb +1 -1
  9. data/lib/rbbt/workflow/step/info.rb +1 -0
  10. data/lib/rbbt/workflow/step.rb +2 -1
  11. data/python/rbbt/__init__.py +2 -2
  12. data/share/rbbt_commands/workflow/task +1 -1
  13. metadata +4 -220
  14. data/test/rbbt/annotations/test_util.rb +0 -43
  15. data/test/rbbt/association/test_database.rb +0 -87
  16. data/test/rbbt/association/test_index.rb +0 -127
  17. data/test/rbbt/association/test_item.rb +0 -15
  18. data/test/rbbt/association/test_open.rb +0 -63
  19. data/test/rbbt/association/test_util.rb +0 -108
  20. data/test/rbbt/entity/test_identifiers.rb +0 -34
  21. data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -70
  22. data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -108
  23. data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -59
  24. data/test/rbbt/hpc/test_batch.rb +0 -64
  25. data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
  26. data/test/rbbt/hpc/test_orchestrate.rb +0 -144
  27. data/test/rbbt/hpc/test_pbs.rb +0 -43
  28. data/test/rbbt/hpc/test_slurm.rb +0 -28
  29. data/test/rbbt/knowledge_base/test_enrichment.rb +0 -50
  30. data/test/rbbt/knowledge_base/test_entity.rb +0 -62
  31. data/test/rbbt/knowledge_base/test_query.rb +0 -46
  32. data/test/rbbt/knowledge_base/test_registry.rb +0 -74
  33. data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
  34. data/test/rbbt/knowledge_base/test_traverse.rb +0 -133
  35. data/test/rbbt/persist/test_tsv.rb +0 -88
  36. data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
  37. data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
  38. data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
  39. data/test/rbbt/persist/tsv/test_lmdb.rb +0 -20
  40. data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
  41. data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
  42. data/test/rbbt/resource/test_path.rb +0 -49
  43. data/test/rbbt/test_annotations.rb +0 -167
  44. data/test/rbbt/test_association.rb +0 -103
  45. data/test/rbbt/test_entity.rb +0 -252
  46. data/test/rbbt/test_fix_width_table.rb +0 -135
  47. data/test/rbbt/test_knowledge_base.rb +0 -226
  48. data/test/rbbt/test_monitor.rb +0 -11
  49. data/test/rbbt/test_packed_index.rb +0 -68
  50. data/test/rbbt/test_persist.rb +0 -85
  51. data/test/rbbt/test_resource.rb +0 -110
  52. data/test/rbbt/test_tsv.rb +0 -669
  53. data/test/rbbt/test_workflow.rb +0 -609
  54. data/test/rbbt/tsv/parallel/test_through.rb +0 -40
  55. data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
  56. data/test/rbbt/tsv/test_accessor.rb +0 -319
  57. data/test/rbbt/tsv/test_attach.rb +0 -715
  58. data/test/rbbt/tsv/test_change_id.rb +0 -61
  59. data/test/rbbt/tsv/test_csv.rb +0 -49
  60. data/test/rbbt/tsv/test_excel.rb +0 -171
  61. data/test/rbbt/tsv/test_field_index.rb +0 -19
  62. data/test/rbbt/tsv/test_filter.rb +0 -187
  63. data/test/rbbt/tsv/test_index.rb +0 -308
  64. data/test/rbbt/tsv/test_manipulate.rb +0 -334
  65. data/test/rbbt/tsv/test_marshal.rb +0 -24
  66. data/test/rbbt/tsv/test_matrix.rb +0 -20
  67. data/test/rbbt/tsv/test_parallel.rb +0 -7
  68. data/test/rbbt/tsv/test_parser.rb +0 -101
  69. data/test/rbbt/tsv/test_stream.rb +0 -253
  70. data/test/rbbt/tsv/test_util.rb +0 -52
  71. data/test/rbbt/util/R/test_eval.rb +0 -43
  72. data/test/rbbt/util/R/test_model.rb +0 -128
  73. data/test/rbbt/util/R/test_plot.rb +0 -38
  74. data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
  75. data/test/rbbt/util/concurrency/test_processes.rb +0 -192
  76. data/test/rbbt/util/concurrency/test_threads.rb +0 -40
  77. data/test/rbbt/util/log/test_progress.rb +0 -111
  78. data/test/rbbt/util/misc/test_bgzf.rb +0 -48
  79. data/test/rbbt/util/misc/test_communication.rb +0 -13
  80. data/test/rbbt/util/misc/test_development.rb +0 -26
  81. data/test/rbbt/util/misc/test_format.rb +0 -10
  82. data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
  83. data/test/rbbt/util/misc/test_lock.rb +0 -77
  84. data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
  85. data/test/rbbt/util/misc/test_omics.rb +0 -116
  86. data/test/rbbt/util/misc/test_pipes.rb +0 -343
  87. data/test/rbbt/util/misc/test_serialize.rb +0 -24
  88. data/test/rbbt/util/python/test_util.rb +0 -25
  89. data/test/rbbt/util/simpleopt/test_get.rb +0 -12
  90. data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
  91. data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
  92. data/test/rbbt/util/test_R.rb +0 -37
  93. data/test/rbbt/util/test_chain_methods.rb +0 -22
  94. data/test/rbbt/util/test_cmd.rb +0 -87
  95. data/test/rbbt/util/test_colorize.rb +0 -22
  96. data/test/rbbt/util/test_concurrency.rb +0 -6
  97. data/test/rbbt/util/test_config.rb +0 -69
  98. data/test/rbbt/util/test_excel2tsv.rb +0 -10
  99. data/test/rbbt/util/test_filecache.rb +0 -36
  100. data/test/rbbt/util/test_log.rb +0 -52
  101. data/test/rbbt/util/test_migrate.rb +0 -34
  102. data/test/rbbt/util/test_misc.rb +0 -728
  103. data/test/rbbt/util/test_open.rb +0 -200
  104. data/test/rbbt/util/test_procpath.rb +0 -23
  105. data/test/rbbt/util/test_python.rb +0 -144
  106. data/test/rbbt/util/test_semaphore.rb +0 -36
  107. data/test/rbbt/util/test_simpleDSL.rb +0 -55
  108. data/test/rbbt/util/test_simpleopt.rb +0 -11
  109. data/test/rbbt/util/test_ssh.rb +0 -10
  110. data/test/rbbt/util/test_tmpfile.rb +0 -32
  111. data/test/rbbt/workflow/step/test_dependencies.rb +0 -295
  112. data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
  113. data/test/rbbt/workflow/test_doc.rb +0 -30
  114. data/test/rbbt/workflow/test_remote_workflow.rb +0 -99
  115. data/test/rbbt/workflow/test_schedule.rb +0 -0
  116. data/test/rbbt/workflow/test_step.rb +0 -231
  117. data/test/rbbt/workflow/test_task.rb +0 -85
  118. data/test/rbbt/workflow/util/test_archive.rb +0 -27
  119. data/test/rbbt/workflow/util/test_data.rb +0 -67
  120. data/test/rbbt/workflow/util/test_orchestrator.rb +0 -263
  121. data/test/test_helper.rb +0 -114
@@ -1,319 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
- require 'rbbt/tsv'
3
- require 'rbbt/util/tmpfile'
4
- require 'test/unit'
5
-
6
- class TestTSVAccessor < Test::Unit::TestCase
7
-
8
- def test_to_hash
9
- content =<<-EOF
10
- #Id ValueA ValueB OtherID
11
- row1 a|aa|aaa b Id1|Id2
12
- row2 A B Id3
13
- EOF
14
-
15
- TmpFile.with_file(content) do |filename|
16
- tsv = TSV.open(filename, :sep => /\s+/)
17
- hash = tsv.to_hash
18
- assert hash.methods.select{|m| m =~ /#{ TSV::KEY_PREFIX }/}.empty?
19
- end
20
- end
21
-
22
- def test_zip_new
23
- content =<<-EOF
24
- #Id ValueA ValueB OtherID
25
- row1 a|aa|aaa b|bb|bbb Id1|Id2|Id3
26
- EOF
27
-
28
- TmpFile.with_file(content) do |filename|
29
- tsv = TSV.open(filename, :sep => /\s+/)
30
- tsv.zip_new("row1", %w(aaaa bbbb Id4))
31
- assert_equal %w(b bb bbb bbbb), tsv["row1"]["ValueB"]
32
- end
33
- end
34
-
35
- def test_tsv
36
- content =<<-EOF
37
- #Id ValueA ValueB OtherID
38
- row1 a|aa|aaa b Id1|Id2
39
- row2 A B Id3
40
- EOF
41
-
42
- TmpFile.with_file(content) do |filename|
43
- tsv = TSV.open(filename, :sep => /\s+/)
44
- assert_equal 2, tsv.keys.length
45
- assert_equal 2, tsv.values.length
46
- assert_equal 2, tsv.collect.length
47
- end
48
- end
49
-
50
- def test_named_values
51
- content =<<-EOF
52
- #Id ValueA ValueB OtherID
53
- row1 a|aa|aaa b Id1|Id2
54
- row2 A B Id3
55
- EOF
56
-
57
- TmpFile.with_file(content) do |filename|
58
- tsv = TSV.open(filename, :sep => /\s+/)
59
- assert_equal ["A"], tsv["row2"]["ValueA"]
60
- end
61
- end
62
-
63
- def test_to_s
64
- content =<<-EOF
65
- #Id ValueA ValueB OtherID
66
- row1 a|aa|aaa b Id1|Id2
67
- row2 A B Id3
68
- EOF
69
-
70
- TmpFile.with_file(content) do |filename|
71
- tsv = TSV.open(filename, :sep => /\s+/)
72
- assert tsv.to_s =~ /row1\ta|aa|aaa/
73
- assert tsv.to_s =~ /:type=:double/
74
- end
75
- end
76
-
77
- def test_to_s_no_preable
78
- content =<<-EOF
79
- #Id ValueA ValueB OtherID
80
- row1 a|aa|aaa b Id1|Id2
81
- row2 A B Id3
82
- EOF
83
-
84
- target =<<-EOF
85
- Id,ValueA,ValueB,OtherID
86
- row1,a|aa|aaa,b,Id1|Id2
87
- row2,A,B,Id3
88
- EOF
89
-
90
- TmpFile.with_file(content) do |filename|
91
- tsv = TSV.open(filename, :sep => /\s+/)
92
- assert_equal tsv.to_s(preamble: false, header_hash: '').gsub(/\t/, ','), target
93
- end
94
- end
95
-
96
- def test_entries
97
- content =<<-EOF
98
- #Id ValueA ValueB OtherID
99
- row1 a|aa|aaa b Id1|Id2
100
- row2 A B Id3
101
- EOF
102
-
103
- TmpFile.with_file(content) do |filename|
104
- tsv = TSV.open(filename, :sep => /\s+/)
105
- assert_equal filename, tsv.options[:filename]
106
- end
107
-
108
- end
109
-
110
- def test_marshal
111
- content =<<-EOF
112
- #Id ValueA ValueB OtherID
113
- row1 a|aa|aaa b Id1|Id2
114
- row2 A B Id3
115
- EOF
116
-
117
- TmpFile.with_file(content) do |filename|
118
- tsv = TSV.open(filename, :sep => /\s+/, :persist_serializer => :marshal, :persist => true)
119
- assert_equal 2, tsv.size
120
- assert_equal filename, tsv.options[:filename]
121
- end
122
- end
123
-
124
- def test_zip_fields
125
- a = [%w(1 2), %w(a b)]
126
- assert_equal a, TSV.zip_fields(TSV.zip_fields(a))
127
- end
128
-
129
- def test_indentify_fields
130
- content =<<-EOF
131
- #ID ValueA ValueB Comment
132
- row1 a b c
133
- row2 A B C
134
- EOF
135
-
136
- TmpFile.with_file(content) do |filename|
137
- tsv = TSV.open(File.open(filename), :double, :sep => /\s/)
138
- assert_equal :key, tsv.identify_field("ID")
139
- end
140
- end
141
-
142
- def test_sort
143
- content =<<-EOF
144
- #ID ValueA ValueB Comment
145
- row1 a B c
146
- row2 A b C
147
- EOF
148
-
149
- TmpFile.with_file(content) do |filename|
150
- tsv = TSV.open(File.open(filename), :double, :sep => /\s/)
151
- assert_equal %w(row2 row1), tsv.tsv_sort{|a,b|
152
- a[1]["ValueA"] <=> b[1]["ValueA"]
153
- }.collect{|k,v| k}
154
- assert_equal %w(row1 row2), tsv.tsv_sort{|a,b|
155
- a[1]["ValueB"] <=> b[1]["ValueB"]
156
- }.collect{|k,v| k}
157
- end
158
- end
159
-
160
- def test_sort_by
161
- content =<<-EOF
162
- #ID ValueA ValueB Comment
163
- row1 a B c
164
- row2 A b C
165
- EOF
166
-
167
- TmpFile.with_file(content) do |filename|
168
- tsv = TSV.open(File.open(filename), :list, :sep => /\s/)
169
- assert_equal %w(row2 row1), tsv.sort_by("ValueA").collect{|k,v| k}
170
- assert_equal %w(row1 row2), tsv.sort_by("ValueB").collect{|k,v| k}
171
- end
172
- end
173
-
174
-
175
- def test_page
176
- content =<<-EOF
177
- #ID ValueA ValueB Comment
178
- row1 a B f
179
- row2 A b e
180
- row3 A b d
181
- row4 A b c
182
- row5 A b b
183
- row6 A b a
184
- EOF
185
-
186
- TmpFile.with_file(content) do |filename|
187
- tsv = TSV.open(File.open(filename), :list, :sep => /\s/)
188
- assert_equal 3, tsv.page(1,3).size
189
- assert_equal %w(row1 row2 row3).sort, tsv.page(1,3).keys.sort
190
- assert_equal %w(row6 row5 row4).sort, tsv.page(1,3, "Comment").keys.sort
191
- assert_equal %w(row4 row3).sort, tsv.page(2,2, "Comment").keys.sort
192
- end
193
- end
194
-
195
-
196
- def test_sort_by_with_proc
197
- content =<<-EOF
198
- #Id ValueA ValueB OtherID Pos
199
- row1 a|aa|aaa b Id1|Id2 2
200
- row2 aA B Id3 1
201
- row3 A|AA|AAA|AAA B Id3 3
202
- EOF
203
-
204
- TmpFile.with_file(content) do |filename|
205
- tsv = TSV.open(File.open(filename), :sep => /\s+/)
206
- assert_equal %w(row3 row1 row2), (tsv.sort_by("ValueA") do |key, value| value.length end).collect{|k,v| k}.reverse
207
- end
208
- end
209
-
210
- def test_chunked_values_at
211
- tsv = TSV.setup({})
212
- 10.times do |i|
213
- tsv[i] = i
214
- end
215
- pos = tsv.chunked_values_at (0..10-1).to_a, 2
216
- assert_equal (0..10-1).to_a, pos
217
- end
218
-
219
- def test_unzip
220
- content =<<-EOF
221
- #: :type=:list
222
- #PMID:Sentence number:TF:TG Transcription Factor (Associated Gene Name) Target Gene (Associated Gene Name) Sign Negation PMID
223
- 24265317:3:NR1H3:FASN NR1H3 FASN 24265317
224
- 17522048:0:NR1H3:FASN NR1H3 FASN + 17522048
225
- 19903962:0:NR1H3:FASN NR1H3 FASN 19903962
226
- 19903962:7:NR1H3:FASN NR1H3 FASN 19903962
227
- 22183856:4:NR1H3:FASN NR1H3 FASN 22183856
228
- 22641099:4:NR1H3:FASN NR1H3 FASN + 22641099
229
- 23499676:8:NR1H3:FASN NR1H3 FASN + 23499676
230
- 11790787:5:NR1H3:FASN NR1H3 FASN 11790787
231
- 11790787:7:NR1H3:FASN NR1H3 FASN + 11790787
232
- 11790787:9:NR1H3:FASN NR1H3 FASN + 11790787
233
- 11790787:11:NR1H3:FASN NR1H3 FASN 11790787
234
- 17522048:1:NR1H3:FASN NR1H3 FASN + 17522048
235
- 17522048:3:NR1H3:FASN NR1H3 FASN 17522048
236
- 22160584:1:NR1H3:FASN NR1H3 FASN 22160584
237
- 22160584:5:NR1H3:FASN NR1H3 FASN + 22160584
238
- 22160584:8:NR1H3:FASN NR1H3 FASN + 22160584
239
- EOF
240
-
241
- TmpFile.with_file(content) do |filename|
242
- tsv = TSV.open(filename, :key_field => "Transcription Factor (Associated Gene Name)", :fields => ["Target Gene (Associated Gene Name)", "Sign", "PMID"], :merge => true, :type => :double)
243
- unzip = tsv.unzip(0,true)
244
- assert_equal unzip["NR1H3:FASN"][0].length, unzip["NR1H3:FASN"][1].length
245
- end
246
- end
247
-
248
- def test_to_s_unmerge
249
- content =<<-EOF
250
- #Id ValueA ValueB OtherID
251
- row1 a|A b|B Id1|Id2
252
- row2 aa|aa|AA|AA b1|b2|B1|B2 Id1|Id1|Id2|Id2
253
- EOF
254
-
255
- TmpFile.with_file(content) do |filename|
256
- tsv = TSV.open(filename, :sep => /\s+/)
257
- assert_equal 6, CMD.cmd('grep -v "#" | cut -f 1', :in => tsv.to_s(nil, false, true)).read.split("\n").length
258
- end
259
- end
260
-
261
- def test_to_s_no_fields
262
- file1 =<<-EOF
263
- row6 dd dd ee
264
- row1 a b c
265
- row2 A B C
266
- row3 1 2 3
267
- EOF
268
- tsv1 = TSV.open StringIO.new(file1), :sep => " "
269
- assert tsv1.to_s(:sort, true).include?('dd')
270
- end
271
-
272
- def test_to_s_unmerge_expand
273
- content =<<-EOF
274
- #Id ValueA ValueB OtherID
275
- row1 a|A b|B Id1
276
- row2 aa|aa|AA|AA b1|b2|B1|B2 Id2
277
- EOF
278
-
279
- TmpFile.with_file(content) do |filename|
280
- tsv = TSV.open(filename, :sep => /\s+/)
281
- text = tsv.to_s(nil, false, :expand)
282
- assert text =~ /row2\taa\tb2\tId2/
283
- end
284
- end
285
-
286
- def test_remove_duplicates
287
- content =<<-EOF
288
- #Id ValueA ValueB OtherID
289
- row1 a|A|a|a b|B|b| Id1|Id2|Id1|Id1
290
- row2 aa|aa|AA|AA b1|b2|B1|B2 Id1|Id1|Id2|Id2
291
- EOF
292
-
293
- TmpFile.with_file(content) do |filename|
294
- tsv = TSV.open(filename, :sep => /\s+/)
295
- assert_equal %w(a A a), tsv.remove_duplicates["row1"]["ValueA"]
296
- assert tsv.remove_duplicates["row1"]["ValueB"].include?("")
297
- end
298
-
299
- end
300
-
301
- def test_unzip_zip
302
- content =<<-EOF
303
- #Id ValueA ValueB OtherID
304
- row1 a|A|a|a b|B|b| Id1|Id2|Id1|Id1
305
- row2 aa|aa|AA|AA b1|b2|B1|B2 Id1|Id1|Id2|Id2
306
- EOF
307
-
308
- TmpFile.with_file(content) do |filename|
309
- tsv = TSV.open(filename, :sep => /\s+/)
310
- assert_equal ["b", "b", ""], tsv.unzip("ValueA", true)["row1:a"]["ValueB"]
311
- assert_equal ["b", "b", "", "B"].sort, tsv.unzip("ValueA", true).zip(true)["row1"]["ValueB"].sort
312
- end
313
-
314
- end
315
-
316
- def test_identifier_files
317
- assert_include datadir_test.CollecTRI.identifier_files.first, "test/data"
318
- end
319
- end