rbbt-util 5.41.1 → 5.43.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) 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 +13 -3
  6. data/lib/rbbt/entity.rb +6 -5
  7. data/lib/rbbt/hpc/batch.rb +2 -1
  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/change_id.rb +6 -3
  15. data/lib/rbbt/tsv/parallel/traverse.rb +44 -0
  16. data/lib/rbbt/tsv/parser.rb +7 -6
  17. data/lib/rbbt/tsv/serializers.rb +1 -1
  18. data/lib/rbbt/tsv/util.rb +12 -0
  19. data/lib/rbbt/util/R.rb +1 -1
  20. data/lib/rbbt/util/config.rb +1 -1
  21. data/lib/rbbt/util/log/progress.rb +1 -1
  22. data/lib/rbbt/util/log.rb +4 -0
  23. data/lib/rbbt/util/misc/bgzf.rb +5 -4
  24. data/lib/rbbt/util/misc/development.rb +4 -4
  25. data/lib/rbbt/util/misc.rb +1 -1
  26. data/lib/rbbt/util/named_array.rb +1 -1
  27. data/lib/rbbt/util/open.rb +6 -2
  28. data/lib/rbbt/workflow/definition.rb +2 -0
  29. data/lib/rbbt/workflow/integration/nextflow.rb +98 -20
  30. data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +8 -3
  31. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +14 -15
  32. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +9 -9
  33. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +4 -0
  34. data/lib/rbbt/workflow/step/info.rb +11 -2
  35. data/lib/rbbt/workflow/util/trace.rb +2 -2
  36. data/lib/rbbt/workflow.rb +2 -2
  37. data/share/Rlib/util.R +22 -4
  38. data/share/config.ru +1 -1
  39. data/share/rbbt_commands/resource/find +1 -1
  40. data/share/rbbt_commands/workflow/task +3 -3
  41. data/share/workflow_config.ru +0 -1
  42. data/test/rbbt/association/test_database.rb +0 -2
  43. data/test/rbbt/association/test_open.rb +1 -1
  44. data/test/rbbt/entity/test_identifiers.rb +7 -47
  45. data/test/rbbt/hpc/orchestrate/test_batches.rb +2 -45
  46. data/test/rbbt/hpc/orchestrate/test_chains.rb +13 -44
  47. data/test/rbbt/hpc/orchestrate/test_rules.rb +2 -35
  48. data/test/rbbt/hpc/test_batch.rb +18 -22
  49. data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
  50. data/test/rbbt/hpc/test_pbs.rb +1 -1
  51. data/test/rbbt/hpc/test_slurm.rb +6 -10
  52. data/test/rbbt/knowledge_base/test_enrichment.rb +5 -3
  53. data/test/rbbt/knowledge_base/test_entity.rb +26 -6
  54. data/test/rbbt/knowledge_base/test_query.rb +1 -1
  55. data/test/rbbt/knowledge_base/test_registry.rb +34 -41
  56. data/test/rbbt/knowledge_base/test_traverse.rb +106 -58
  57. data/test/rbbt/persist/test_tsv.rb +4 -4
  58. data/test/rbbt/persist/tsv/test_lmdb.rb +7 -5
  59. data/test/rbbt/resource/test_path.rb +2 -2
  60. data/test/rbbt/test_entity.rb +8 -5
  61. data/test/rbbt/test_knowledge_base.rb +107 -30
  62. data/test/rbbt/test_packed_index.rb +5 -5
  63. data/test/rbbt/test_tsv.rb +1 -1
  64. data/test/rbbt/test_workflow.rb +83 -78
  65. data/test/rbbt/tsv/test_accessor.rb +23 -0
  66. data/test/rbbt/tsv/test_attach.rb +2 -5
  67. data/test/rbbt/tsv/test_index.rb +8 -2
  68. data/test/rbbt/tsv/test_manipulate.rb +0 -3
  69. data/test/rbbt/util/R/test_model.rb +0 -2
  70. data/test/rbbt/util/misc/test_bgzf.rb +3 -3
  71. data/test/rbbt/util/misc/test_communication.rb +5 -3
  72. data/test/rbbt/util/test_migrate.rb +1 -3
  73. data/test/rbbt/util/test_misc.rb +7 -2
  74. data/test/rbbt/util/test_open.rb +9 -0
  75. data/test/rbbt/util/test_procpath.rb +1 -1
  76. data/test/rbbt/util/test_python.rb +12 -8
  77. data/test/rbbt/workflow/step/test_dependencies.rb +0 -4
  78. data/test/rbbt/workflow/test_remote_workflow.rb +6 -5
  79. data/test/rbbt/workflow/util/test_archive.rb +4 -8
  80. data/test/rbbt/workflow/util/test_orchestrator.rb +5 -15
  81. data/test/test_helper.rb +25 -1
  82. metadata +5 -5
  83. data/test/rbbt/test_hpc.rb +0 -16
