rbbt-util 5.42.0 → 5.43.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/annotations/util.rb +1 -1
- data/lib/rbbt/association/database.rb +2 -1
- data/lib/rbbt/association/index.rb +1 -0
- data/lib/rbbt/association/util.rb +13 -3
- data/lib/rbbt/entity.rb +6 -5
- data/lib/rbbt/hpc/orchestrate/batches.rb +1 -1
- data/lib/rbbt/hpc/orchestrate/chains.rb +3 -4
- data/lib/rbbt/knowledge_base/traverse.rb +24 -16
- data/lib/rbbt/persist/tsv/tokyocabinet.rb +1 -1
- data/lib/rbbt/resource/path.rb +7 -2
- data/lib/rbbt/resource.rb +1 -1
- data/lib/rbbt/tsv/parallel/traverse.rb +44 -0
- data/lib/rbbt/tsv/parser.rb +7 -6
- data/lib/rbbt/tsv/serializers.rb +1 -1
- data/lib/rbbt/tsv/util.rb +12 -0
- data/lib/rbbt/util/log/progress.rb +1 -1
- data/lib/rbbt/util/misc/bgzf.rb +5 -4
- data/lib/rbbt/util/misc/development.rb +4 -4
- data/lib/rbbt/util/misc.rb +1 -1
- data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +8 -3
- data/lib/rbbt/workflow/remote_workflow/remote_step.rb +4 -0
- data/lib/rbbt/workflow/util/trace.rb +2 -2
- data/lib/rbbt/workflow.rb +2 -2
- data/test/rbbt/association/test_database.rb +0 -2
- data/test/rbbt/association/test_open.rb +1 -1
- data/test/rbbt/entity/test_identifiers.rb +7 -47
- data/test/rbbt/hpc/orchestrate/test_batches.rb +2 -45
- data/test/rbbt/hpc/orchestrate/test_chains.rb +13 -44
- data/test/rbbt/hpc/orchestrate/test_rules.rb +2 -35
- data/test/rbbt/hpc/test_batch.rb +18 -22
- data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
- data/test/rbbt/hpc/test_pbs.rb +1 -1
- data/test/rbbt/hpc/test_slurm.rb +6 -10
- data/test/rbbt/knowledge_base/test_enrichment.rb +5 -3
- data/test/rbbt/knowledge_base/test_entity.rb +26 -6
- data/test/rbbt/knowledge_base/test_query.rb +1 -1
- data/test/rbbt/knowledge_base/test_registry.rb +34 -41
- data/test/rbbt/knowledge_base/test_traverse.rb +106 -58
- data/test/rbbt/persist/test_tsv.rb +4 -4
- data/test/rbbt/persist/tsv/test_lmdb.rb +7 -5
- data/test/rbbt/test_entity.rb +8 -5
- data/test/rbbt/test_knowledge_base.rb +107 -30
- data/test/rbbt/test_packed_index.rb +5 -5
- data/test/rbbt/test_tsv.rb +1 -1
- data/test/rbbt/test_workflow.rb +83 -78
- data/test/rbbt/tsv/test_accessor.rb +4 -0
- data/test/rbbt/tsv/test_attach.rb +2 -5
- data/test/rbbt/tsv/test_index.rb +8 -2
- data/test/rbbt/tsv/test_manipulate.rb +0 -3
- data/test/rbbt/util/R/test_model.rb +0 -2
- data/test/rbbt/util/misc/test_bgzf.rb +3 -3
- data/test/rbbt/util/misc/test_communication.rb +5 -3
- data/test/rbbt/util/test_migrate.rb +1 -3
- data/test/rbbt/util/test_misc.rb +7 -2
- data/test/rbbt/util/test_procpath.rb +1 -1
- data/test/rbbt/util/test_python.rb +12 -8
- data/test/rbbt/workflow/step/test_dependencies.rb +0 -4
- data/test/rbbt/workflow/test_remote_workflow.rb +6 -5
- data/test/rbbt/workflow/util/test_archive.rb +4 -8
- data/test/rbbt/workflow/util/test_orchestrator.rb +5 -15
- data/test/test_helper.rb +25 -1
- metadata +5 -5
- data/test/rbbt/test_hpc.rb +0 -16
@@ -7,11 +7,13 @@ require 'test/unit'
|
|
7
7
|
class TestPersistTSVLMDB < Test::Unit::TestCase
|
8
8
|
|
9
9
|
def test_organism
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
data/test/rbbt/test_entity.rb
CHANGED
@@ -54,7 +54,7 @@ module ReversableString
|
|
54
54
|
end
|
55
55
|
|
56
56
|
persist :reverse_text_ary_p, :marshal
|
57
|
-
persist :reverse_text_single_p, :memory
|
57
|
+
#persist :reverse_text_single_p, :memory
|
58
58
|
|
59
59
|
persist :reverse_text_ary_p_array, :array, :dir => TmpFile.tmp_file
|
60
60
|
|
@@ -133,12 +133,15 @@ class TestEntity < Test::Unit::TestCase
|
|
133
133
|
|
134
134
|
assert_equal 2, $count
|
135
135
|
|
136
|
+
a = ["String1", "String2"]
|
137
|
+
ReversableString.setup a
|
138
|
+
|
136
139
|
$count = 0
|
137
140
|
|
138
141
|
assert_equal "2gnirtS", a.reverse_text_single_p.last
|
139
|
-
assert_equal
|
142
|
+
assert_equal 2, $count
|
140
143
|
assert_equal "2gnirtS", a[1].reverse_text_single_p
|
141
|
-
assert_equal
|
144
|
+
assert_equal 3, $count
|
142
145
|
end
|
143
146
|
|
144
147
|
def test_property_ary_p_array
|
@@ -168,7 +171,7 @@ class TestEntity < Test::Unit::TestCase
|
|
168
171
|
|
169
172
|
# After persist
|
170
173
|
ReversableString.persist :random
|
171
|
-
assert
|
174
|
+
assert ReversableString.persisted?(:random)
|
172
175
|
|
173
176
|
r1 = a.random
|
174
177
|
r2 = a.random
|
@@ -176,7 +179,7 @@ class TestEntity < Test::Unit::TestCase
|
|
176
179
|
|
177
180
|
# After unpersist
|
178
181
|
ReversableString.unpersist :random
|
179
|
-
|
182
|
+
refute ReversableString.persisted?(:random)
|
180
183
|
|
181
184
|
r1 = a.random
|
182
185
|
r2 = a.random
|
@@ -50,77 +50,154 @@ end
|
|
50
50
|
class TestKnowledgeBase < Test::Unit::TestCase
|
51
51
|
def setup
|
52
52
|
require 'rbbt/sources/organism'
|
53
|
-
require 'rbbt/sources/tfacts'
|
54
|
-
require 'rbbt/sources/kegg'
|
55
53
|
|
56
54
|
Gene.add_identifiers Organism.identifiers("NAMESPACE"), "Ensembl Gene ID", "Associated Gene Name"
|
57
|
-
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_knowledge_base_simple
|
58
|
+
organism = Organism.default_code("Hsa")
|
59
|
+
TmpFile.with_file do |tmpdir|
|
60
|
+
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
61
|
+
kb.format = {"Gene" => "Ensembl Gene ID"}
|
62
|
+
|
63
|
+
kb.register :gene_ages, datadir_test.gene_ages
|
64
|
+
|
65
|
+
i = kb.get_index(:gene_ages)
|
66
|
+
|
67
|
+
assert_include i.match("ENSG00000000003"), "ENSG00000000003~Bilateria"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_knowledge_base_translate
|
72
|
+
organism = Organism.default_code("Hsa")
|
73
|
+
TmpFile.with_file do |tmpdir|
|
74
|
+
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
75
|
+
kb.format = {"Gene" => "Ensembl Gene ID"}
|
76
|
+
|
77
|
+
kb.register :gene_ages, datadir_test.gene_ages, :source => "FamilyAge", :target => "=>Associated Gene Name"
|
58
78
|
|
79
|
+
i = kb.get_index(:gene_ages)
|
80
|
+
|
81
|
+
assert_include i.match("Bilateria"), "Bilateria~SMAD4"
|
82
|
+
end
|
59
83
|
end
|
60
84
|
|
85
|
+
|
61
86
|
def test_knowledge_base_reverse
|
62
87
|
organism = Organism.default_code("Hsa")
|
63
88
|
TmpFile.with_file do |tmpdir|
|
64
89
|
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
65
90
|
kb.format = {"Gene" => "Ensembl Gene ID"}
|
66
91
|
|
67
|
-
kb.register :
|
92
|
+
kb.register :gene_ages, datadir_test.gene_ages
|
68
93
|
|
69
|
-
kb.get_index(:
|
94
|
+
ri = kb.get_index(:gene_ages).reverse
|
95
|
+
|
96
|
+
assert_include ri.match("Bilateria"), "Bilateria~ENSG00000000003"
|
70
97
|
end
|
71
98
|
end
|
72
99
|
|
73
|
-
def
|
100
|
+
def test_entity
|
74
101
|
organism = Organism.default_code("Hsa")
|
75
102
|
TmpFile.with_file do |tmpdir|
|
76
103
|
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
77
104
|
kb.format = {"Gene" => "Ensembl Gene ID"}
|
78
105
|
|
79
|
-
kb.register :
|
106
|
+
kb.register :gene_ages, datadir_test.gene_ages, :source => "=>Associated Gene Name"
|
80
107
|
|
81
|
-
|
108
|
+
kb.register :CollecTRI, datadir_test.CollecTRI,
|
109
|
+
:source => "Transcription Factor", :target => "Target Gene",
|
110
|
+
:fields => ["[ExTRI] Confidence", "[ExTRI] PMID"]
|
82
111
|
|
83
|
-
|
84
|
-
|
112
|
+
smad4 = Gene.setup("SMAD4", "Associated Gene Name", kb.namespace)
|
113
|
+
smad7 = Gene.setup("SMAD7", "Associated Gene Name", kb.namespace)
|
85
114
|
|
86
|
-
gene = Gene.setup("TP53", "Associated Gene Name", organism).ensembl
|
87
|
-
assert_equal "TP53", gene.name
|
88
|
-
assert_equal "ENSG00000141510", gene.ensembl
|
89
115
|
|
90
|
-
|
91
|
-
|
92
|
-
|
116
|
+
assert_include smad4.follow(kb, :CollecTRI), smad7
|
117
|
+
assert_include smad7.backtrack(kb, :CollecTRI), smad4
|
118
|
+
refute smad7.follow(kb, :CollecTRI).include?(smad4)
|
119
|
+
assert_include smad7.expand(kb, :CollecTRI), smad4
|
120
|
+
assert_include smad4.expand(kb, :CollecTRI), smad7
|
93
121
|
|
94
|
-
|
122
|
+
end
|
123
|
+
end
|
95
124
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
125
|
+
def __test_benchmark
|
126
|
+
organism = Organism.default_code("Hsa")
|
127
|
+
TmpFile.with_file do |tmpdir|
|
128
|
+
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
129
|
+
kb.format = {"Gene" => "Ensembl Gene ID"}
|
130
|
+
|
131
|
+
kb.register :gene_ages, datadir_test.gene_ages, :source => "=>Associated Gene Name"
|
132
|
+
|
133
|
+
kb.register :CollecTRI, datadir_test.CollecTRI,
|
134
|
+
:source => "Transcription Factor", :target => "Target Gene (Associated Gene Name)",
|
135
|
+
:fields => ["[ExTRI] Confidence", "[ExTRI] PMID"]
|
136
|
+
|
137
|
+
|
138
|
+
smad4 = Gene.setup("SMAD4", "Associated Gene Name", kb.namespace)
|
139
|
+
downstream = smad4.follow(kb, :CollecTRI, true)
|
140
|
+
Gene.setup(downstream)
|
141
|
+
|
142
|
+
downstream.follow(kb, :CollecTRI)
|
143
|
+
downstream.backtrack(kb, :CollecTRI)
|
144
|
+
downstream.expand(kb, :CollecTRI)
|
101
145
|
|
102
146
|
Misc.benchmark(50) do
|
103
|
-
downstream.follow(kb, :
|
104
|
-
downstream.backtrack(kb, :
|
105
|
-
downstream.expand(kb, :
|
147
|
+
downstream.follow(kb, :CollecTRI)
|
148
|
+
downstream.backtrack(kb, :CollecTRI)
|
149
|
+
downstream.expand(kb, :CollecTRI)
|
106
150
|
end
|
107
151
|
|
108
152
|
Misc.benchmark(50) do
|
109
|
-
downstream.follow(kb, :
|
110
|
-
downstream.backtrack(kb, :
|
111
|
-
downstream.expand(kb, :
|
153
|
+
downstream.follow(kb, :CollecTRI, true)
|
154
|
+
downstream.backtrack(kb, :CollecTRI, true)
|
155
|
+
downstream.expand(kb, :CollecTRI, true)
|
112
156
|
end
|
113
157
|
end
|
114
158
|
end
|
115
159
|
|
160
|
+
def test_identifier_files
|
161
|
+
organism = Organism.default_code("Hsa")
|
162
|
+
TmpFile.with_file do |tmpdir|
|
163
|
+
Path.setup(tmpdir)
|
164
|
+
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
165
|
+
|
166
|
+
kb.register :gene_ages, datadir_test.gene_ages
|
167
|
+
|
168
|
+
assert_include kb.get_database(:gene_ages).identifier_files.first, "test/data"
|
169
|
+
assert_include kb.get_index(:gene_ages).identifier_files.first, "test/data"
|
170
|
+
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
116
174
|
def test_knowledge_base_reuse
|
117
175
|
organism = Organism.default_code("Hsa")
|
118
176
|
TmpFile.with_file do |tmpdir|
|
119
177
|
Path.setup(tmpdir)
|
120
|
-
|
178
|
+
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
179
|
+
kb.register :CollecTRI, datadir_test.CollecTRI,
|
180
|
+
:source => "Transcription Factor=~Associated Gene Name=>Ensembl Gene ID", :target => "Target Gene",
|
181
|
+
:fields => ["[ExTRI] Confidence", "[ExTRI] PMID"]
|
182
|
+
|
183
|
+
assert kb.get_database(:CollecTRI).identifier_files.any?
|
184
|
+
|
185
|
+
i = Association.index(datadir_test.CollecTRI, :persist_file => tmpdir.CollecTRI,
|
186
|
+
:source => "Transcription Factor=~Associated Gene Name=>Ensembl Gene ID", :target => "Target Gene",
|
187
|
+
:fields => ["[ExTRI] Confidence", "[ExTRI] PMID"],
|
188
|
+
:format => {"Gene" => "Ensembl Gene ID"},
|
189
|
+
:namespace => Organism.default_code("Hsa"))
|
190
|
+
|
191
|
+
assert i.identifier_files.any?
|
121
192
|
|
122
193
|
kb = KnowledgeBase.load(tmpdir)
|
123
|
-
|
194
|
+
|
195
|
+
assert kb.get_database(:CollecTRI).identifier_files.any?
|
196
|
+
|
197
|
+
i = kb.get_index(:CollecTRI)
|
198
|
+
|
199
|
+
assert i.identifier_files.any?
|
200
|
+
assert kb.identify_source('CollecTRI', "SMAD4") =~ /ENSG/
|
124
201
|
end
|
125
202
|
end
|
126
203
|
|
@@ -2,7 +2,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'test_helper.r
|
|
2
2
|
require 'rbbt/packed_index'
|
3
3
|
|
4
4
|
class TestPackedIndex < Test::Unit::TestCase
|
5
|
-
def
|
5
|
+
def test_packed_index
|
6
6
|
|
7
7
|
TmpFile.with_file do |tmpfile|
|
8
8
|
pi = PackedIndex.new tmpfile, true, %w(i i 23s f f f f f)
|
@@ -14,10 +14,10 @@ class TestPackedIndex < Test::Unit::TestCase
|
|
14
14
|
pi.close
|
15
15
|
pi = PackedIndex.new(tmpfile, false)
|
16
16
|
Misc.benchmark(1000) do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
100.times do |i|
|
18
|
+
assert_equal i, pi[i][0]
|
19
|
+
assert_equal i+2, pi[i][1]
|
20
|
+
end
|
21
21
|
end
|
22
22
|
assert_equal nil, pi[100]
|
23
23
|
assert_equal nil, pi[101]
|
data/test/rbbt/test_tsv.rb
CHANGED
data/test/rbbt/test_workflow.rb
CHANGED
@@ -174,21 +174,26 @@ for this dependency
|
|
174
174
|
"alt"
|
175
175
|
end
|
176
176
|
|
177
|
+
task :overr_alt2 => :string do
|
178
|
+
"alt"
|
179
|
+
end
|
180
|
+
|
181
|
+
|
177
182
|
dep :overr_orig
|
178
183
|
task :overr_target => :string do
|
179
184
|
step(:overr_orig).load.reverse
|
180
185
|
end
|
181
186
|
|
182
187
|
dep :overr_alt, :not_overriden => true
|
183
|
-
dep :overr_target, "TestWF#overr_orig" => :overr_alt
|
188
|
+
dep :overr_target, "TestWF#overr_orig" => :overr_alt
|
184
189
|
task :overr_action => :string do
|
185
190
|
step(:overr_target).load.upcase
|
186
191
|
end
|
187
192
|
|
188
193
|
|
189
|
-
dep :
|
190
|
-
dep :overr_target, "TestWF#overr_orig" => :
|
191
|
-
task :
|
194
|
+
dep :overr_alt2, :not_overriden => true
|
195
|
+
dep :overr_target, "TestWF#overr_orig" => :overr_alt2, :not_overriden => true
|
196
|
+
task :not_overr_action => :string do
|
192
197
|
step(:overr_target).load.upcase
|
193
198
|
end
|
194
199
|
|
@@ -354,12 +359,10 @@ class TestWorkflow < Test::Unit::TestCase
|
|
354
359
|
|
355
360
|
def test_stream_order
|
356
361
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
job.produce
|
362
|
+
job = TestWF.job(:stream2)
|
363
|
+
job.recursive_clean
|
364
|
+
job.produce
|
361
365
|
|
362
|
-
end
|
363
366
|
end
|
364
367
|
|
365
368
|
def test_rec_input_use
|
@@ -450,13 +453,16 @@ class TestWorkflow < Test::Unit::TestCase
|
|
450
453
|
end
|
451
454
|
end
|
452
455
|
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
456
|
+
TmpFile.with_file("code") do |tmpfile|
|
457
|
+
job_orig = TestWF.job(:reverse_file, nil, :file => tmpfile)
|
458
|
+
TmpFile.with_file do |dir|
|
459
|
+
Path.setup(dir)
|
460
|
+
Step.save_job_inputs(job_orig, dir)
|
461
|
+
assert_equal [dir.file.find + '.as_path'], Dir.glob(dir + "/*")
|
462
|
+
inputs = Workflow.load_inputs(dir, [:file], :file => :file)
|
463
|
+
job = TestWF.job(:reverse_file, nil, inputs)
|
464
|
+
assert job_orig.path, job.path
|
465
|
+
end
|
460
466
|
end
|
461
467
|
|
462
468
|
end
|
@@ -507,11 +513,12 @@ class TestWorkflow < Test::Unit::TestCase
|
|
507
513
|
|
508
514
|
assert Symbol === job.step(:overr_orig).overriden
|
509
515
|
assert TrueClass === job.step(:overr_target).overriden
|
510
|
-
assert
|
516
|
+
assert job.overriden
|
511
517
|
|
512
|
-
job = TestWF.job(:
|
518
|
+
job = TestWF.job(:not_overr_action)
|
519
|
+
assert ! job.overriden
|
513
520
|
assert_equal "TLA", job.run
|
514
|
-
assert job.overriden
|
521
|
+
assert ! job.step(:overr_target).overriden
|
515
522
|
end
|
516
523
|
|
517
524
|
def test_anonymous_workflow
|
@@ -539,65 +546,63 @@ class TestWorkflow < Test::Unit::TestCase
|
|
539
546
|
end
|
540
547
|
|
541
548
|
def test_low_level_step
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
assert_equal "test -> s2 -> s3", s3.run
|
600
|
-
end
|
549
|
+
TmpFile.with_file do |tmpdir|
|
550
|
+
Path.setup tmpdir
|
551
|
+
|
552
|
+
s1 = Step.new tmpdir.s1 do "s1" end
|
553
|
+
s1.task_name = "s1"
|
554
|
+
|
555
|
+
# run clean run
|
556
|
+
assert_equal "s1", s1.run
|
557
|
+
s1.clean
|
558
|
+
assert_equal "s1", s1.run
|
559
|
+
assert_equal "s1", s1.run
|
560
|
+
|
561
|
+
# is persisted because it raises RbbtException
|
562
|
+
s1.task = proc do raise RbbtException end
|
563
|
+
assert_equal "s1", s1.run
|
564
|
+
s1.clean
|
565
|
+
assert_raises RbbtException do s1.run end
|
566
|
+
assert RbbtException === s1.get_exception
|
567
|
+
assert s1.error?
|
568
|
+
|
569
|
+
s1.recursive_clean
|
570
|
+
s1.task = proc do "s1" end
|
571
|
+
|
572
|
+
# add dependencies
|
573
|
+
s2 = Step.new tmpdir.s2 do
|
574
|
+
step(:s1).load + " -> s2"
|
575
|
+
end
|
576
|
+
s2.task_name = "s2"
|
577
|
+
s2.dependencies << s1
|
578
|
+
|
579
|
+
s3 = Step.new tmpdir.s3 do
|
580
|
+
step(:s2).load + " -> s3"
|
581
|
+
end
|
582
|
+
s3.task_name = "s3"
|
583
|
+
s3.dependencies << s2
|
584
|
+
|
585
|
+
assert_equal "s1 -> s2", s2.run
|
586
|
+
assert_equal "s1 -> s2 -> s3", s3.run
|
587
|
+
|
588
|
+
# Test recusive behaviour
|
589
|
+
s1.task = proc do raise RbbtException end
|
590
|
+
ComputeDependency.setup(s1, :produce)
|
591
|
+
s1.clean
|
592
|
+
s3.clean
|
593
|
+
s3.run
|
594
|
+
assert_equal "s1 -> s2 -> s3", s3.run
|
595
|
+
|
596
|
+
s1.task = proc do raise RbbtException end
|
597
|
+
ComputeDependency.setup(s1, :produce)
|
598
|
+
s3.recursive_clean
|
599
|
+
assert_raises RbbtException do s3.run end
|
600
|
+
|
601
|
+
s1.task = proc{|v| v }
|
602
|
+
s1.inputs = ["test"]
|
603
|
+
assert_equal "test", s1.run
|
604
|
+
s3.recursive_clean
|
605
|
+
assert_equal "test -> s2 -> s3", s3.run
|
601
606
|
end
|
602
607
|
end
|
603
608
|
|
@@ -215,7 +215,6 @@ row2 E
|
|
215
215
|
|
216
216
|
tsv1 = Rbbt.tmp.test.test1.data.produce(true).tsv :double, :sep => /\s+/
|
217
217
|
tsv2 = Rbbt.tmp.test.test2.data.produce(true).tsv :double, :sep => /\s+/
|
218
|
-
Log.tsv tsv2
|
219
218
|
|
220
219
|
tsv2.identifiers = Rbbt.tmp.test.test2.identifiers.produce.find #.to_s
|
221
220
|
|
@@ -603,8 +602,7 @@ A Id3
|
|
603
602
|
tsv2.identifiers = Rbbt.tmp.test.test2.identifiers.produce(true).produce.find #.to_s
|
604
603
|
|
605
604
|
tsv1.attach tsv2, :fields => ["ValueE"] #, :persist_input => true
|
606
|
-
|
607
|
-
ppp tsv1
|
605
|
+
assert_equal [["a", "aa", "aaa"], ["b"], ["e"]], tsv1["row1"]
|
608
606
|
|
609
607
|
end
|
610
608
|
|
@@ -631,7 +629,7 @@ E B
|
|
631
629
|
tsv2 = Rbbt.tmp.test.test2.data.produce(true).tsv :double, :sep => /\s+/
|
632
630
|
|
633
631
|
tsv1.attach tsv2, :fields => ["ValueE"] #, :persist_input => true
|
634
|
-
|
632
|
+
assert_equal [["a", "aa", "aaa"], ["b"], ["e"]], tsv1["row1"]
|
635
633
|
|
636
634
|
end
|
637
635
|
|
@@ -663,7 +661,6 @@ row3 C
|
|
663
661
|
tsv1 = Rbbt.tmp.test.test1.data.produce(true).tsv :double, :sep => /\s+/
|
664
662
|
tsv2 = Rbbt.tmp.test.test2.data.produce(true).tsv :double, :sep => /\s+/
|
665
663
|
|
666
|
-
ppp tsv1.attach tsv2, :complete => ["AA"]
|
667
664
|
tsv1.attach tsv2, :complete => ["AA"]
|
668
665
|
assert_equal [["AA"], ["C"]], tsv1["row3"]
|
669
666
|
end
|
data/test/rbbt/tsv/test_index.rb
CHANGED
@@ -111,16 +111,22 @@ row3 A a|B Id4
|
|
111
111
|
assert_equal "Id1", index['a']
|
112
112
|
assert_equal "Id3", index['A']
|
113
113
|
assert_equal "OtherID", index.fields.first
|
114
|
+
assert_equal "Id1", index['a']
|
115
|
+
|
116
|
+
index = tsv.index(:order => true, :persist => false)
|
117
|
+
assert_equal "Id1", index['a']
|
114
118
|
|
115
119
|
tsv.delete "Id1"
|
116
120
|
|
121
|
+
index = tsv.index(:order => true, :persist => false)
|
122
|
+
assert_equal "Id3", index['a']
|
123
|
+
|
117
124
|
index = tsv.index(:order => true, :persist => true)
|
118
125
|
assert_equal "Id1", index['a']
|
119
126
|
assert_equal "Id3", index['A']
|
120
127
|
assert_equal "OtherID", index.fields.first
|
121
|
-
|
122
|
-
index = tsv.index(:order => true, :persist => false)
|
123
128
|
assert_equal "Id1", index['a']
|
129
|
+
|
124
130
|
end
|
125
131
|
end
|
126
132
|
|
@@ -13,8 +13,6 @@ rowa a|aa b|BB C|CC
|
|
13
13
|
|
14
14
|
TmpFile.with_file(content) do |filename|
|
15
15
|
tsv = TSV.open(File.open(filename), :sep => /\s+/, :type => :double)
|
16
|
-
Log.tsv tsv
|
17
|
-
Log.tsv tsv.reorder("ValueA", nil, :zipped => true)
|
18
16
|
assert_equal ["A", "AA", "a", "aa"].sort, tsv.reorder("ValueA", nil, :zipped => true).keys.sort
|
19
17
|
end
|
20
18
|
end
|
@@ -129,7 +127,6 @@ row2 A B C
|
|
129
127
|
tsv = tsv.slice []
|
130
128
|
assert tsv.fields.empty?
|
131
129
|
TmpFile.with_file do |tmpfile|
|
132
|
-
iii tsv.to_s
|
133
130
|
Open.write(tmpfile, tsv.to_s)
|
134
131
|
tsv = TSV.open tmpfile
|
135
132
|
assert tsv.fields.empty?
|
@@ -2,12 +2,12 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_he
|
|
2
2
|
require 'rbbt/util/misc/bgzf'
|
3
3
|
|
4
4
|
class TestBgzf < Test::Unit::TestCase
|
5
|
-
def
|
5
|
+
def test_Bgzf
|
6
6
|
content = "1234567890" * 1000000
|
7
7
|
TmpFile.with_file(content) do |file|
|
8
8
|
compressed = file + '.gz'
|
9
9
|
`bgzip #{file} -c > #{compressed}`
|
10
|
-
stream = Bgzf.setup
|
10
|
+
stream = Bgzf.setup Open.open(compressed, :noz => true)
|
11
11
|
assert_equal "1234", stream.read(4)
|
12
12
|
assert_equal "56", stream.read(2)
|
13
13
|
stream.seek 500003
|
@@ -40,7 +40,7 @@ class TestBgzf < Test::Unit::TestCase
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def test_bgzip
|
44
44
|
assert File.exist?(Bgzf.bgzip_cmd)
|
45
45
|
assert 'bgzip', File.basename(Bgzf.bgzip_cmd)
|
46
46
|
end
|
@@ -3,9 +3,11 @@ require 'rbbt/util/misc/communication'
|
|
3
3
|
|
4
4
|
class TestCommunication < Test::Unit::TestCase
|
5
5
|
def test_send_email
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
keyword_test :mail do
|
7
|
+
to = from = 'mvazque2@localhost'
|
8
|
+
subject = message = "Test"
|
9
|
+
Misc.send_email(to, from, subject, message)
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
@@ -14,9 +14,7 @@ class TestMigrate < Test::Unit::TestCase
|
|
14
14
|
Open.write(test_file, "TEST")
|
15
15
|
TmpFile.with_file do |tmpdir|
|
16
16
|
Misc.in_dir tmpdir do
|
17
|
-
|
18
|
-
Rbbt.migrate('tmp/test/migration_test/migration_test_file', :current)
|
19
|
-
end
|
17
|
+
Rbbt.migrate('tmp/test/migration_test/migration_test_file', :current)
|
20
18
|
end
|
21
19
|
assert_equal "TEST", Open.read(File.join(tmpdir, 'tmp/test/migration_test/migration_test_file'))
|
22
20
|
end
|