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,164 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
-
require 'test/unit'
|
3
|
-
require 'rbbt-util'
|
4
|
-
require 'rbbt/persist/tsv'
|
5
|
-
|
6
|
-
class TestSharder < Test::Unit::TestCase
|
7
|
-
def test_shard
|
8
|
-
TmpFile.with_file do |dir|
|
9
|
-
shard_function = Proc.new do |key|
|
10
|
-
key[-1]
|
11
|
-
end
|
12
|
-
|
13
|
-
size = 10
|
14
|
-
sharder = Persist.persist_tsv(nil, "ShardTest", {}, :file => dir, :shard_function => shard_function, :persist => true, :serializer => :float_array) do |db|
|
15
|
-
size.times do |v|
|
16
|
-
db[v.to_s] = [v, v*2]
|
17
|
-
end
|
18
|
-
db
|
19
|
-
end
|
20
|
-
assert_equal dir, sharder.persistence_path
|
21
|
-
assert_equal size, sharder.keys.length
|
22
|
-
|
23
|
-
assert_equal [2,4], sharder["2"]
|
24
|
-
count = 0
|
25
|
-
sharder.through do |k,v|
|
26
|
-
count += 1
|
27
|
-
end
|
28
|
-
assert_equal count, size
|
29
|
-
|
30
|
-
sharder = Persist::Sharder.new dir do |key|
|
31
|
-
key[-1]
|
32
|
-
end
|
33
|
-
|
34
|
-
assert_equal size, sharder.keys.length
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_shard_fwt
|
40
|
-
TmpFile.with_file do |dir|
|
41
|
-
shard_function = Proc.new do |key|
|
42
|
-
key[0..(key.index(":")-1)]
|
43
|
-
end
|
44
|
-
|
45
|
-
pos_function = Proc.new do |key|
|
46
|
-
key.split(":").last.to_i
|
47
|
-
end
|
48
|
-
|
49
|
-
size = 10
|
50
|
-
sharder = Persist.persist_tsv(nil, "ShardTest", {}, :update => true, :range => false, :value_size => 64, :engine => 'fwt', :file => dir, :shard_function => shard_function, :pos_function => pos_function, :persist => true, :serializer => :float) do |db|
|
51
|
-
size.times do |v|
|
52
|
-
v = v + 1
|
53
|
-
chr = "chr" << (v % 5).to_s
|
54
|
-
key = chr + ":" << v.to_s
|
55
|
-
db << [key, v*2]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
sharder.read
|
59
|
-
|
60
|
-
assert_equal dir, sharder.persistence_path
|
61
|
-
assert_equal size, sharder.size
|
62
|
-
|
63
|
-
assert_equal [4.0], sharder["chr2:2"]
|
64
|
-
|
65
|
-
count = 0
|
66
|
-
sharder.through do |k,v|
|
67
|
-
count += 1
|
68
|
-
end
|
69
|
-
assert_equal count, size
|
70
|
-
|
71
|
-
sharder = Persist.open_sharder(dir, false, :float, 'fwt', {:range => false, :value_size => 64, :pos_function => pos_function}, &shard_function)
|
72
|
-
|
73
|
-
assert_equal [4.0], sharder["chr2:2"]
|
74
|
-
|
75
|
-
assert_equal size, sharder.size
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_shard_pki
|
80
|
-
TmpFile.with_file do |dir|
|
81
|
-
shard_function = Proc.new do |key|
|
82
|
-
key[0..(key.index(":")-1)]
|
83
|
-
end
|
84
|
-
|
85
|
-
pos_function = Proc.new do |key|
|
86
|
-
key.split(":").last.to_i
|
87
|
-
end
|
88
|
-
|
89
|
-
size = 10
|
90
|
-
chrs = (1..10).to_a
|
91
|
-
sharder = Persist.persist_tsv(nil, "ShardTest", {}, :pattern => %w(f), :update => true, :range => false, :value_size => 64, :engine => 'pki', :file => dir, :shard_function => shard_function, :pos_function => pos_function, :persist => true, :serializer => :clean) do |db|
|
92
|
-
chrs.each do |c|
|
93
|
-
size.times do |v|
|
94
|
-
v = v
|
95
|
-
chr = "chr" << c.to_s
|
96
|
-
key = chr + ":" << v.to_s
|
97
|
-
db << [key, [v*2]]
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
sharder.read
|
102
|
-
|
103
|
-
assert_equal dir, sharder.persistence_path
|
104
|
-
assert_equal size*chrs.length, sharder.size
|
105
|
-
|
106
|
-
assert_equal [4.0], sharder["chr2:2"]
|
107
|
-
|
108
|
-
count = 0
|
109
|
-
sharder.through do |k,v|
|
110
|
-
count += 1
|
111
|
-
end
|
112
|
-
assert_equal count, size*chrs.length
|
113
|
-
|
114
|
-
sharder = Persist.open_sharder(dir, false, :float, 'fwt', {:range => false, :value_size => 64, :pos_function => pos_function}, &shard_function)
|
115
|
-
|
116
|
-
assert_equal [4.0], sharder["chr2:2"]
|
117
|
-
|
118
|
-
assert_equal chrs.length*size, sharder.size
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_shard_pki_skip
|
123
|
-
TmpFile.with_file do |dir|
|
124
|
-
shard_function = Proc.new do |key|
|
125
|
-
key[0..(key.index(":")-1)]
|
126
|
-
end
|
127
|
-
|
128
|
-
pos_function = Proc.new do |key|
|
129
|
-
key.split(":").last.to_i
|
130
|
-
end
|
131
|
-
|
132
|
-
size = 10
|
133
|
-
chrs = (1..10).to_a
|
134
|
-
sharder = Persist.persist_tsv(nil, "ShardTest", {}, :pattern => %w(f), :update => true, :range => false, :value_size => 64, :engine => 'pki', :file => dir, :shard_function => shard_function, :pos_function => pos_function, :persist => true, :serializer => :clean) do |db|
|
135
|
-
chrs.each do |c|
|
136
|
-
size.times do |v|
|
137
|
-
v = v + 1
|
138
|
-
chr = "chr" << c.to_s
|
139
|
-
key = chr + ":" << (v*2).to_s
|
140
|
-
db << [key, [v*2]]
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
sharder.read
|
145
|
-
|
146
|
-
assert_equal dir, sharder.persistence_path
|
147
|
-
|
148
|
-
assert_equal [2.0], sharder["chr2:2"]
|
149
|
-
assert_equal [4.0], sharder["chr2:4"]
|
150
|
-
|
151
|
-
count = 0
|
152
|
-
sharder.through do |k,v|
|
153
|
-
count += 1 unless v.nil?
|
154
|
-
end
|
155
|
-
assert_equal count, size*chrs.length
|
156
|
-
|
157
|
-
sharder = Persist.open_sharder(dir, false, :float, 'fwt', {:range => false, :value_size => 64, :pos_function => pos_function}, &shard_function)
|
158
|
-
|
159
|
-
assert_equal [2.0], sharder["chr2:2"]
|
160
|
-
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
@@ -1,262 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
-
require 'rbbt/persist'
|
3
|
-
require 'rbbt/annotations'
|
4
|
-
require 'rbbt/util/tmpfile'
|
5
|
-
require 'test/unit'
|
6
|
-
|
7
|
-
|
8
|
-
module TestAnnotationModule
|
9
|
-
extend Annotation
|
10
|
-
|
11
|
-
self.annotation :test_annotation
|
12
|
-
end
|
13
|
-
|
14
|
-
class TestPersistTSVTC < Test::Unit::TestCase
|
15
|
-
|
16
|
-
def test_organism
|
17
|
-
require 'rbbt/sources/organism'
|
18
|
-
TmpFile.with_file do |tmp_file|
|
19
|
-
tsv = Organism.identifiers("Hsa").tsv :key_field => "Associated Gene Name", :fields => ["Ensembl Gene ID"], :type => :single, :persist => true, :persist_engine => "HDB", :persist_dir => tmp_file
|
20
|
-
assert_equal "ENSG00000141510", tsv["TP53"]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_annotation_persist
|
25
|
-
TmpFile.with_file do |tmp|
|
26
|
-
entity1 = "Entity 1"
|
27
|
-
entity2 = "Entity 2"
|
28
|
-
|
29
|
-
TestAnnotationModule.setup(entity1, :test_annotation => "1")
|
30
|
-
TestAnnotationModule.setup(entity2, :test_annotation => "2")
|
31
|
-
|
32
|
-
annotations = [entity1, entity2]
|
33
|
-
|
34
|
-
persisted_annotations = Persist.persist("Test", :annotations, :file => tmp) do
|
35
|
-
annotations
|
36
|
-
end
|
37
|
-
|
38
|
-
assert_equal "Entity 1", persisted_annotations.first
|
39
|
-
assert_equal "Entity 2", persisted_annotations.last
|
40
|
-
assert_equal "1", persisted_annotations.first.test_annotation
|
41
|
-
assert_equal "2", persisted_annotations.last.test_annotation
|
42
|
-
|
43
|
-
persisted_annotations = Persist.persist("Test", :annotations, :file => tmp) do
|
44
|
-
annotations
|
45
|
-
end
|
46
|
-
|
47
|
-
assert_equal "Entity 1", persisted_annotations.sort.first
|
48
|
-
assert_equal "Entity 2", persisted_annotations.sort.last
|
49
|
-
assert_equal "1", persisted_annotations.sort.first.test_annotation
|
50
|
-
assert_equal "2", persisted_annotations.sort.last.test_annotation
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_annotation_persist_with_repetitions
|
55
|
-
TmpFile.with_file do |tmp|
|
56
|
-
entity1 = "Entity 1"
|
57
|
-
entity2 = "Entity 2"
|
58
|
-
entity2bis = "Entity 2"
|
59
|
-
|
60
|
-
TestAnnotationModule.setup(entity1, :test_annotation => "1")
|
61
|
-
TestAnnotationModule.setup(entity2, :test_annotation => "2")
|
62
|
-
TestAnnotationModule.setup(entity2bis, :test_annotation => "2")
|
63
|
-
|
64
|
-
annotations = [entity1, entity2, entity2bis]
|
65
|
-
|
66
|
-
persisted_annotations = Persist.persist("Test", :annotations, :file => tmp) do
|
67
|
-
annotations
|
68
|
-
end
|
69
|
-
|
70
|
-
assert_equal 3, persisted_annotations.length
|
71
|
-
|
72
|
-
assert_equal "Entity 1", persisted_annotations.first
|
73
|
-
assert_equal "Entity 2", persisted_annotations.last
|
74
|
-
assert_equal "1", persisted_annotations.first.test_annotation
|
75
|
-
assert_equal "2", persisted_annotations.last.test_annotation
|
76
|
-
|
77
|
-
persisted_annotations = Persist.persist("Test", :annotations, :file => tmp) do
|
78
|
-
annotations
|
79
|
-
end
|
80
|
-
|
81
|
-
assert_equal 3, persisted_annotations.length
|
82
|
-
|
83
|
-
assert_equal "Entity 1", persisted_annotations.sort.first
|
84
|
-
assert_equal "Entity 2", persisted_annotations.sort.last
|
85
|
-
assert_equal "1", persisted_annotations.sort.first.test_annotation
|
86
|
-
assert_equal "2", persisted_annotations.sort.last.test_annotation
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_bdb
|
91
|
-
TmpFile.with_file do |tmp|
|
92
|
-
repo = Persist.open_tokyocabinet(tmp, true, :double, TokyoCabinet::BDB)
|
93
|
-
repo["test:string1"] = [["STR1"]]
|
94
|
-
repo["test:string2"] = [["STR2"]]
|
95
|
-
repo["other_test:string3"] = [["STR2"]]
|
96
|
-
|
97
|
-
assert_equal ["test:string1", "test:string2"].sort, repo.range("test:" << 0.chr, false, "test:" << 255.chr, false).sort
|
98
|
-
assert_equal ["other_test:string3"].sort, repo.range("other_test:" << 0.chr, false, "other_test:" << 255.chr, false).sort
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_annotation_persist_repo
|
103
|
-
TmpFile.with_file do |tmp|
|
104
|
-
repo = Persist.open_tokyocabinet(tmp, true, :list, TokyoCabinet::BDB)
|
105
|
-
|
106
|
-
entity1 = "Entity 1"
|
107
|
-
entity2 = "Entity 2"
|
108
|
-
|
109
|
-
TestAnnotationModule.setup(entity1, :test_annotation => "1")
|
110
|
-
TestAnnotationModule.setup(entity2, :test_annotation => "2")
|
111
|
-
|
112
|
-
annotations = [entity1, entity2]
|
113
|
-
|
114
|
-
persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
|
115
|
-
annotations
|
116
|
-
end
|
117
|
-
|
118
|
-
assert_equal "Entity 1", persisted_annotations.first
|
119
|
-
assert_equal "Entity 2", persisted_annotations.last
|
120
|
-
assert_equal "1", persisted_annotations.first.test_annotation
|
121
|
-
assert_equal "2", persisted_annotations.last.test_annotation
|
122
|
-
|
123
|
-
persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
|
124
|
-
annotations
|
125
|
-
end
|
126
|
-
|
127
|
-
assert_equal "Entity 1", persisted_annotations.sort.first
|
128
|
-
assert_equal "Entity 2", persisted_annotations.sort.last
|
129
|
-
assert_equal "1", persisted_annotations.sort.first.test_annotation
|
130
|
-
assert_equal "2", persisted_annotations.sort.last.test_annotation
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_annotation_persist_repo_annotated_array
|
135
|
-
TmpFile.with_file do |tmp|
|
136
|
-
repo = Persist.open_tokyocabinet(tmp, true, :list, TokyoCabinet::BDB)
|
137
|
-
|
138
|
-
entity1 = "Entity 1"
|
139
|
-
entity2 = "Entity 2"
|
140
|
-
|
141
|
-
annotations = [entity1, entity2]
|
142
|
-
TestAnnotationModule.setup(annotations, :test_annotation => "1")
|
143
|
-
annotations.extend AnnotatedArray
|
144
|
-
|
145
|
-
persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
|
146
|
-
annotations
|
147
|
-
end
|
148
|
-
|
149
|
-
assert_equal "Entity 1", persisted_annotations.first
|
150
|
-
assert_equal "Entity 2", persisted_annotations.last
|
151
|
-
assert_equal "1", persisted_annotations.first.test_annotation
|
152
|
-
assert_equal "1", persisted_annotations.last.test_annotation
|
153
|
-
|
154
|
-
persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
|
155
|
-
annotations
|
156
|
-
end
|
157
|
-
|
158
|
-
persisted_annotations.extend AnnotatedArray
|
159
|
-
|
160
|
-
assert_equal "Entity 1", persisted_annotations.sort.first
|
161
|
-
assert_equal "Entity 2", persisted_annotations.sort.last
|
162
|
-
assert_equal "1", persisted_annotations.sort.first.test_annotation
|
163
|
-
assert_equal "1", persisted_annotations.sort.last.test_annotation
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_annotation_persist_repo_triple_array
|
168
|
-
TmpFile.with_file(nil, false) do |tmp|
|
169
|
-
repo = Persist.open_database(tmp, true, :list, "BDB")
|
170
|
-
|
171
|
-
entity1 = "Entity 1"
|
172
|
-
entity2 = "Entity 2"
|
173
|
-
|
174
|
-
annotations = [entity1, entity2]
|
175
|
-
TestAnnotationModule.setup(annotations, :test_annotation => "1")
|
176
|
-
annotations.extend AnnotatedArray
|
177
|
-
|
178
|
-
annotations_ary = [annotations]
|
179
|
-
TestAnnotationModule.setup(annotations_ary, :test_annotation => "1")
|
180
|
-
annotations_ary.extend AnnotatedArray
|
181
|
-
|
182
|
-
persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
|
183
|
-
annotations_ary
|
184
|
-
end
|
185
|
-
assert AnnotatedArray === persisted_annotations
|
186
|
-
|
187
|
-
assert_equal "Entity 1", persisted_annotations.first.first
|
188
|
-
assert_equal "Entity 2", persisted_annotations.first.last
|
189
|
-
assert_equal "1", persisted_annotations.first.first.test_annotation
|
190
|
-
assert_equal "1", persisted_annotations.first.last.test_annotation
|
191
|
-
|
192
|
-
persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
|
193
|
-
annotations_ary
|
194
|
-
end
|
195
|
-
|
196
|
-
assert AnnotatedArray === persisted_annotations
|
197
|
-
|
198
|
-
assert_equal "Entity 1", persisted_annotations.sort.first.first
|
199
|
-
assert_equal "Entity 2", persisted_annotations.sort.first.last
|
200
|
-
assert_equal "1", persisted_annotations.sort.first.first.test_annotation
|
201
|
-
assert_equal "1", persisted_annotations.sort.first.last.test_annotation
|
202
|
-
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_annotation_persist_repo_with_repetitions
|
207
|
-
TmpFile.with_file do |tmp|
|
208
|
-
repo = Persist.open_tokyocabinet(tmp, true, :list, TokyoCabinet::BDB)
|
209
|
-
|
210
|
-
entity1 = "Entity 1"
|
211
|
-
entity2 = "Entity 2"
|
212
|
-
entity2bis = "Entity 2"
|
213
|
-
|
214
|
-
TestAnnotationModule.setup(entity1, :test_annotation => "1")
|
215
|
-
TestAnnotationModule.setup(entity2, :test_annotation => "2")
|
216
|
-
TestAnnotationModule.setup(entity2bis, :test_annotation => "2")
|
217
|
-
|
218
|
-
annotations = [entity1, entity2, entity2bis]
|
219
|
-
|
220
|
-
persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
|
221
|
-
annotations
|
222
|
-
end
|
223
|
-
|
224
|
-
assert_equal 3, persisted_annotations.length
|
225
|
-
|
226
|
-
assert_equal "Entity 1", persisted_annotations.first
|
227
|
-
assert_equal "Entity 2", persisted_annotations.last
|
228
|
-
assert_equal "1", persisted_annotations.first.test_annotation
|
229
|
-
assert_equal "2", persisted_annotations.last.test_annotation
|
230
|
-
|
231
|
-
persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
|
232
|
-
annotations
|
233
|
-
end
|
234
|
-
|
235
|
-
assert_equal 3, persisted_annotations.length
|
236
|
-
|
237
|
-
assert_equal "Entity 1", persisted_annotations.sort.first
|
238
|
-
assert_equal "Entity 2", persisted_annotations.sort.last
|
239
|
-
assert_equal "1", persisted_annotations.sort.first.test_annotation
|
240
|
-
assert_equal "2", persisted_annotations.sort.last.test_annotation
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
def __test_fdb
|
245
|
-
TmpFile.with_file do |tmp|
|
246
|
-
repo = Persist.open_tokyocabinet(tmp, true, :list, TokyoCabinet::FDB)
|
247
|
-
repo.write
|
248
|
-
repo.put(1, "hola")
|
249
|
-
repo.put(2, "adios")
|
250
|
-
47000.times do |i|
|
251
|
-
repo.put(i*500, "key: " << i.to_s)
|
252
|
-
end
|
253
|
-
repo.read
|
254
|
-
Misc.profile do
|
255
|
-
repo.values_at *repo.range("[100,1000]")
|
256
|
-
end
|
257
|
-
Misc.benchmark(60_000) do
|
258
|
-
repo.values_at *repo.range("[100,1000]")
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '../../../test_helper')
|
2
|
-
require 'rbbt/resource/path'
|
3
|
-
require 'rbbt/util/tmpfile'
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
|
-
class TestTSV < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def test_find
|
9
|
-
name = 'test_name_for_unexistent_file'
|
10
|
-
path = Path.setup "tmp/#{ name }"
|
11
|
-
|
12
|
-
TmpFile.with_file do |dir|
|
13
|
-
assert File.join(ENV['HOME'], path), path.find(nil, nil, {:root => File.join(dir, '{TOPLEVEL}/{SUBPATH}'), :default => :user, :user => File.join(ENV['HOME'], "{TOPLEVEL}", "{SUBPATH}")})
|
14
|
-
FileUtils.mkdir_p File.dirname(File.join(dir, path))
|
15
|
-
FileUtils.touch File.join(dir, path)
|
16
|
-
assert File.join(dir, "tmp/test"), path.find(nil, nil, {:root => File.join(dir, '{TOPLEVEL}/{SUBPATH}'), :default => :user, :user => File.join(ENV['HOME'], "{TOPLEVEL}", "{SUBPATH}")})
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_find_current
|
21
|
-
TmpFile.with_file do |dir|
|
22
|
-
Misc.in_dir dir do
|
23
|
-
CMD.cmd('touch foo')
|
24
|
-
p = Path.setup('foo')
|
25
|
-
assert_equal File.join(dir, 'foo'), p.find(:current)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_prev
|
31
|
-
path = Path.setup "/tmp"
|
32
|
-
assert_equal "/tmp/bar/foo", path.foo("bar")
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_doc_file
|
36
|
-
path = Path.setup "lib/rbbt/resource.rb"
|
37
|
-
assert_equal File.join('doc', path), path.doc_file
|
38
|
-
assert_equal Path.setup(File.join('doc', path)).find(:lib), path.find(:lib).doc_file
|
39
|
-
|
40
|
-
assert_equal "lib/rbbt/resource.rb", path.doc_file.source_for_doc_file
|
41
|
-
assert_equal File.realpath(path.find), File.realpath(path.doc_file.find(:lib).source_for_doc_file)
|
42
|
-
assert_equal File.realpath(path.find), File.realpath(path.doc_file.source_for_doc_file.find)
|
43
|
-
|
44
|
-
assert_equal "doc/lib/rbbt/resource.rb.doc", path.doc_file.set_extension('doc')
|
45
|
-
#assert_equal "lib/rbbt/resource.rb", path.doc_file.set_extension('doc').source_for_doc_file
|
46
|
-
|
47
|
-
assert_equal "doc/lib/rbbt/resource.rb.doc", path.doc_file.set_extension('doc')
|
48
|
-
end
|
49
|
-
end
|
@@ -1,167 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
-
require 'rbbt/annotations'
|
3
|
-
require 'rbbt/util/tmpfile'
|
4
|
-
require 'test/unit'
|
5
|
-
|
6
|
-
module AnnotatedString
|
7
|
-
extend Annotation
|
8
|
-
self.annotation :annotation_str
|
9
|
-
|
10
|
-
def add_annot
|
11
|
-
self + annotation_str
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
module AnnotatedString2
|
16
|
-
extend Annotation
|
17
|
-
include AnnotatedString
|
18
|
-
self.annotation :annotation_str2
|
19
|
-
end
|
20
|
-
|
21
|
-
class TestAnnotations < Test::Unit::TestCase
|
22
|
-
|
23
|
-
def test_annotated_string
|
24
|
-
assert_equal %w(annotation_str), AnnotatedString.annotations.collect{|a| a.to_s}
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_string
|
28
|
-
str = "string"
|
29
|
-
annotation_str = "Annotation String"
|
30
|
-
AnnotatedString.setup(str, annotation_str)
|
31
|
-
assert_equal [AnnotatedString], str.annotation_types
|
32
|
-
assert_equal annotation_str, str.annotation_str
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_array
|
36
|
-
ary = ["string"]
|
37
|
-
annotation_str = "Annotation String"
|
38
|
-
ary.extend AnnotatedArray
|
39
|
-
AnnotatedString.setup(ary, annotation_str)
|
40
|
-
assert_equal [AnnotatedString], ary.annotation_types
|
41
|
-
assert_equal annotation_str, ary.annotation_str
|
42
|
-
assert_equal annotation_str, ary[0].annotation_str
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def test_info
|
47
|
-
ary = ["string"]
|
48
|
-
annotation_str = "Annotation String"
|
49
|
-
AnnotatedString.setup(ary, annotation_str)
|
50
|
-
|
51
|
-
assert_equal({:annotation_str => annotation_str, :annotation_types => [AnnotatedString], :annotated_array => true}, ary.info)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_load
|
55
|
-
str = "string"
|
56
|
-
annotation_str = "Annotation String"
|
57
|
-
info = {:annotation_str => annotation_str, :annotation_types => [AnnotatedString]}
|
58
|
-
|
59
|
-
Annotated.load_entity(str, info)
|
60
|
-
assert_equal annotation_str, str.annotation_str
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_json
|
64
|
-
str1 = "string1"
|
65
|
-
annotation_str1 = "Annotation String 1"
|
66
|
-
str2 = "string2"
|
67
|
-
annotation_str2 = "Annotation String 2"
|
68
|
-
AnnotatedString.setup(str1, annotation_str1)
|
69
|
-
AnnotatedString.setup(str2, annotation_str2)
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_tsv
|
73
|
-
str1 = "string1"
|
74
|
-
annotation_str1 = "Annotation String 1"
|
75
|
-
str2 = "string2"
|
76
|
-
annotation_str2 = "Annotation String 2"
|
77
|
-
AnnotatedString.setup(str1, annotation_str1)
|
78
|
-
AnnotatedString.setup(str2, annotation_str2)
|
79
|
-
|
80
|
-
assert_equal str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + "#0"]["literal"]
|
81
|
-
assert_equal annotation_str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + "#0"]["annotation_str"]
|
82
|
-
assert_equal str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + "#0"]["literal"]
|
83
|
-
assert_equal annotation_str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + "#0"]["annotation_str"]
|
84
|
-
assert_equal annotation_str1, Annotated.tsv([str1, str2], :annotation_str, :JSON).tap{|t| t.unnamed = false}[str1.id + "#0"]["annotation_str"]
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_literal
|
88
|
-
str = "string"
|
89
|
-
annotation_str = "Annotation String"
|
90
|
-
AnnotatedString.setup(str, annotation_str)
|
91
|
-
assert_equal ["string"], str.tsv_values("literal")
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_load_tsv
|
95
|
-
str1 = "string1"
|
96
|
-
annotation_str1 = "Annotation String 1"
|
97
|
-
str2 = "string2"
|
98
|
-
annotation_str2 = "Annotation String 2"
|
99
|
-
AnnotatedString.setup(str1, annotation_str1)
|
100
|
-
AnnotatedString.setup(str2, annotation_str2)
|
101
|
-
assert_equal annotation_str1, Annotated.load_tsv(Annotated.tsv([str1, str2], :all)).sort.first.annotation_str
|
102
|
-
assert_equal str1, Annotated.load_tsv(Annotated.tsv([str1, str2], :literal, :JSON)).sort.first
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_load_array_tsv
|
106
|
-
str1 = "string1"
|
107
|
-
str2 = "string2"
|
108
|
-
a = [str1, str2]
|
109
|
-
annotation_str = "Annotation String 2"
|
110
|
-
AnnotatedString.setup(a, annotation_str)
|
111
|
-
a.extend AnnotatedArray
|
112
|
-
|
113
|
-
|
114
|
-
assert_equal annotation_str, Annotated.load_tsv(Annotated.tsv(a, :all)).annotation_str
|
115
|
-
|
116
|
-
assert_equal str2, Annotated.load_tsv(Annotated.tsv(a, :literal, :JSON)).sort.last
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_inheritance
|
120
|
-
str = "string1"
|
121
|
-
annotation_str1 = "Annotation String 1"
|
122
|
-
annotation_str2 = "Annotation String 2"
|
123
|
-
AnnotatedString2.setup(str, annotation_str1, annotation_str2)
|
124
|
-
assert_equal annotation_str1, str.annotation_str
|
125
|
-
assert_equal annotation_str2, str.annotation_str2
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_annotation_methods
|
129
|
-
str = "string"
|
130
|
-
annotation_str = "Annotation String"
|
131
|
-
AnnotatedString.setup(str, annotation_str)
|
132
|
-
assert_equal str + annotation_str, str.add_annot
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_double_array_1
|
136
|
-
ary = ["string"]
|
137
|
-
annotation_str = "Annotation String"
|
138
|
-
ary.extend AnnotatedArray
|
139
|
-
ary_ary = [ary]
|
140
|
-
ary_ary.extend AnnotatedArray
|
141
|
-
AnnotatedString.setup(ary, annotation_str)
|
142
|
-
AnnotatedString.setup(ary_ary, annotation_str)
|
143
|
-
assert_equal [AnnotatedString], ary.annotation_types
|
144
|
-
assert_equal annotation_str, ary.annotation_str
|
145
|
-
assert_equal annotation_str, ary[0].annotation_str
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_double_array_2
|
149
|
-
a = ["a"]
|
150
|
-
b = AnnotatedString.setup([AnnotatedString.setup(["a"])])
|
151
|
-
AnnotatedString.setup(a)
|
152
|
-
a.extend AnnotatedArray
|
153
|
-
assert AnnotatedString === b[0]
|
154
|
-
b.extend AnnotatedArray
|
155
|
-
assert AnnotatedString === b[0, true]
|
156
|
-
assert(!a.double_array)
|
157
|
-
assert(b.double_array)
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_annotation_positional2hash
|
161
|
-
str = "string"
|
162
|
-
annotation_str = "Annotation String"
|
163
|
-
AnnotatedString.setup(str, :annotation_str => annotation_str)
|
164
|
-
assert_equal str + annotation_str, str.add_annot
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|