@@ -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 0, $count
142
+ assert_equal 2, $count
140
143
  assert_equal "2gnirtS", a[1].reverse_text_single_p
141
- assert_equal 1, $count
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(ReversableString.persisted?(:random))
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
- assert(! ReversableString.persisted?(:random))
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
- Gene.add_identifiers KEGG.identifiers
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 :tfacts, TFactS.regulators, :source =>"=~Associated Gene Name"
92
+ kb.register :gene_ages, datadir_test.gene_ages
68
93
 
69
- kb.get_index(:tfacts).reverse
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 test_knowledge_base
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 :tfacts, TFactS.regulators, :source =>"=~Associated Gene Name"
106
+ kb.register :gene_ages, datadir_test.gene_ages, :source => "=>Associated Gene Name"
80
107
 
81
- assert_equal "Ensembl Gene ID", kb.get_database(:tfacts).key_field
108
+ kb.register :CollecTRI, datadir_test.CollecTRI,
109
+ :source => "Transcription Factor", :target => "Target Gene",
110
+ :fields => ["[ExTRI] Confidence", "[ExTRI] PMID"]
82
111
 
83
- kb.register :kegg, KEGG.gene_pathway, :source_format => "Ensembl Gene ID"
84
- assert_match "Ensembl Gene ID", kb.get_database(:kegg).key_field
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
- downstream = gene.follow kb, :tfacts
91
- upstream = gene.backtrack kb, :tfacts
92
- close = gene.expand kb, :tfacts
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
- assert downstream.length < downstream.follow(kb, :tfacts,false).flatten.length
122
+ end
123
+ end
95
124
 
96
- Misc.benchmark(50) do
97
- downstream.follow(kb, :tfacts, false)
98
- downstream.backtrack(kb, :tfacts, false)
99
- downstream.expand(kb, :tfacts, false)
100
- end
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, :tfacts)
104
- downstream.backtrack(kb, :tfacts)
105
- downstream.expand(kb, :tfacts)
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, :tfacts, true)
110
- downstream.backtrack(kb, :tfacts, true)
111
- downstream.expand(kb, :tfacts, true)
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
- Association.index(TFactS.regulators, :persist_file => tmpdir.tfacts, :format => {"Gene" => "Ensembl Gene ID"}, :namespace => Organism.default_code("Hsa"))
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
- assert kb.identify_source('tfacts', "TP53") =~ /ENSG/
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 _test_packed_index
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
- 100.times do |i|
18
- assert_equal i, pi[i][0]
19
- assert_equal i+2, pi[i][1]
20
- end
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]
@@ -651,7 +651,7 @@ row3 AA BB|BBB Id3|Id2
651
651
  end
652
652
  end
653
653
 
654
- def test_benchmark
654
+ def __test_benchmark
655
655
  num = 10_000
656
656
  txt = num.times.inject(nil) do |acc,i|
657
657
  (acc.nil? ? "" : acc << "\n") << (0..10).collect{|v| v == 0 ? i : [v,v] * "|" } * "\t"
@@ -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, :not_overriden => true
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 :overr_alt, :not_overriden => true
190
- dep :overr_target, "TestWF#overr_orig" => :overr_alt
191
- task :overr_action2 => :string do
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
- Log.with_severity 0 do
358
- job = TestWF.job(:stream2)
359
- job.recursive_clean
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
- job = TestWF.job(:reverse_file, nil, :file => "code")
454
- TmpFile.with_file do |dir|
455
- Path.setup(dir)
456
- Step.save_job_inputs(job, dir)
457
- assert_equal Dir.glob(dir + "/*"), [dir.file.find + '.as_path']
458
- inputs = Workflow.load_inputs(dir, [:file], :file => :file)
459
- assert_equal inputs, {:file => 'code'}
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 ! job.overriden
516
+ assert job.overriden
511
517
 
