rbbt-util 5.42.0 → 5.44.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/annotations/util.rb +1 -1
  3. data/lib/rbbt/association/database.rb +2 -1
  4. data/lib/rbbt/association/index.rb +1 -0
  5. data/lib/rbbt/association/util.rb +14 -4
  6. data/lib/rbbt/entity.rb +6 -5
  7. data/lib/rbbt/hpc/batch.rb +19 -17
  8. data/lib/rbbt/hpc/orchestrate/batches.rb +1 -1
  9. data/lib/rbbt/hpc/orchestrate/chains.rb +3 -4
  10. data/lib/rbbt/knowledge_base/traverse.rb +24 -16
  11. data/lib/rbbt/persist/tsv/tokyocabinet.rb +1 -1
  12. data/lib/rbbt/resource/path.rb +7 -2
  13. data/lib/rbbt/resource.rb +1 -1
  14. data/lib/rbbt/tsv/accessor.rb +6 -11
  15. data/lib/rbbt/tsv/dumper.rb +21 -10
  16. data/lib/rbbt/tsv/index.rb +2 -1
  17. data/lib/rbbt/tsv/parallel/traverse.rb +44 -0
  18. data/lib/rbbt/tsv/parser.rb +7 -6
  19. data/lib/rbbt/tsv/serializers.rb +1 -1
  20. data/lib/rbbt/tsv/util.rb +12 -0
  21. data/lib/rbbt/util/log/progress.rb +1 -1
  22. data/lib/rbbt/util/misc/bgzf.rb +5 -4
  23. data/lib/rbbt/util/misc/development.rb +4 -4
  24. data/lib/rbbt/util/misc/math.rb +0 -1
  25. data/lib/rbbt/util/misc.rb +1 -1
  26. data/lib/rbbt/util/open.rb +1 -1
  27. data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +8 -3
  28. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +4 -0
  29. data/lib/rbbt/workflow/step/info.rb +1 -0
  30. data/lib/rbbt/workflow/step.rb +2 -1
  31. data/lib/rbbt/workflow/util/trace.rb +2 -2
  32. data/lib/rbbt/workflow.rb +2 -2
  33. data/python/rbbt/__init__.py +2 -2
  34. data/share/rbbt_commands/workflow/task +1 -1
  35. metadata +4 -220
  36. data/test/rbbt/annotations/test_util.rb +0 -43
  37. data/test/rbbt/association/test_database.rb +0 -89
  38. data/test/rbbt/association/test_index.rb +0 -127
  39. data/test/rbbt/association/test_item.rb +0 -15
  40. data/test/rbbt/association/test_open.rb +0 -63
  41. data/test/rbbt/association/test_util.rb +0 -108
  42. data/test/rbbt/entity/test_identifiers.rb +0 -74
  43. data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -113
  44. data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -139
  45. data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -92
  46. data/test/rbbt/hpc/test_batch.rb +0 -68
  47. data/test/rbbt/hpc/test_orchestrate.rb +0 -144
  48. data/test/rbbt/hpc/test_pbs.rb +0 -43
  49. data/test/rbbt/hpc/test_slurm.rb +0 -32
  50. data/test/rbbt/knowledge_base/test_enrichment.rb +0 -48
  51. data/test/rbbt/knowledge_base/test_entity.rb +0 -42
  52. data/test/rbbt/knowledge_base/test_query.rb +0 -46
  53. data/test/rbbt/knowledge_base/test_registry.rb +0 -81
  54. data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
  55. data/test/rbbt/knowledge_base/test_traverse.rb +0 -85
  56. data/test/rbbt/persist/test_tsv.rb +0 -88
  57. data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
  58. data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
  59. data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
  60. data/test/rbbt/persist/tsv/test_lmdb.rb +0 -18
  61. data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
  62. data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
  63. data/test/rbbt/resource/test_path.rb +0 -49
  64. data/test/rbbt/test_annotations.rb +0 -167
  65. data/test/rbbt/test_association.rb +0 -103
  66. data/test/rbbt/test_entity.rb +0 -249
  67. data/test/rbbt/test_fix_width_table.rb +0 -135
  68. data/test/rbbt/test_hpc.rb +0 -16
  69. data/test/rbbt/test_knowledge_base.rb +0 -149
  70. data/test/rbbt/test_monitor.rb +0 -11
  71. data/test/rbbt/test_packed_index.rb +0 -68
  72. data/test/rbbt/test_persist.rb +0 -85
  73. data/test/rbbt/test_resource.rb +0 -110
  74. data/test/rbbt/test_tsv.rb +0 -669
  75. data/test/rbbt/test_workflow.rb +0 -604
  76. data/test/rbbt/tsv/parallel/test_through.rb +0 -40
  77. data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
  78. data/test/rbbt/tsv/test_accessor.rb +0 -315
  79. data/test/rbbt/tsv/test_attach.rb +0 -718
  80. data/test/rbbt/tsv/test_change_id.rb +0 -61
  81. data/test/rbbt/tsv/test_csv.rb +0 -49
  82. data/test/rbbt/tsv/test_excel.rb +0 -171
  83. data/test/rbbt/tsv/test_field_index.rb +0 -19
  84. data/test/rbbt/tsv/test_filter.rb +0 -187
  85. data/test/rbbt/tsv/test_index.rb +0 -302
  86. data/test/rbbt/tsv/test_manipulate.rb +0 -337
  87. data/test/rbbt/tsv/test_marshal.rb +0 -24
  88. data/test/rbbt/tsv/test_matrix.rb +0 -20
  89. data/test/rbbt/tsv/test_parallel.rb +0 -7
  90. data/test/rbbt/tsv/test_parser.rb +0 -101
  91. data/test/rbbt/tsv/test_stream.rb +0 -253
  92. data/test/rbbt/tsv/test_util.rb +0 -52
  93. data/test/rbbt/util/R/test_eval.rb +0 -43
  94. data/test/rbbt/util/R/test_model.rb +0 -130
  95. data/test/rbbt/util/R/test_plot.rb +0 -38
  96. data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
  97. data/test/rbbt/util/concurrency/test_processes.rb +0 -192
  98. data/test/rbbt/util/concurrency/test_threads.rb +0 -40
  99. data/test/rbbt/util/log/test_progress.rb +0 -111
  100. data/test/rbbt/util/misc/test_bgzf.rb +0 -48
  101. data/test/rbbt/util/misc/test_communication.rb +0 -11
  102. data/test/rbbt/util/misc/test_development.rb +0 -26
  103. data/test/rbbt/util/misc/test_format.rb +0 -10
  104. data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
  105. data/test/rbbt/util/misc/test_lock.rb +0 -77
  106. data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
  107. data/test/rbbt/util/misc/test_omics.rb +0 -116
  108. data/test/rbbt/util/misc/test_pipes.rb +0 -343
  109. data/test/rbbt/util/misc/test_serialize.rb +0 -24
  110. data/test/rbbt/util/python/test_util.rb +0 -25
  111. data/test/rbbt/util/simpleopt/test_get.rb +0 -12
  112. data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
  113. data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
  114. data/test/rbbt/util/test_R.rb +0 -37
  115. data/test/rbbt/util/test_chain_methods.rb +0 -22
  116. data/test/rbbt/util/test_cmd.rb +0 -87
  117. data/test/rbbt/util/test_colorize.rb +0 -22
  118. data/test/rbbt/util/test_concurrency.rb +0 -6
  119. data/test/rbbt/util/test_config.rb +0 -69
  120. data/test/rbbt/util/test_excel2tsv.rb +0 -10
  121. data/test/rbbt/util/test_filecache.rb +0 -36
  122. data/test/rbbt/util/test_log.rb +0 -52
  123. data/test/rbbt/util/test_migrate.rb +0 -36
  124. data/test/rbbt/util/test_misc.rb +0 -723
  125. data/test/rbbt/util/test_open.rb +0 -200
  126. data/test/rbbt/util/test_procpath.rb +0 -23
  127. data/test/rbbt/util/test_python.rb +0 -140
  128. data/test/rbbt/util/test_semaphore.rb +0 -36
  129. data/test/rbbt/util/test_simpleDSL.rb +0 -55
  130. data/test/rbbt/util/test_simpleopt.rb +0 -11
  131. data/test/rbbt/util/test_ssh.rb +0 -10
  132. data/test/rbbt/util/test_tmpfile.rb +0 -32
  133. data/test/rbbt/workflow/step/test_dependencies.rb +0 -299
  134. data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
  135. data/test/rbbt/workflow/test_doc.rb +0 -30
  136. data/test/rbbt/workflow/test_remote_workflow.rb +0 -98
  137. data/test/rbbt/workflow/test_schedule.rb +0 -0
  138. data/test/rbbt/workflow/test_step.rb +0 -231
  139. data/test/rbbt/workflow/test_task.rb +0 -85
  140. data/test/rbbt/workflow/util/test_archive.rb +0 -31
  141. data/test/rbbt/workflow/util/test_data.rb +0 -67
  142. data/test/rbbt/workflow/util/test_orchestrator.rb +0 -273
  143. data/test/test_helper.rb +0 -90
@@ -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,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 TestPersistTSVLMDB < Test::Unit::TestCase
8
-
9
- def test_organism
10
- require 'rbbt/sources/organism'
11
- if Persist.respond_to? :open_lmdb
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 => "LMDB", :persist_dir => tmp_file
14
- assert_equal "ENSG00000141510", tsv["TP53"]
15
- end
16
- end
17
- end
18
- 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