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.
- checksums.yaml +4 -4
- data/lib/rbbt/association/util.rb +1 -1
- data/lib/rbbt/hpc/batch.rb +19 -17
- 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/open.rb +1 -1
- data/lib/rbbt/workflow/step/info.rb +1 -0
- data/lib/rbbt/workflow/step.rb +2 -1
- data/python/rbbt/__init__.py +2 -2
- data/share/rbbt_commands/workflow/task +1 -1
- metadata +4 -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,88 +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
|
-
|
9
|
-
class TestPersistTSV < Test::Unit::TestCase
|
10
|
-
MAX = 100_002
|
11
|
-
|
12
|
-
def tsv_path
|
13
|
-
Random.new
|
14
|
-
require 'rbbt/workflow'
|
15
|
-
Workflow.require_workflow "Genomes1000"
|
16
|
-
require 'rbbt/sources/genomes1000'
|
17
|
-
CMD.cmd("grep -v '^\\.\t' | head -n #{MAX}", :in => Genomes1000.mutations.open, :pipe => true)
|
18
|
-
end
|
19
|
-
|
20
|
-
def run_bechmark(file, engine)
|
21
|
-
Log.info "Testing #{ Term::ANSIColor.red(engine) }"
|
22
|
-
TmpFile.with_file nil, false do |tmp_file|
|
23
|
-
db= nil
|
24
|
-
|
25
|
-
Misc.benchmark(1, "Build database with #{MAX - 2} entries") do
|
26
|
-
db = TSV.open(file, :fields => [1], :persist => true, :persist_engine => engine, :persist_dir => tmp_file, :type => :single, :unnamed => true)
|
27
|
-
end
|
28
|
-
|
29
|
-
test = db.keys.sort{rand}[1..100000]
|
30
|
-
Misc.benchmark(5, "Access #{test.length} random entries") do
|
31
|
-
test.each do |k| db[k] end
|
32
|
-
end
|
33
|
-
Log.info "Profiling access to #{test.length} random entries"
|
34
|
-
Misc.profile :min_percent => 0.1 do
|
35
|
-
test.each do |k| db[k] end
|
36
|
-
end
|
37
|
-
assert_equal "1:10611:G", db["rs189107123"]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def __test_benchmark_tch
|
42
|
-
engine = "HDB"
|
43
|
-
run_bechmark(tsv_path, engine)
|
44
|
-
end
|
45
|
-
|
46
|
-
def __test_benchmark_tcb
|
47
|
-
engine = "BDB"
|
48
|
-
run_bechmark(tsv_path, engine)
|
49
|
-
end
|
50
|
-
|
51
|
-
def __test_benchmark_kch
|
52
|
-
engine = "kch"
|
53
|
-
run_bechmark(tsv_path, engine)
|
54
|
-
end
|
55
|
-
|
56
|
-
def __test_benchmark_kcb
|
57
|
-
engine = "kct"
|
58
|
-
run_bechmark(tsv_path, engine)
|
59
|
-
end
|
60
|
-
|
61
|
-
def __test_benchmark_cdb
|
62
|
-
engine = "CDB"
|
63
|
-
run_bechmark(tsv_path, engine)
|
64
|
-
end
|
65
|
-
|
66
|
-
def __test_benchmark_leveldb
|
67
|
-
engine = "LevelDB"
|
68
|
-
run_bechmark(tsv_path, engine)
|
69
|
-
end
|
70
|
-
|
71
|
-
def __test_benchmark_lmdb
|
72
|
-
engine = "LMDB"
|
73
|
-
run_bechmark(tsv_path, engine)
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_tsv_persist
|
77
|
-
content =<<-EOF
|
78
|
-
#: :cast=:to_f
|
79
|
-
#Key Value1 Value2
|
80
|
-
k1 1.1 2.1
|
81
|
-
k2 1.2 2.2
|
82
|
-
EOF
|
83
|
-
TmpFile.with_file(content) do |tsv_file|
|
84
|
-
tsv = TSV.open(tsv_file, :sep => " ", :persist => true, :type => :double, :merge => true)
|
85
|
-
assert_equal [[1.1], [2.1]], tsv["k1"]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,18 +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
|
-
class TestPersistTSVCDB < Test::Unit::TestCase
|
8
|
-
|
9
|
-
if Persist.respond_to? :open_cbd
|
10
|
-
def test_organism
|
11
|
-
require 'rbbt/sources/organism'
|
12
|
-
TmpFile.with_file nil do |tmp_file|
|
13
|
-
tsv = Organism.identifiers("Hsa").tsv(:key_field => "Associated Gene Name", :fields => ["Ensembl Gene ID"], :type => :single, :persist => true, :persist_engine => "CDB", :persist_dir => tmp_file)
|
14
|
-
assert_equal "ENSG00000141510", tsv["TP53"]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
-
require 'rbbt/persist'
|
3
|
-
require 'rbbt/persist/tsv'
|
4
|
-
require 'rbbt/annotations'
|
5
|
-
require 'rbbt/util/tmpfile'
|
6
|
-
require 'test/unit'
|
7
|
-
|
8
|
-
class TestPersistTSVKC < Test::Unit::TestCase
|
9
|
-
if Persist.respond_to? :open_kyotocabinet
|
10
|
-
def test_organism_kch
|
11
|
-
require 'rbbt/sources/organism'
|
12
|
-
TmpFile.with_file do |tmp_file|
|
13
|
-
tsv = Organism.identifiers("Hsa").tsv :key_field => "Associated Gene Name", :fields => ["Ensembl Gene ID"], :type => :single, :persist => true, :persist_engine => "kch", :persist_dir => tmp_file
|
14
|
-
assert_equal "ENSG00000141510", tsv["TP53"]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
def test_organism_kct
|
20
|
-
require 'rbbt/sources/organism'
|
21
|
-
TmpFile.with_file do |tmp_file|
|
22
|
-
tsv = Organism.identifiers("Hsa").tsv :key_field => "Associated Gene Name", :fields => ["Ensembl Gene ID"], :type => :single, :persist => true, :persist_engine => "kct", :persist_dir => tmp_file
|
23
|
-
assert_equal "ENSG00000141510", tsv["TP53"]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,18 +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
|
-
class TestPersistTSVLevelDB < Test::Unit::TestCase
|
8
|
-
|
9
|
-
if Persist.respond_to? :open_leveldb
|
10
|
-
def test_organism
|
11
|
-
require 'rbbt/sources/organism'
|
12
|
-
TmpFile.with_file do |tmp_file|
|
13
|
-
tsv = Organism.identifiers("Hsa").tsv :key_field => "Associated Gene Name", :fields => ["Ensembl Gene ID"], :type => :single, :persist => true, :persist_engine => "LevelDB", :persist_dir => tmp_file
|
14
|
-
assert_equal "ENSG00000141510", tsv["TP53"]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,20 +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
|
-
class TestPersistTSVLMDB < Test::Unit::TestCase
|
8
|
-
|
9
|
-
def test_organism
|
10
|
-
keyword_test :lmdb do
|
11
|
-
require 'rbbt/sources/organism'
|
12
|
-
if Persist.respond_to? :open_lmdb
|
13
|
-
TmpFile.with_file do |tmp_file|
|
14
|
-
tsv = Organism.identifiers("Hsa").tsv :key_field => "Associated Gene Name", :fields => ["Ensembl Gene ID"], :type => :single, :persist => true, :persist_engine => "LMDB", :persist_dir => tmp_file
|
15
|
-
assert_equal "ENSG00000141510", tsv["TP53"]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -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
|