rbbt-util 5.43.0 → 5.44.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/etc/app.d/base.rb +1 -1
- data/lib/rbbt/association/util.rb +1 -1
- data/lib/rbbt/hpc/batch.rb +19 -17
- data/lib/rbbt/persist/tsv/sharder.rb +1 -1
- data/lib/rbbt/tsv/accessor.rb +6 -11
- data/lib/rbbt/tsv/dumper.rb +21 -10
- data/lib/rbbt/tsv/index.rb +2 -1
- data/lib/rbbt/util/misc/math.rb +0 -1
- data/lib/rbbt/util/misc/omics.rb +2 -1
- data/lib/rbbt/util/misc/ssw.rb +298 -0
- data/lib/rbbt/util/open.rb +1 -1
- data/lib/rbbt/workflow/step/info.rb +3 -2
- data/lib/rbbt/workflow/step.rb +2 -1
- data/python/rbbt/__init__.py +2 -2
- data/share/rbbt_commands/workflow/server +6 -1
- data/share/rbbt_commands/workflow/task +1 -1
- metadata +5 -220
- data/test/rbbt/annotations/test_util.rb +0 -43
- data/test/rbbt/association/test_database.rb +0 -87
- data/test/rbbt/association/test_index.rb +0 -127
- data/test/rbbt/association/test_item.rb +0 -15
- data/test/rbbt/association/test_open.rb +0 -63
- data/test/rbbt/association/test_util.rb +0 -108
- data/test/rbbt/entity/test_identifiers.rb +0 -34
- data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -70
- data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -108
- data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -59
- data/test/rbbt/hpc/test_batch.rb +0 -64
- data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
- data/test/rbbt/hpc/test_orchestrate.rb +0 -144
- data/test/rbbt/hpc/test_pbs.rb +0 -43
- data/test/rbbt/hpc/test_slurm.rb +0 -28
- data/test/rbbt/knowledge_base/test_enrichment.rb +0 -50
- data/test/rbbt/knowledge_base/test_entity.rb +0 -62
- data/test/rbbt/knowledge_base/test_query.rb +0 -46
- data/test/rbbt/knowledge_base/test_registry.rb +0 -74
- data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
- data/test/rbbt/knowledge_base/test_traverse.rb +0 -133
- data/test/rbbt/persist/test_tsv.rb +0 -88
- data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
- data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
- data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
- data/test/rbbt/persist/tsv/test_lmdb.rb +0 -20
- data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
- data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
- data/test/rbbt/resource/test_path.rb +0 -49
- data/test/rbbt/test_annotations.rb +0 -167
- data/test/rbbt/test_association.rb +0 -103
- data/test/rbbt/test_entity.rb +0 -252
- data/test/rbbt/test_fix_width_table.rb +0 -135
- data/test/rbbt/test_knowledge_base.rb +0 -226
- data/test/rbbt/test_monitor.rb +0 -11
- data/test/rbbt/test_packed_index.rb +0 -68
- data/test/rbbt/test_persist.rb +0 -85
- data/test/rbbt/test_resource.rb +0 -110
- data/test/rbbt/test_tsv.rb +0 -669
- data/test/rbbt/test_workflow.rb +0 -609
- data/test/rbbt/tsv/parallel/test_through.rb +0 -40
- data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
- data/test/rbbt/tsv/test_accessor.rb +0 -319
- data/test/rbbt/tsv/test_attach.rb +0 -715
- data/test/rbbt/tsv/test_change_id.rb +0 -61
- data/test/rbbt/tsv/test_csv.rb +0 -49
- data/test/rbbt/tsv/test_excel.rb +0 -171
- data/test/rbbt/tsv/test_field_index.rb +0 -19
- data/test/rbbt/tsv/test_filter.rb +0 -187
- data/test/rbbt/tsv/test_index.rb +0 -308
- data/test/rbbt/tsv/test_manipulate.rb +0 -334
- data/test/rbbt/tsv/test_marshal.rb +0 -24
- data/test/rbbt/tsv/test_matrix.rb +0 -20
- data/test/rbbt/tsv/test_parallel.rb +0 -7
- data/test/rbbt/tsv/test_parser.rb +0 -101
- data/test/rbbt/tsv/test_stream.rb +0 -253
- data/test/rbbt/tsv/test_util.rb +0 -52
- data/test/rbbt/util/R/test_eval.rb +0 -43
- data/test/rbbt/util/R/test_model.rb +0 -128
- data/test/rbbt/util/R/test_plot.rb +0 -38
- data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
- data/test/rbbt/util/concurrency/test_processes.rb +0 -192
- data/test/rbbt/util/concurrency/test_threads.rb +0 -40
- data/test/rbbt/util/log/test_progress.rb +0 -111
- data/test/rbbt/util/misc/test_bgzf.rb +0 -48
- data/test/rbbt/util/misc/test_communication.rb +0 -13
- data/test/rbbt/util/misc/test_development.rb +0 -26
- data/test/rbbt/util/misc/test_format.rb +0 -10
- data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
- data/test/rbbt/util/misc/test_lock.rb +0 -77
- data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
- data/test/rbbt/util/misc/test_omics.rb +0 -116
- data/test/rbbt/util/misc/test_pipes.rb +0 -343
- data/test/rbbt/util/misc/test_serialize.rb +0 -24
- data/test/rbbt/util/python/test_util.rb +0 -25
- data/test/rbbt/util/simpleopt/test_get.rb +0 -12
- data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
- data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
- data/test/rbbt/util/test_R.rb +0 -37
- data/test/rbbt/util/test_chain_methods.rb +0 -22
- data/test/rbbt/util/test_cmd.rb +0 -87
- data/test/rbbt/util/test_colorize.rb +0 -22
- data/test/rbbt/util/test_concurrency.rb +0 -6
- data/test/rbbt/util/test_config.rb +0 -69
- data/test/rbbt/util/test_excel2tsv.rb +0 -10
- data/test/rbbt/util/test_filecache.rb +0 -36
- data/test/rbbt/util/test_log.rb +0 -52
- data/test/rbbt/util/test_migrate.rb +0 -34
- data/test/rbbt/util/test_misc.rb +0 -728
- data/test/rbbt/util/test_open.rb +0 -200
- data/test/rbbt/util/test_procpath.rb +0 -23
- data/test/rbbt/util/test_python.rb +0 -144
- data/test/rbbt/util/test_semaphore.rb +0 -36
- data/test/rbbt/util/test_simpleDSL.rb +0 -55
- data/test/rbbt/util/test_simpleopt.rb +0 -11
- data/test/rbbt/util/test_ssh.rb +0 -10
- data/test/rbbt/util/test_tmpfile.rb +0 -32
- data/test/rbbt/workflow/step/test_dependencies.rb +0 -295
- data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
- data/test/rbbt/workflow/test_doc.rb +0 -30
- data/test/rbbt/workflow/test_remote_workflow.rb +0 -99
- data/test/rbbt/workflow/test_schedule.rb +0 -0
- data/test/rbbt/workflow/test_step.rb +0 -231
- data/test/rbbt/workflow/test_task.rb +0 -85
- data/test/rbbt/workflow/util/test_archive.rb +0 -27
- data/test/rbbt/workflow/util/test_data.rb +0 -67
- data/test/rbbt/workflow/util/test_orchestrator.rb +0 -263
- data/test/test_helper.rb +0 -114
@@ -1,202 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/util/misc/multipart_payload'
|
3
|
-
|
4
|
-
class TestMultipartPayload < Test::Unit::TestCase
|
5
|
-
|
6
|
-
URL='http://localhost:2887/Echo'
|
7
|
-
def _test_post_data_stream
|
8
|
-
content =<<-EOF
|
9
|
-
Line 1
|
10
|
-
Line 2
|
11
|
-
Line 3
|
12
|
-
END
|
13
|
-
EOF
|
14
|
-
mutipart =<<-EOF
|
15
|
-
--Rbbt_Param_Stream<>
|
16
|
-
Content-Disposition: form-data; name="input1"<>
|
17
|
-
Content-Transfer-Encoding: binary<>
|
18
|
-
Content-Type: text/plain<>
|
19
|
-
<>
|
20
|
-
Input1<>
|
21
|
-
--Rbbt_Param_Stream<>
|
22
|
-
Content-Disposition: form-data; name="input2"<>
|
23
|
-
Content-Transfer-Encoding: binary<>
|
24
|
-
Content-Type: text/plain<>
|
25
|
-
<>
|
26
|
-
Input2<>
|
27
|
-
--Rbbt_Param_Stream<>
|
28
|
-
Content-Disposition: form-data; name="stream_input"<>
|
29
|
-
Content-Transfer-Encoding: binary<>
|
30
|
-
Content-Type: text/plain<>
|
31
|
-
<>
|
32
|
-
Line 1
|
33
|
-
Line 2
|
34
|
-
Line 3
|
35
|
-
END
|
36
|
-
<>
|
37
|
-
--Rbbt_Param_Stream--<>
|
38
|
-
<>
|
39
|
-
EOF
|
40
|
-
TmpFile.with_file(content) do |tmpfile|
|
41
|
-
inputs = {}
|
42
|
-
stream_input = :stream_input
|
43
|
-
inputs[:input1] = "Input1"
|
44
|
-
inputs[:input2] = "Input2"
|
45
|
-
inputs[:stream_input] = Open.open(tmpfile)
|
46
|
-
|
47
|
-
post_data_stream = RbbtMutiplartPayload.post_data_stream(inputs, stream_input, inputs[stream_input])
|
48
|
-
assert_equal mutipart, post_data_stream.read.gsub(/\r\n/,"<>\n")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def _test_issue
|
53
|
-
content =<<-EOF
|
54
|
-
Line 1
|
55
|
-
Line 2
|
56
|
-
Line 3
|
57
|
-
END
|
58
|
-
EOF
|
59
|
-
mutipart =<<-EOF
|
60
|
-
--Rbbt_Param_Stream<>
|
61
|
-
Content-Disposition: form-data; name="input1"<>
|
62
|
-
Content-Transfer-Encoding: binary<>
|
63
|
-
Content-Type: text/plain<>
|
64
|
-
<>
|
65
|
-
Input1<>
|
66
|
-
--Rbbt_Param_Stream<>
|
67
|
-
Content-Disposition: form-data; name="input2"<>
|
68
|
-
Content-Transfer-Encoding: binary<>
|
69
|
-
Content-Type: text/plain<>
|
70
|
-
<>
|
71
|
-
Input2<>
|
72
|
-
--Rbbt_Param_Stream<>
|
73
|
-
Content-Disposition: form-data; name="stream_input"; filename="FILENAME"<>
|
74
|
-
Content-Transfer-Encoding: binary<>
|
75
|
-
Content-Type: text/plain<>
|
76
|
-
<>
|
77
|
-
Line 1
|
78
|
-
Line 2
|
79
|
-
Line 3
|
80
|
-
END
|
81
|
-
<>
|
82
|
-
--Rbbt_Param_Stream--<>
|
83
|
-
<>
|
84
|
-
DONE_PARAM_STREAM
|
85
|
-
EOF
|
86
|
-
inputs = {}
|
87
|
-
#mutipart.gsub!('<>',"\r")
|
88
|
-
stream_input = :stream_input
|
89
|
-
inputs[:input1] = "Input1"
|
90
|
-
inputs[:input2] = "Input2"
|
91
|
-
num = 50
|
92
|
-
cpus = 1
|
93
|
-
TmpFile.with_file(content) do |tmpfile|
|
94
|
-
inputs = inputs.dup
|
95
|
-
inputs[:stream_input] = File.open(tmpfile)
|
96
|
-
|
97
|
-
io = RbbtMutiplartPayload.issue(URL, inputs, stream_input)
|
98
|
-
assert_equal mutipart.sub("FILENAME", tmpfile).force_encoding("ASCII"), io.read.gsub(/\r\n/,"<>\n")
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def _test_issue_multiple
|
103
|
-
content =<<-EOF
|
104
|
-
Line 1
|
105
|
-
Line 2
|
106
|
-
Line 3
|
107
|
-
END
|
108
|
-
EOF
|
109
|
-
mutipart =<<-EOF
|
110
|
-
--Rbbt_Param_Stream<>
|
111
|
-
Content-Disposition: form-data; name="input1"<>
|
112
|
-
Content-Transfer-Encoding: binary<>
|
113
|
-
Content-Type: text/plain<>
|
114
|
-
<>
|
115
|
-
Input1<>
|
116
|
-
--Rbbt_Param_Stream<>
|
117
|
-
Content-Disposition: form-data; name="input2"<>
|
118
|
-
Content-Transfer-Encoding: binary<>
|
119
|
-
Content-Type: text/plain<>
|
120
|
-
<>
|
121
|
-
Input2<>
|
122
|
-
--Rbbt_Param_Stream<>
|
123
|
-
Content-Disposition: form-data; name="stream_input"; filename="FILENAME"<>
|
124
|
-
Content-Transfer-Encoding: binary<>
|
125
|
-
Content-Type: text/plain<>
|
126
|
-
<>
|
127
|
-
Line 1
|
128
|
-
Line 2
|
129
|
-
Line 3
|
130
|
-
END
|
131
|
-
<>
|
132
|
-
--Rbbt_Param_Stream--<>
|
133
|
-
<>
|
134
|
-
DONE_PARAM_STREAM
|
135
|
-
EOF
|
136
|
-
inputs = {}
|
137
|
-
stream_input = :stream_input
|
138
|
-
inputs[:input1] = "Input1"
|
139
|
-
inputs[:input2] = "Input2"
|
140
|
-
num = 100
|
141
|
-
cpus = 10
|
142
|
-
Misc.bootstrap((0..num-1).to_a, cpus) do |n|
|
143
|
-
TmpFile.with_file(content) do |tmpfile|
|
144
|
-
inputs = inputs.dup
|
145
|
-
inputs[:stream_input] = File.open(tmpfile)
|
146
|
-
|
147
|
-
io = RbbtMutiplartPayload.issue(URL, inputs, stream_input)
|
148
|
-
str = io.read
|
149
|
-
assert_equal mutipart.sub("FILENAME", tmpfile).force_encoding("ASCII"), str.gsub(/\r\n/,"<>\n")
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def _test_raw
|
155
|
-
mutipart =<<-EOF
|
156
|
-
--Rbbt_Param_Stream<>
|
157
|
-
Content-Disposition: form-data; name="input1"<>
|
158
|
-
Content-Transfer-Encoding: binary<>
|
159
|
-
Content-Type: text/plain<>
|
160
|
-
<>
|
161
|
-
Input1<>
|
162
|
-
--Rbbt_Param_Stream<>
|
163
|
-
Content-Disposition: form-data; name="input2"<>
|
164
|
-
Content-Transfer-Encoding: binary<>
|
165
|
-
Content-Type: text/plain<>
|
166
|
-
<>
|
167
|
-
Input2<>
|
168
|
-
--Rbbt_Param_Stream<>
|
169
|
-
Content-Disposition: form-data; name="stream_input"; filename="FILENAME"<>
|
170
|
-
Content-Transfer-Encoding: binary<>
|
171
|
-
Content-Type: text/plain<>
|
172
|
-
<>
|
173
|
-
Line 1
|
174
|
-
Line 2
|
175
|
-
Line 3
|
176
|
-
END
|
177
|
-
<>
|
178
|
-
--Rbbt_Param_Stream--<>
|
179
|
-
<>
|
180
|
-
EOF
|
181
|
-
mutipart.gsub!('<>',"\r")
|
182
|
-
inputs = {}
|
183
|
-
stream_input = :stream_input
|
184
|
-
inputs[:input1] = "Input1"
|
185
|
-
inputs[:input2] = "Input2"
|
186
|
-
num = 50
|
187
|
-
cpus = 1
|
188
|
-
|
189
|
-
Misc.bootstrap((0..num-1).to_a, cpus) do |n|
|
190
|
-
puts mutipart
|
191
|
-
TmpFile.with_file(mutipart, false) do |tmpfile|
|
192
|
-
inputs = inputs.dup
|
193
|
-
inputs[:stream_input] = File.open(tmpfile)
|
194
|
-
|
195
|
-
puts "wget '#{URL}' --post-file #{ tmpfile } -O -"
|
196
|
-
io = CMD.cmd("wget '#{URL}' --post-file #{ tmpfile } -O -", :pipe => true)
|
197
|
-
assert_equal mutipart, io.read
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
-
require 'test/unit'
|
3
|
-
require 'rbbt/util/misc/omics'
|
4
|
-
|
5
|
-
class TestMiscOmics < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def test_translate_dna_mutation_hgvs2rbbt
|
8
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.395G>A"), "A"
|
9
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1-124C>T"), "T"
|
10
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.639+6T>A"), "A"
|
11
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.3386-2A>G"), "G"
|
12
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.4090_4091insT"), "+T"
|
13
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.533_534insGGGG"), "+GGGG"
|
14
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.4249_4249delC"), "-"
|
15
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.464-2_465delAGTG"), "----"
|
16
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.209+1delGTAA"), "----"
|
17
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.371_397del27"), "---------------------------"
|
18
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1359+2_1359+11delTTAGAAGAGC"), "----------"
|
19
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.ins?"), "?(c.ins?)"
|
20
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?ins?"), "?(c.?_?ins?)"
|
21
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.184_185ins?"), "?(c.184_185ins?)"
|
22
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?ins57"), "+NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
|
23
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?insCT"), "+CT"
|
24
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?del?"), "?(c.?_?del?)"
|
25
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?"), "?(c.?)"
|
26
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(312)?"), "?(c.(312)?)"
|
27
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(1669_1671)>?"), "?"
|
28
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1050-?"), "?(c.1050-?)"
|
29
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(1347_1540)?"), "?(c.(1347_1540)?)"
|
30
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1-?_850+?del"), "?(c.1-?_850+?del)"
|
31
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.2289_?del(7236)"), "?(c.2289_?del(7236))"
|
32
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(3916_3927)del?"), "?(c.(3916_3927)del?)"
|
33
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1705_?del?"), "?(c.1705_?del?)"
|
34
|
-
assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1-?_421+?del"), "?(c.1-?_421+?del)"
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_translate_prot_mutation_hgvs2rbbt
|
38
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.Arg2459Gly"), "R2459G"
|
39
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.E255K"), "E255K"
|
40
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.E279Z"), "E279Z"
|
41
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.R132?"), "R132?"
|
42
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.*757?"), "*757?"
|
43
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.A2216>?"), "A2216Indel"
|
44
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.M552_W557>Z"), "M552Indel"
|
45
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.T1151_L1152insT"), "T1151Indel"
|
46
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.N771_P772ins?"), "N771Indel"
|
47
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.T310_?insKAAQRGA"), "T310Indel"
|
48
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.D579del"), "D579Indel"
|
49
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.E746_A750delELREA"), "E746Indel"
|
50
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.P14fs*?"), "P14Frameshift"
|
51
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.*588fs?"), "*588Frameshift"
|
52
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?fs*(46_47)"), nil
|
53
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(A443)fs*?"), nil
|
54
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(574_1542)fs*?"), nil
|
55
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?fs"), nil
|
56
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.fs*?"), nil
|
57
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?fs*?"), nil
|
58
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(P1249)fs*?"), nil
|
59
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?"), nil
|
60
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.WQQSYLD25?"), nil
|
61
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(449_514)?"), nil
|
62
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("?"), nil
|
63
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.0?"), nil
|
64
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?_?ins?"), nil
|
65
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?_?insXXXX"), nil
|
66
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(A775)ins?"), nil
|
67
|
-
assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?del"), nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_index_BED
|
71
|
-
text= ""
|
72
|
-
|
73
|
-
%w(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y MT).each do |chr|
|
74
|
-
%w(1 2 3 4 5 6 7 8).each do |i|
|
75
|
-
start = i.to_i * 100
|
76
|
-
eend = start + 50
|
77
|
-
id = [chr, i] * ":"
|
78
|
-
text << [chr, start.to_s, eend.to_s, id] * "\t" + "\n"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
io = Misc.open_pipe do |sin|
|
83
|
-
sin.write text
|
84
|
-
end
|
85
|
-
|
86
|
-
TmpFile.with_file do |dir|
|
87
|
-
index = Misc.index_BED(io, dir)
|
88
|
-
assert_equal ["1:1"], index["1:120:130"]
|
89
|
-
index = Misc.index_BED(io, dir)
|
90
|
-
assert_equal ["2:2"], index["2:220:230"]
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_sort_genomic_locations
|
95
|
-
mutations =<<-EOF.split("\n").shuffle
|
96
|
-
1:100:A
|
97
|
-
1:20:A
|
98
|
-
1:300:A
|
99
|
-
2:100:A
|
100
|
-
2:20:A
|
101
|
-
2:300:A
|
102
|
-
10:100:A
|
103
|
-
10:20:A
|
104
|
-
10:300:A
|
105
|
-
EOF
|
106
|
-
sorted = Misc.sort_mutation_stream(StringIO.new(mutations * "\n")).read.split("\n")
|
107
|
-
strict_sorted = Misc.sort_mutation_stream_strict(StringIO.new(mutations * "\n")).read.split("\n")
|
108
|
-
|
109
|
-
assert sorted.index("1:20:A") < sorted.index("1:100:A")
|
110
|
-
assert sorted.index("1:300:A") < sorted.index("10:300:A")
|
111
|
-
assert sorted.index("10:300:A") < sorted.index("2:300:A")
|
112
|
-
assert strict_sorted.index("1:20:A") < strict_sorted.index("1:100:A")
|
113
|
-
assert strict_sorted.index("1:300:A") < strict_sorted.index("10:300:A")
|
114
|
-
assert strict_sorted.index("2:300:A") < strict_sorted.index("10:300:A")
|
115
|
-
end
|
116
|
-
end
|
@@ -1,343 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
-
require 'test/unit'
|
3
|
-
require 'rbbt/tsv'
|
4
|
-
require 'rbbt/util/misc'
|
5
|
-
|
6
|
-
class TestMiscPipes < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def test_collapse_stream
|
9
|
-
text=<<-EOF
|
10
|
-
row1 A B C
|
11
|
-
row1 a b c
|
12
|
-
row2 AA BB CC
|
13
|
-
row2 aa bb cc
|
14
|
-
EOF
|
15
|
-
|
16
|
-
s = StringIO.new text
|
17
|
-
tsv = TSV.open Misc.collapse_stream(s,nil, " "), :sep => " "
|
18
|
-
assert_equal ["A", "a"], tsv["row1"][0]
|
19
|
-
assert_equal ["BB", "bb"], tsv["row2"][1]
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_collapse_sum
|
23
|
-
text=<<-EOF
|
24
|
-
row1 12
|
25
|
-
row1 4
|
26
|
-
row2 10
|
27
|
-
row2 6
|
28
|
-
EOF
|
29
|
-
|
30
|
-
s = StringIO.new text
|
31
|
-
stream = Misc.collapse_stream(s,nil, " ") do |parts|
|
32
|
-
next nil if parts.empty?
|
33
|
-
parts.first.split("|").collect{|p| p.to_f}.inject(0){|acc,e| acc += e}.to_s
|
34
|
-
end
|
35
|
-
tsv = TSV.open stream, :sep => " "
|
36
|
-
ppp tsv.to_s
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_collapse_stream_gap
|
40
|
-
text=<<-EOF
|
41
|
-
row2 AA BB
|
42
|
-
row2 aa bb cc
|
43
|
-
EOF
|
44
|
-
|
45
|
-
s = StringIO.new text
|
46
|
-
assert Misc.collapse_stream(s, nil, " ").read =~ /\|cc$/
|
47
|
-
|
48
|
-
text=<<-EOF
|
49
|
-
row2 aa bb cc
|
50
|
-
row2 AA BB
|
51
|
-
EOF
|
52
|
-
|
53
|
-
s = StringIO.new text
|
54
|
-
assert Misc.collapse_stream(s, nil, " ").read =~ /cc\|$/
|
55
|
-
|
56
|
-
text=<<-EOF
|
57
|
-
row2 AA BB
|
58
|
-
row2 aa bb cc
|
59
|
-
EOF
|
60
|
-
|
61
|
-
s = StringIO.new text
|
62
|
-
assert Misc.collapse_stream(s, nil, " ").read =~ /\|cc$/
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
def test_paste_stream
|
68
|
-
text1=<<-EOF
|
69
|
-
row1 A B C
|
70
|
-
row2 AA BB CC
|
71
|
-
row3 AAA BBB CCC
|
72
|
-
EOF
|
73
|
-
|
74
|
-
text2=<<-EOF
|
75
|
-
row1 a b
|
76
|
-
row2 aa bb
|
77
|
-
EOF
|
78
|
-
|
79
|
-
text3=<<-EOF
|
80
|
-
row1 c
|
81
|
-
row2 cc
|
82
|
-
row3 ccc
|
83
|
-
EOF
|
84
|
-
|
85
|
-
s1 = StringIO.new text1
|
86
|
-
s2 = StringIO.new text2
|
87
|
-
s3 = StringIO.new text3
|
88
|
-
tsv = TSV.open Misc.paste_streams([s1,s2,s3], nil, " "), :sep => " ", :type => :list
|
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", "", "", "ccc"], tsv["row3"]
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_sort_stream
|
95
|
-
text =<<-EOF
|
96
|
-
##
|
97
|
-
##
|
98
|
-
##
|
99
|
-
#Row LabelA LabelB LabelC
|
100
|
-
row2 AA BB CC
|
101
|
-
row3 AAA BBB CCC
|
102
|
-
row1 A B C
|
103
|
-
EOF
|
104
|
-
s = StringIO.new text
|
105
|
-
sorted = Misc.sort_stream(s)
|
106
|
-
assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
|
107
|
-
assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_sort_long_stream
|
111
|
-
text =<<-EOF
|
112
|
-
##
|
113
|
-
##
|
114
|
-
##
|
115
|
-
#Row LabelA LabelB LabelC
|
116
|
-
row2 AA BB CC
|
117
|
-
row3 AAA BBB CCC
|
118
|
-
row1 A B C
|
119
|
-
EOF
|
120
|
-
|
121
|
-
s = StringIO.new text + (text.split("\n")[-3..-1] * "\n" + "\n") * 10000
|
122
|
-
sorted = Misc.sort_stream(s)
|
123
|
-
assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
|
124
|
-
assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_sort_stream2
|
128
|
-
text =<<-EOF
|
129
|
-
##
|
130
|
-
##
|
131
|
-
##
|
132
|
-
#Row LabelA LabelB LabelC
|
133
|
-
row2 AA BB CC
|
134
|
-
row3 AAA BBB CCC
|
135
|
-
row1 A B C
|
136
|
-
EOF
|
137
|
-
s = StringIO.new text
|
138
|
-
sorted = Misc.sort_stream(Misc.sort_stream(s))
|
139
|
-
assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
|
140
|
-
assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_dup_stream
|
144
|
-
text =<<-EOF
|
145
|
-
#: :sep=" "
|
146
|
-
#Row LabelA LabelB LabelC
|
147
|
-
row2 AA BB CC
|
148
|
-
row3 AAA BBB CCC
|
149
|
-
row1 A B C
|
150
|
-
EOF
|
151
|
-
|
152
|
-
text = text * 10000
|
153
|
-
TmpFile.with_file(text) do |tmp|
|
154
|
-
io = Open.open(tmp)
|
155
|
-
dup = Misc.dup_stream(io)
|
156
|
-
new_text = StringIO.new ""
|
157
|
-
Misc.consume_stream dup, true, new_text
|
158
|
-
Misc.consume_stream io, false
|
159
|
-
new_text.rewind
|
160
|
-
assert_equal text, new_text.read
|
161
|
-
end
|
162
|
-
|
163
|
-
|
164
|
-
TmpFile.with_file(text) do |tmp|
|
165
|
-
io = Open.open(tmp)
|
166
|
-
dup = Misc.dup_stream(io)
|
167
|
-
Misc.consume_stream dup, true
|
168
|
-
assert_equal text, io.read
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
def test_dup_stream_multiple
|
173
|
-
text =<<-EOF
|
174
|
-
row2 AA BB CC
|
175
|
-
row3 AAA BBB CCC
|
176
|
-
row1 A B C
|
177
|
-
EOF
|
178
|
-
|
179
|
-
text = text * 10000
|
180
|
-
num = 5
|
181
|
-
str_io = StringIO.new
|
182
|
-
strs = []
|
183
|
-
num.times{ strs << StringIO.new }
|
184
|
-
TmpFile.with_file(text) do |tmp|
|
185
|
-
io = Open.open(tmp)
|
186
|
-
copies = Misc.dup_stream_multiple(io, num)
|
187
|
-
|
188
|
-
|
189
|
-
copies.each_with_index do |cio,i|
|
190
|
-
cio.add_callback do
|
191
|
-
str = strs[i]
|
192
|
-
str.rewind
|
193
|
-
assert_equal text, str.read
|
194
|
-
end
|
195
|
-
Misc.consume_stream cio, true, strs[i], false
|
196
|
-
end
|
197
|
-
|
198
|
-
|
199
|
-
Misc.consume_stream io, false, str_io, false
|
200
|
-
str_io.rewind
|
201
|
-
assert_equal text, str_io.read
|
202
|
-
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_remove_lines
|
207
|
-
text1 =<<-EOF
|
208
|
-
line1
|
209
|
-
line2
|
210
|
-
line3
|
211
|
-
line4
|
212
|
-
EOF
|
213
|
-
text2 =<<-EOF
|
214
|
-
line3
|
215
|
-
line1
|
216
|
-
EOF
|
217
|
-
|
218
|
-
TmpFile.with_file(text1) do |file1|
|
219
|
-
TmpFile.with_file(text2) do |file2|
|
220
|
-
assert ! Misc.remove_lines(file1, file2, true).read.split("\n").include?("line1")
|
221
|
-
assert Misc.remove_lines(file1, file2, true).read.split("\n").include?("line2")
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
def test_select_lines
|
229
|
-
text1 =<<-EOF
|
230
|
-
line1
|
231
|
-
line2
|
232
|
-
line3
|
233
|
-
line4
|
234
|
-
EOF
|
235
|
-
text2 =<<-EOF
|
236
|
-
line3
|
237
|
-
line1
|
238
|
-
line5
|
239
|
-
EOF
|
240
|
-
|
241
|
-
TmpFile.with_file(text1) do |file1|
|
242
|
-
TmpFile.with_file(text2) do |file2|
|
243
|
-
assert Misc.select_lines(file1, file2, true).read.split("\n").include?("line1")
|
244
|
-
assert ! Misc.select_lines(file1, file2, true).read.split("\n").include?("line2")
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_consume_into_string_io
|
250
|
-
text =<<-EOF
|
251
|
-
line1
|
252
|
-
line2
|
253
|
-
line3
|
254
|
-
line4
|
255
|
-
EOF
|
256
|
-
|
257
|
-
TmpFile.with_file(text) do |file|
|
258
|
-
out = StringIO.new
|
259
|
-
io = Open.open(file)
|
260
|
-
Misc.consume_stream(io, false, out, false)
|
261
|
-
out.rewind
|
262
|
-
assert_equal text, out.read
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_monitor
|
267
|
-
text =<<-EOF
|
268
|
-
line1
|
269
|
-
line2
|
270
|
-
line3
|
271
|
-
line4
|
272
|
-
EOF
|
273
|
-
|
274
|
-
TmpFile.with_file(text) do |file|
|
275
|
-
io = Open.open(file)
|
276
|
-
lines = Set.new
|
277
|
-
io2 = Misc.line_monitor_stream io do |line|
|
278
|
-
lines << line
|
279
|
-
end
|
280
|
-
Misc.consume_stream(io2, false)
|
281
|
-
assert_equal text, lines.to_a * ""
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_sort
|
286
|
-
assert_raise RbbtException do
|
287
|
-
io = Misc.open_pipe do |sin|
|
288
|
-
sin.puts "#START"
|
289
|
-
20.times do
|
290
|
-
sin.puts rand(1000).to_s
|
291
|
-
sleep 0.1
|
292
|
-
end
|
293
|
-
raise RbbtException
|
294
|
-
end
|
295
|
-
|
296
|
-
sio = Misc.sort_stream(io)
|
297
|
-
begin
|
298
|
-
Misc.consume_stream(sio, false, STDOUT)
|
299
|
-
rescue
|
300
|
-
raise $!
|
301
|
-
end
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_gz_pipe
|
306
|
-
text =<<-EOF
|
307
|
-
line1
|
308
|
-
line2
|
309
|
-
line3
|
310
|
-
line4
|
311
|
-
EOF
|
312
|
-
|
313
|
-
TmpFile.with_file nil, :extension => 'txt.gz' do |file|
|
314
|
-
sout = Misc.open_gz_pipe do |sin|
|
315
|
-
text.split("\n").each do |line|
|
316
|
-
sin.puts line
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
Open.mkdir File.basename(file)
|
321
|
-
thr1 = Misc.consume_stream(sout, true, file)
|
322
|
-
thr1.join
|
323
|
-
assert Open.gzip?(file)
|
324
|
-
assert_equal text, Open.read(file)
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
def test_open_pipe_error
|
329
|
-
sout = Misc.open_pipe do |sin|
|
330
|
-
10.times do |i|
|
331
|
-
sin.puts "line #{i}"
|
332
|
-
end
|
333
|
-
raise
|
334
|
-
end
|
335
|
-
|
336
|
-
TmpFile.with_file do |tmp|
|
337
|
-
#Misc.consume_stream(sout, false, tmp)
|
338
|
-
assert_raise do
|
339
|
-
Open.write(tmp, sout)
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|
343
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/util/misc/serialize'
|
3
|
-
|
4
|
-
class TestClass < Test::Unit::TestCase
|
5
|
-
def test_load_yaml
|
6
|
-
yaml_txt=<<-EOF
|
7
|
-
---
|
8
|
-
a: b
|
9
|
-
EOF
|
10
|
-
yaml_sio = StringIO.new yaml_txt
|
11
|
-
|
12
|
-
assert_equal "b", Misc.load_yaml(yaml_txt)["a"]
|
13
|
-
assert_equal "b", Misc.load_yaml(yaml_sio)["a"]
|
14
|
-
|
15
|
-
TmpFile.with_file yaml_txt do |yaml_file|
|
16
|
-
assert_equal "b", Misc.load_yaml(yaml_file)["a"]
|
17
|
-
Open.open(yaml_file) do |yaml_io|
|
18
|
-
assert_equal "b", Misc.load_yaml(yaml_io)["a"]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/util/python'
|
3
|
-
require 'rbbt/util/python/util'
|
4
|
-
|
5
|
-
class TestPythonUtil < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def test_tuple
|
8
|
-
tsv = TSV.setup([], :key_field => "Key", :fields => %w(Value1 Value2), :type => :list)
|
9
|
-
tsv["k1"] = %w(V1_1 V2_1)
|
10
|
-
tsv["k2"] = %w(V1_2 V2_2)
|
11
|
-
df = RbbtPython.tsv2df(tsv)
|
12
|
-
new_tsv = RbbtPython.df2tsv(df)
|
13
|
-
assert_equal tsv, new_tsv
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_numpy
|
17
|
-
ra = RbbtPython.run :numpy, :as => :np do
|
18
|
-
na = np.array([[[1,2,3], [4,5,6]]])
|
19
|
-
RbbtPython.numpy2ruby na
|
20
|
-
end
|
21
|
-
assert_equal 6, ra[0][1][2]
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|