512
- job = TestWF.job(:overr_action2)
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
- Log.with_severity 0 do
543
- TmpFile.with_file do |tmpdir|
544
- Path.setup tmpdir
545
-
546
- s1 = Step.new tmpdir.s1 do "s1" end
547
- s1.task_name = "s1"
548
-
549
- # run clean run
550
- assert_equal "s1", s1.run
551
- s1.clean
552
- assert_equal "s1", s1.run
553
- assert_equal "s1", s1.run
554
-
555
- # is persisted because it raises RbbtException
556
- s1.task = proc do raise RbbtException end
557
- assert_equal "s1", s1.run
558
- s1.clean
559
- assert_raises RbbtException do s1.run end
560
- assert RbbtException === s1.get_exception
561
- assert s1.error?
562
-
563
- s1.recursive_clean
564
- s1.task = proc do "s1" end
565
-
566
- # add dependencies
567
- s2 = Step.new tmpdir.s2 do
568
- step(:s1).load + " -> s2"
569
- end
570
- s2.task_name = "s2"
571
- s2.dependencies << s1
572
-
573
- s3 = Step.new tmpdir.s3 do
574
- step(:s2).load + " -> s3"
575
- end
576
- s3.task_name = "s3"
577
- s3.dependencies << s2
578
-
579
- assert_equal "s1 -> s2", s2.run
580
- assert_equal "s1 -> s2 -> s3", s3.run
581
-
582
- # Test recusive behaviour
583
- s1.task = proc do raise RbbtException end
584
- ComputeDependency.setup(s1, :produce)
585
- s1.clean
586
- s3.clean
587
- s3.run
588
- assert_equal "s1 -> s2 -> s3", s3.run
589
-
590
- s1.task = proc do raise RbbtException end
591
- ComputeDependency.setup(s1, :produce)
592
- s3.recursive_clean
593
- assert_raises RbbtException do s3.run end
594
-
595
- s1.task = proc{|v| v }
596
- s1.inputs = ["test"]
597
- assert_equal "test", s1.run
598
- s3.recursive_clean
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
 
@@ -74,6 +74,25 @@ row2 A B Id3
74
74
  end
75
75
  end
76
76
 
77
+ def test_to_s_no_preable
78
+ content =<<-EOF
79
+ #Id ValueA ValueB OtherID
80
+ row1 a|aa|aaa b Id1|Id2
81
+ row2 A B Id3
82
+ EOF
83
+
84
+ target =<<-EOF
85
+ Id,ValueA,ValueB,OtherID
86
+ row1,a|aa|aaa,b,Id1|Id2
87
+ row2,A,B,Id3
88
+ EOF
89
+
90
+ TmpFile.with_file(content) do |filename|
91
+ tsv = TSV.open(filename, :sep => /\s+/)
92
+ assert_equal tsv.to_s(preamble: false, header_hash: '').gsub(/\t/, ','), target
93
+ end
94
+ end
95
+
77
96
  def test_entries
78
97
  content =<<-EOF
79
98
  #Id ValueA ValueB OtherID
@@ -293,4 +312,8 @@ row2 aa|aa|AA|AA b1|b2|B1|B2 Id1|Id1|Id2|Id2
293
312
  end
294
313
 
295
314
  end
315
+
316
+ def test_identifier_files
317
+ assert_include datadir_test.CollecTRI.identifier_files.first, "test/data"
318
+ end
296
319
  end
@@ -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
- Log.tsv tsv1
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
- Log.tsv tsv1
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
@@ -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?
@@ -3,8 +3,6 @@ require 'rbbt/util/R'
3
3
  require 'rbbt/util/R/model'
4
4
 
5
5
  class TestRModel < Test::Unit::TestCase
6
- def model
7
- end
8
6
 
9
7
  def test_fit
10
8
  data = TSV.setup({}, :key_field => "Dose", :fields => ["Response"], :type => :single)
@@ -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 _test_Bgzf
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 File.open(compressed)
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 _test_bgzip
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
- to = from = 'mvazque2@localhost'
7
- subject = message = "Test"
8
- iii Misc.send_email(to, from, subject, message)
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
- Log.with_severity 0 do
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