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,101 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'test_helper.rb'))
2
- require 'rbbt/tsv'
3
-
4
- class TestTSVParser < Test::Unit::TestCase
5
- def test_flat
6
- TmpFile.with_file do |tmpdir|
7
- file = File.join(tmpdir, 'file')
8
- str =<<-EOF
9
- #: :type=:flat#:sep=' '
10
- #Key Value
11
- a b c d e
12
- A B C D E
13
- EOF
14
- Open.write(file, str)
15
- Open.open(file) do |io|
16
- parser = TSV::Parser.new(io, :merge => true, :zipped => true)
17
- parser.traverse do |k,v|
18
- assert v.length > 1
19
- end
20
- end
21
- end
22
- end
23
-
24
- def test_traverse
25
-
26
- content =<<-EOF
27
- row1 a|aa|aaa b Id1|Id2
28
- EOF
29
-
30
- TmpFile.with_file(content) do |filename|
31
- TSV::Parser.traverse(Open.open(filename), :sep => /\s+/, :fields => [1], :type => :double) do |k,v|
32
- assert_equal ["row1"], k
33
- assert_equal [%w(a aa aaa)], v
34
- end
35
-
36
- TSV::Parser.traverse(Open.open(filename), :sep => /\s+/, :fields => [1], :type => :list) do |k,v|
37
- assert_equal "row1", k
38
- assert_equal ["a|aa|aaa"], v
39
- end
40
-
41
- TSV::Parser.traverse(Open.open(filename), :sep => /\s+/, :fields => [1], :type => :single) do |k,v|
42
- assert_equal "row1", k
43
- assert_equal "a|aa|aaa", v
44
- end
45
-
46
- TSV::Parser.traverse(Open.open(filename), :sep => /\s+/, :fields => [1], :type => :flat) do |k,v|
47
- assert_equal ["row1"], k
48
- assert_equal %w(a aa aaa), v
49
- end
50
- end
51
- end
52
-
53
- def test_fields
54
- TmpFile.with_file do |tmpdir|
55
- file = File.join(tmpdir, 'file')
56
- str =<<-EOF
57
- #: :type=:flat#:sep=' '
58
- #Key Value
59
- a b c d e
60
- A B C D E
61
- EOF
62
- Open.write(file, str)
63
- Open.open(file) do |io|
64
- parser = TSV::Parser.new(io, :merge => true, :zipped => true, :type => :double)
65
- parser.traverse do |k,v,f|
66
- assert_equal f, %w(Value)
67
- end
68
- end
69
- end
70
- end
71
-
72
- def test_merge
73
- content =<<-EOF
74
- #: :type=:double
75
- #PMID:Sentence number:TF:TG Transcription Factor (Associated Gene Name) Target Gene (Associated Gene Name) Sign Negation PMID
76
- 24265317:3:NR1H3:FASN NR1H3 FASN 24265317
77
- 17522048:0:NR1H3:FASN NR1H3 FASN + 17522048
78
- 19903962:0:NR1H3:FASN NR1H3 FASN 19903962
79
- 19903962:7:NR1H3:FASN NR1H3 FASN 19903962
80
- 22183856:4:NR1H3:FASN NR1H3 FASN 22183856
81
- 22641099:4:NR1H3:FASN NR1H3 FASN + 22641099
82
- 23499676:8:NR1H3:FASN NR1H3 FASN + 23499676
83
- 11790787:5:NR1H3:FASN NR1H3 FASN 11790787
84
- 11790787:7:NR1H3:FASN NR1H3 FASN + 11790787
85
- 11790787:9:NR1H3:FASN NR1H3 FASN + 11790787
86
- 11790787:11:NR1H3:FASN NR1H3 FASN 11790787
87
- 17522048:1:NR1H3:FASN NR1H3 FASN + 17522048
88
- 17522048:3:NR1H3:FASN NR1H3 FASN 17522048
89
- 22160584:1:NR1H3:FASN NR1H3 FASN 22160584
90
- 22160584:5:NR1H3:FASN NR1H3 FASN + 22160584
91
- 22160584:8:NR1H3:FASN NR1H3 FASN + 22160584
92
- EOF
93
-
94
- TmpFile.with_file(content) do |filename|
95
- tsv = TSV.open(filename, :key_field => "Transcription Factor (Associated Gene Name)", :fields => ["Target Gene (Associated Gene Name)", "Sign", "PMID"], :merge => true, :type => :double)
96
- assert_equal 16, tsv["NR1H3"]["Sign"].length
97
- end
98
- end
99
-
100
- end
101
-
@@ -1,253 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
- require 'rbbt/tsv'
3
- require 'rbbt/tsv/stream'
4
- require 'rbbt'
5
-
6
- class TestStream < Test::Unit::TestCase
7
-
8
- def test_collapse_stream
9
- text=<<-EOF
10
- #: :sep=" "
11
- #Row LabelA LabelB LabelC
12
- row1 A B C
13
- row1 a b c
14
- row2 AA BB CC
15
- row2 aa bb cc
16
- EOF
17
-
18
- s = StringIO.new text
19
- tsv = TSV.open TSV.collapse_stream(s)
20
- assert_equal ["A", "a"], tsv["row1"][0]
21
- assert_equal ["BB", "bb"], tsv["row2"][1]
22
- end
23
-
24
- def test_paste_stream
25
- text1=<<-EOF
26
- #: :sep=" "
27
- #Row LabelA LabelB LabelC
28
- row1 A B C
29
- row2 AA BB CC
30
- row3 AAA BBB CCC
31
- EOF
32
-
33
- text2=<<-EOF
34
- #: :sep=" "
35
- #Row Labela Labelb
36
- row1 a b
37
- row2 aa bb
38
- row3 aaa bbb
39
- EOF
40
-
41
- text3=<<-EOF
42
- #: :sep=" "
43
- #Row LabelC
44
- row1 c
45
- row2 cc
46
- row3 ccc
47
- EOF
48
-
49
- s1 = StringIO.new text1
50
- s2 = StringIO.new text2
51
- s3 = StringIO.new text3
52
- tsv = TSV.open TSV.paste_streams([s1,s2,s3], :sep => " ", :type => :list)
53
- assert_equal ["A", "B", "C", "a", "b", "c"], tsv["row1"]
54
- assert_equal ["AA", "BB", "CC", "aa", "bb", "cc"], tsv["row2"]
55
- assert_equal ["AAA", "BBB", "CCC", "aaa", "bbb", "ccc"], tsv["row3"]
56
- end
57
-
58
- def test_paste_stream_sort
59
- text1=<<-EOF
60
- #: :sep=" "
61
- #Row LabelA LabelB LabelC
62
- row2 AA BB CC
63
- row1 A B C
64
- row3 AAA BBB CCC
65
- EOF
66
-
67
- text2=<<-EOF
68
- #: :sep=" "
69
- #Row Labela Labelb
70
- row1 a b
71
- row3 aaa bbb
72
- row2 aa bb
73
- EOF
74
-
75
- text3=<<-EOF
76
- #: :sep=" "
77
- #Row Labelc
78
- row3 ccc
79
- row1 c
80
- row2 cc
81
- EOF
82
-
83
- s1 = StringIO.new text1
84
- s2 = StringIO.new text2
85
- s3 = StringIO.new text3
86
- tsv = TSV.open TSV.paste_streams([s1,s2,s3], :sep => " ", :type => :list, :sort => true)
87
- assert_equal "Row", tsv.key_field
88
- assert_equal %w(LabelA LabelB LabelC Labela Labelb Labelc), tsv.fields
89
- assert_equal ["A", "B", "C", "a", "b", "c"], tsv["row1"]
90
- assert_equal ["AA", "BB", "CC", "aa", "bb", "cc"], tsv["row2"]
91
- assert_equal ["AAA", "BBB", "CCC", "aaa", "bbb", "ccc"], tsv["row3"]
92
- end
93
-
94
- def test_paste_stream_missing_2
95
- text1=<<-EOF
96
- #: :sep=" "
97
- #Row LabelA LabelB LabelC
98
- row2 AA BB CC
99
- row1 A B C
100
- EOF
101
-
102
- text2=<<-EOF
103
- #: :sep=" "
104
- #Row Labela Labelb
105
- row2 aa bb
106
- EOF
107
-
108
- text3=<<-EOF
109
- #: :sep=" "
110
- #Row Labelc
111
- row3 ccc
112
- row2 cc
113
- EOF
114
-
115
- s1 = StringIO.new text1
116
- s2 = StringIO.new text2
117
- s3 = StringIO.new text3
118
- tsv = TSV.open TSV.paste_streams([s1,s2,s3], :sep => " ", :type => :list, :sort => true)
119
- assert_equal "Row", tsv.key_field
120
- assert_equal %w(LabelA LabelB LabelC Labela Labelb Labelc), tsv.fields
121
- assert_equal ["A", "B", "C", "", "", ""], tsv["row1"]
122
- assert_equal ["AA", "BB", "CC", "aa", "bb", "cc"], tsv["row2"]
123
- assert_equal ["", "", "", "", "", "ccc"], tsv["row3"]
124
- end
125
-
126
- def test_paste_stream_missing
127
- text1=<<-EOF
128
- #: :sep=" "
129
- #Row LabelA LabelB LabelC
130
- row2 AA BB CC
131
- row1 A B C
132
- EOF
133
-
134
- text2=<<-EOF
135
- #: :sep=" "
136
- #Row Labela Labelb
137
- row2 aa bb
138
- EOF
139
-
140
- text3=<<-EOF
141
- #: :sep=" "
142
- #Row Labelc
143
- row3 ccc
144
- row2 cc
145
- EOF
146
-
147
- s1 = StringIO.new text1
148
- s2 = StringIO.new text2
149
- s3 = StringIO.new text3
150
- tsv = TSV.open TSV.paste_streams([s1,s2,s3], :sep => " ", :type => :list, :sort => true)
151
- assert_equal "Row", tsv.key_field
152
- assert_equal %w(LabelA LabelB LabelC Labela Labelb Labelc), tsv.fields
153
- assert_equal ["A", "B", "C", "", "", ""], tsv["row1"]
154
- assert_equal ["AA", "BB", "CC", "aa", "bb", "cc"], tsv["row2"]
155
- assert_equal ["", "", "", "", "", "ccc"], tsv["row3"]
156
- end
157
-
158
- def test_paste_stream_missing_3
159
- text1=<<-EOF
160
- #: :sep=" "
161
- #Row LabelA LabelB LabelC
162
- row2 AA BB CC
163
- row1 A B C
164
- EOF
165
-
166
- text2=<<-EOF
167
- #: :sep=" "
168
- #Row Labelc
169
- EOF
170
-
171
- s1 = StringIO.new text1
172
- s2 = StringIO.new text2
173
- tsv = TSV.open TSV.paste_streams([s1,s2], :sep => " ", :type => :list, :sort => true)
174
- assert_equal "Row", tsv.key_field
175
- assert_equal %w(LabelA LabelB LabelC Labelc), tsv.fields
176
- assert_equal ["A", "B", "C", ""], tsv["row1"]
177
- assert_equal ["AA", "BB", "CC", ""], tsv["row2"]
178
- end
179
-
180
- def test_paste_stream_same_field
181
- text1=<<-EOF
182
- #: :sep=" "
183
- #Row LabelA
184
- row1 A
185
- row2 AA
186
- EOF
187
-
188
- text2=<<-EOF
189
- #: :sep=" "
190
- #Row LabelA
191
- row2 AAA
192
- EOF
193
-
194
- s1 = StringIO.new text1
195
- s2 = StringIO.new text2
196
- tsv = TSV.open TSV.paste_streams([s1,s2], :sep => " ", :type => :double, :sort => false, :same_fields => true)
197
- assert_equal "Row", tsv.key_field
198
- assert_equal ["AA", "AAA"], tsv["row2"][0]
199
- end
200
-
201
- def test_paste_stream_nohead
202
- text1=<<-EOF
203
- row1\tA
204
- row2\tAA
205
- EOF
206
-
207
- text2=<<-EOF
208
- row2\tAAA
209
- EOF
210
-
211
- s1 = StringIO.new text1
212
- s2 = StringIO.new text2
213
- tsv = TSV.open TSV.paste_streams([s1,s2], :type => :double, :sort => false, :same_fields => true)
214
- assert_equal ["AA", "AAA"], tsv["row2"][0]
215
- end
216
-
217
- def test_flat2double
218
- text1=<<-EOF
219
- #: :sep= #:type=:flat
220
- #Row LabelA
221
- row1 A AA AAA
222
- row2 a aa aaa
223
- EOF
224
-
225
- text2=<<-EOF
226
- #: :sep= #:type=:double
227
- #Row LabelA
228
- row1 A|AA|AAA
229
- row2 a|aa|aaa
230
- EOF
231
- s1 = StringIO.new text1
232
- s2 = TSV.stream_flat2double(s1, :sep => " ")
233
-
234
- assert_equal text2, s2.stream.read
235
- end
236
-
237
- def test_reorder_stream
238
- text=<<-EOF
239
- #: :sep=" "
240
- #Row LabelA LabelB LabelC
241
- row1 A B C
242
- row1 a b c
243
- row2 AA BB CC
244
- row2 aa bb cc
245
- row4 BBB CC
246
- EOF
247
-
248
- s = StringIO.new text
249
- dumper = TSV.reorder_stream_tsv(s, "LabelC", %w(Row LabelA))
250
- tsv = TSV.open TSV.collapse_stream(dumper.stream)
251
- assert_equal %w(row2 row4), tsv["CC"]["Row"]
252
- end
253
- end
@@ -1,52 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
- require 'rbbt/tsv'
3
- require 'rbbt/tsv/util'
4
- require 'rbbt/util/tmpfile'
5
- require 'test/unit'
6
-
7
- class TestTSVUtil < Test::Unit::TestCase
8
-
9
- def test_field_counts
10
- content =<<-EOF
11
- #Id ValueA ValueB OtherID
12
- row1 a|aa|aaa b Id1|Id2
13
- row2 A B Id3
14
- EOF
15
-
16
- TmpFile.with_file(content) do |filename|
17
- tsv = TSV.open(filename, :sep => /\s+/)
18
-
19
- assert_equal 2, TSV.field_match_counts(tsv, ["a","A","a","b","Id3"])["ValueA"]
20
- assert_equal nil, TSV.field_match_counts(tsv, ["ValueA"])["ValueA"]
21
- end
22
- end
23
-
24
- def test_replicates
25
- content =<<-EOF
26
- #Id ValueA ValueB OtherID
27
- row1 a|aa|aaa b|bb|bbb Id1|Id2|Id3
28
- row2 A B Id3
29
- EOF
30
-
31
- TmpFile.with_file(content) do |filename|
32
- tsv = TSV.open(filename, :sep => /\s+/)
33
-
34
- assert_equal 4, tsv.unzip_replicates.length
35
- assert_equal %w(aa bb Id2), tsv.unzip_replicates["row1(1)"]
36
- end
37
- end
38
-
39
- def test_merge
40
- content =<<-EOF
41
- #Id ValueA ValueB OtherID
42
- row1 a|aa|aaa b|bb|bbb Id1|Id2|Id3
43
- row2 A B Id3
44
- EOF
45
-
46
- TmpFile.with_file(content) do |filename|
47
- tsv = TSV.open(filename, :sep => /\s+/)
48
- tsv = tsv.merge({"row3" => [["A3"], ["B3"], ["Id4"]]})
49
- assert TSV === tsv
50
- end
51
- end
52
- end
@@ -1,43 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
- require 'rbbt/util/R/eval'
3
-
4
- class TestREval < Test::Unit::TestCase
5
- def test_get
6
- Misc.benchmark(1000) do
7
- a = R.eval <<-EOF
8
- p = 12
9
- a = p * 2
10
- c(a)
11
- EOF
12
- assert_equal 12 * 2, a
13
- end
14
- end
15
-
16
- def test_TSV_fork
17
- tsv = TSV.setup({"1" => "1"},:type => :single)
18
- a = tsv.R <<-EOF, :R_method => :eval
19
- p = 12
20
- a = p * 2
21
- c(a)
22
- EOF
23
-
24
- pid = Process.fork do
25
- a = tsv.R <<-EOF, :R_method => :eval
26
- p = 12
27
- a = p * 2
28
- c(a)
29
- EOF
30
- end
31
- s = Process.waitpid2 pid
32
- end
33
-
34
- def test_TSV
35
- tsv = TSV.setup({"1" => "1"},:type => :single)
36
- a = tsv.R <<-EOF, :R_method => :eval
37
- p = 12
38
- a = p * 2
39
- c(a)
40
- EOF
41
- end
42
- end
43
-
@@ -1,128 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
- require 'rbbt/util/R'
3
- require 'rbbt/util/R/model'
4
-
5
- class TestRModel < Test::Unit::TestCase
6
-
7
- def test_fit
8
- data = TSV.setup({}, :key_field => "Dose", :fields => ["Response"], :type => :single)
9
- 10.times do
10
- x = rand(10)
11
- y = 10 + 3 * x + rand * 4
12
- data[x] = y
13
- end
14
-
15
- model = R::Model.new "Test fit 2", "Response ~ Dose"
16
-
17
- model.fit(data, method='drm', :fct => "LL.3()") unless model.exists?
18
-
19
- x = 5
20
- y = 10 + 3 * x
21
- input = TSV.setup({"new 1" => [x]}, :key_field => "Code", :fields => ["Dose"], :type => :single)
22
- pred = model.predict(input)["new 1"]["Prediction"].to_f
23
- assert pred > y and pred < y + 4
24
- end
25
-
26
- def test_add_fit
27
- tsv = TSV.open datafile_test('dose_response'), :type => :list
28
- tsv = tsv.slice(["Dose", "Response"])
29
-
30
- result = tsv.R <<-EOF, :R_method => :shell
31
- library(drc, quietly=T)
32
- library(txtplot)
33
- data = rbbt.model.add_fit(data, Response ~ Dose, method=drm, classes='numeric', fct=LL.4(),na.action=na.omit)
34
- txtplot(data$Dose, data$Response)
35
- txtplot(data$Dose, data$Prediction)
36
- EOF
37
- assert result.fields.include? "Prediction"
38
- end
39
-
40
- def test_add_inpute
41
- tsv = TSV.open datafile_test('dose_response'), :type => :list
42
-
43
- result = tsv.R <<-EOF, :R_method => :eval
44
- library(drc, quietly=T)
45
- data = rbbt.model.inpute(data, CI ~ Dose, method=drm, classes='numeric', fct=LL.4(), na.action=na.exclude)
46
- EOF
47
-
48
- assert_equal result.size, result.column("CI").values.flatten.reject{|p| p.nil? or p.empty? or p == "NA"}.length
49
- end
50
-
51
- def __test_ab_surv_corr
52
- require 'rbbt/workflow'
53
- Workflow.require_workflow "Miller"
54
-
55
- require 'rbbt/util/R/model'
56
- require 'rbbt/util/R/svg'
57
-
58
- antibody = "14-3-3-Zeta(C)_GBL9006927"
59
-
60
- rppa = Miller.RPPA.data.tsv
61
- rppa.attach Miller.RPPA.labels
62
- viability = Miller.Viability.data.tsv
63
-
64
- viability.add_field "Perturbation" do |compound,values|
65
- values["Dose"].collect do |dose|
66
- compound.split("-").flatten.zip(dose.split("-")).collect{|p| p * "="} * "-"
67
- end
68
- end
69
-
70
- viability = viability.reorder "Perturbation", nil, :zipped => true
71
- compounds = viability.column("Compound").flatten.uniq
72
-
73
- rppa = rppa.select("Compound"){|c| ! c.include? "-" and compounds.include? c}
74
- rppa = rppa.slice([antibody,"Compound", "Dose"])
75
- rppa.rename_field antibody, "RPPA"
76
-
77
- model = R::Model.new "viability", "Effect ~ Dose", nil, "Compound" => :factor
78
-
79
- model.fit(viability.select("Compound"){|c| ! c.include? "-"}, 'lm')
80
-
81
- rppa = model.predict(rppa, "Prediction")
82
-
83
- plot_script = "plot<-ggplot(data=data) + geom_point(aes(x=RPPA, y=Prediction, color=Compound));"
84
-
85
- R::SVG.ggplotSVG rppa, plot_script, 7, 7, :R_method => :eval
86
- end
87
-
88
- def test_fit_fast
89
- data = TSV.setup({}, :key_field => "Dose", :fields => ["Response"], :type => :single)
90
- 10.times do
91
- x = rand(10)
92
- y = 10 + 3 * x + rand * 4
93
- data[x] = y
94
- end
95
-
96
- model = R::Model.new "Test fit 2", "Response ~ Dose", data, :fit => 'lm'
97
-
98
- x = 5
99
- y = 10 + 3 * x
100
-
101
- pred = model.predict x
102
- assert pred > y and pred < y + 4
103
-
104
- pred = model.predict [x, 2*x, 3*x]
105
- assert pred.first > y and pred.first < y + 4
106
-
107
-
108
- pred = model.predict "Dose" => x
109
- assert pred > y and pred < y + 4
110
- end
111
-
112
- def test_interval
113
- data = TSV.setup({}, :key_field => "Dose", :fields => ["Response"], :type => :single)
114
- 10.times do
115
- x = rand(10)
116
- y = 10 + 3 * x + rand * 4
117
- data[x] = y
118
- end
119
-
120
- model = R::Model.new "Test fit 2", "Response ~ Dose", data, :fit => 'lm'
121
-
122
- x = 5
123
- y = 10 + 3 * x
124
-
125
- pred = model.predict x
126
- assert pred > y and pred < y + 4
127
- end
128
- end
@@ -1,38 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
- require 'rbbt/util/R'
3
- require 'rbbt/util/R/plot'
4
-
5
- class TestRPlot < Test::Unit::TestCase
6
- def __test_ggplotgif
7
-
8
- x = R.eval_a 'rnorm(100, 0, 1)'
9
- data = TSV.setup(x, "Num~#:type=:single#:cast=:to_f")
10
-
11
- data.add_field "Val" do |k,v|
12
- k
13
- end
14
-
15
- R::GIF.eog(data, (0..10).to_a.collect{|i| 100.0 / 10**i}, <<-EOF, nil, nil, :delay => 100)
16
- rbbt.require('reshape')
17
- ggplot(data) + geom_density(bw=frame.value, aes(x=Val))
18
- EOF
19
-
20
- end
21
-
22
- def test_gif
23
-
24
- x = R.eval_a 'rnorm(100, 0, 1)'
25
- data = TSV.setup(x, "Num~#:type=:single#:cast=:to_f")
26
-
27
- data.add_field "Val" do |k,v|
28
- k
29
- end
30
-
31
- R::GIF.eog_plot(data, (0..10).to_a.collect{|i| 100.0 / 10**i}, <<-EOF, 400, 400, :delay => 10)
32
- rbbt.require('reshape')
33
- plot(density(data$Val, bw=frame.value))
34
- EOF
35
-
36
- end
37
- end
38
-
@@ -1,70 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../../../..', 'test_helper.rb')
2
-
3
- require 'rbbt-util'
4
- require 'rbbt/util/log'
5
- require 'rbbt/util/concurrency/processes/socket'
6
-
7
- class TestConcurrency < Test::Unit::TestCase
8
- def test_socket_push_pop
9
- obj1 = [1,[2,3,4]] #* 1000
10
- obj2 = ["1",["2","3","4"]] #* 1000
11
- obj3 = "some string"
12
- obj4 = TSV.setup({1 => 1})
13
-
14
- socket = RbbtProcessQueue::RbbtProcessSocket.new Marshal
15
- 10.times do
16
- socket.push(obj1)
17
- socket.push(obj2)
18
- socket.push(obj3)
19
- socket.push(obj4)
20
-
21
- assert_equal obj1, socket.pop
22
- assert_equal obj2, socket.pop
23
- assert_equal obj3, socket.pop
24
- assert_equal obj4, socket.pop
25
-
26
- end
27
-
28
- socket.swrite.close
29
- assert_raise ClosedStream do
30
- socket.pop
31
- end
32
-
33
- socket.clean
34
- end
35
- end
36
-
37
- if false and __FILE__ == $0
38
- socket = RbbtProcessQueue::RbbtProcessSocket.new
39
-
40
- obj = "Some string" * 1000
41
- Misc.benchmark(1000) do
42
- socket.push(obj)
43
- socket.pop
44
- end
45
-
46
- obj = ["Some string"] * 1000
47
- Misc.benchmark(1000) do
48
- socket.push(obj)
49
- socket.pop
50
- end
51
- socket.clean
52
-
53
-
54
- socket = RbbtProcessQueue::RbbtProcessSocket.new Marshal
55
-
56
- obj = "Some string" * 1000
57
- Misc.benchmark(1000) do
58
- socket.push(obj)
59
- socket.pop
60
- end
61
- socket.clean
62
-
63
- socket = RbbtProcessQueue::RbbtProcessSocket.new TSV::StringArraySerializer
64
- obj = ["Some string"] * 1000
65
- Misc.benchmark(1000) do
66
- socket.push(obj)
67
- socket.pop
68
- end
69
- socket.clean
70
- end