miga-base 0.6.0.0 → 0.6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/dataset_test.rb CHANGED
@@ -1,22 +1,22 @@
1
- require "test_helper"
2
- require "miga/project"
1
+ require 'test_helper'
2
+ require 'miga/project'
3
3
 
4
4
  class DatasetTest < Test::Unit::TestCase
5
-
5
+
6
6
  def setup
7
7
  $tmp = Dir.mktmpdir
8
- ENV["MIGA_HOME"] = $tmp
9
- FileUtils.touch("#{ENV["MIGA_HOME"]}/.miga_rc")
10
- FileUtils.touch("#{ENV["MIGA_HOME"]}/.miga_daemon.json")
11
- $p1 = MiGA::Project.new(File.expand_path("project1", $tmp))
12
- $d1 = $p1.add_dataset("dataset1")
8
+ ENV['MIGA_HOME'] = $tmp
9
+ FileUtils.touch(File.expand_path('.miga_rc', ENV['MIGA_HOME']))
10
+ FileUtils.touch(File.expand_path('.miga_daemon.json', ENV['MIGA_HOME']))
11
+ $p1 = MiGA::Project.new(File.expand_path('project1', $tmp))
12
+ $d1 = $p1.add_dataset('dataset1')
13
13
  end
14
14
 
15
15
  def teardown
16
16
  FileUtils.rm_rf $tmp
17
- ENV["MIGA_HOME"] = nil
17
+ ENV['MIGA_HOME'] = nil
18
18
  end
19
-
19
+
20
20
  def test_known_types
21
21
  assert_respond_to(MiGA::Dataset, :KNOWN_TYPES)
22
22
  assert(MiGA::Dataset.KNOWN_TYPES.has_key?(:genome))
@@ -24,27 +24,25 @@ class DatasetTest < Test::Unit::TestCase
24
24
 
25
25
  def test_exist
26
26
  assert_respond_to(MiGA::Dataset, :exist?)
27
- assert(MiGA::Dataset.exist?($p1, "dataset1"))
28
- assert(! MiGA::Dataset.exist?($p1, "Nope"))
27
+ assert(MiGA::Dataset.exist?($p1, 'dataset1'))
28
+ assert(!MiGA::Dataset.exist?($p1, 'Nope'))
29
29
  end
30
30
 
31
31
  def test_info_fields
32
32
  assert_respond_to(MiGA::Dataset, :INFO_FIELDS)
33
- assert(MiGA::Dataset.INFO_FIELDS.include?("name"))
33
+ assert(MiGA::Dataset.INFO_FIELDS.include?('name'))
34
34
  end
35
35
 
36
36
  def test_initialize
37
- assert_raise do
38
- MiGA::Dataset.new($p1, "dataset-1")
39
- end
37
+ assert_raise { MiGA::Dataset.new($p1, 'dataset-1') }
40
38
  assert_equal($p1, $d1.project)
41
- assert_equal("dataset1", $d1.name)
39
+ assert_equal('dataset1', $d1.name)
42
40
  assert($d1.is_ref?)
43
41
  assert_equal(MiGA::Metadata, $d1.metadata.class)
44
42
  end
45
43
 
46
44
  def test_save
47
- d2 = $p1.add_dataset("ds_save")
45
+ d2 = $p1.add_dataset('ds_save')
48
46
  assert_respond_to(d2, :save)
49
47
  d2.save
50
48
  assert(!d2.is_multi?)
@@ -58,7 +56,7 @@ class DatasetTest < Test::Unit::TestCase
58
56
  end
59
57
 
60
58
  def test_remove
61
- d2 = $p1.add_dataset("ds_remove")
59
+ d2 = $p1.add_dataset('ds_remove')
62
60
  assert(File.exist?(d2.metadata.path))
63
61
  d2.remove!
64
62
  assert(! File.exist?(d2.metadata.path))
@@ -69,7 +67,7 @@ class DatasetTest < Test::Unit::TestCase
69
67
  end
70
68
 
71
69
  def test_add_result
72
- d2 = $p1.add_dataset("ds_add_result")
70
+ d2 = $p1.add_dataset('ds_add_result')
73
71
  assert_nil(d2.add_result(:koop))
74
72
  assert_nil(d2.add_result(:raw_reads))
75
73
  FileUtils.touch(
@@ -81,14 +79,16 @@ class DatasetTest < Test::Unit::TestCase
81
79
  end
82
80
 
83
81
  def test_preprocessing
84
- d2 = $p1.add_dataset("ds_preprocessing")
82
+ d2 = $p1.add_dataset('ds_preprocessing')
85
83
  assert_nil(d2.first_preprocessing)
86
84
  assert_nil(d2.next_preprocessing)
87
85
  assert(! d2.done_preprocessing?)
88
86
  FileUtils.touch(File.expand_path(
89
- "data/02.trimmed_reads/#{d2.name}.1.clipped.fastq",$p1.path))
87
+ "data/02.trimmed_reads/#{d2.name}.1.clipped.fastq", $p1.path
88
+ ))
90
89
  FileUtils.touch(File.expand_path(
91
- "data/02.trimmed_reads/#{d2.name}.done",$p1.path))
90
+ "data/02.trimmed_reads/#{d2.name}.done", $p1.path
91
+ ))
92
92
  assert_equal(:trimmed_reads, d2.first_preprocessing(true))
93
93
  assert_equal(:read_quality, d2.next_preprocessing(true))
94
94
  assert(! d2.done_preprocessing?(true))
@@ -114,53 +114,70 @@ class DatasetTest < Test::Unit::TestCase
114
114
  end
115
115
 
116
116
  def test_profile_advance
117
- d2 = $p1.add_dataset("ds_profile_advance")
117
+ d2 = $p1.add_dataset('ds_profile_advance')
118
118
  assert_equal(0, d2.profile_advance(true).first)
119
119
  assert_equal(0, d2.profile_advance(true).last)
120
120
  assert_equal(0, d2.profile_advance(true).inject(:+))
121
121
  Dir.mkdir(File.expand_path(
122
- "data/03.read_quality/#{d2.name}.solexaqa",$p1.path))
122
+ "data/03.read_quality/#{d2.name}.solexaqa", $p1.path
123
+ ))
123
124
  Dir.mkdir(File.expand_path(
124
- "data/03.read_quality/#{d2.name}.fastqc",$p1.path))
125
+ "data/03.read_quality/#{d2.name}.fastqc", $p1.path
126
+ ))
125
127
  FileUtils.touch(File.expand_path(
126
- "data/03.read_quality/#{d2.name}.done",$p1.path))
128
+ "data/03.read_quality/#{d2.name}.done", $p1.path
129
+ ))
127
130
  assert_equal([0,0,1,2], d2.profile_advance(true)[0..3])
128
131
  assert_equal(2, d2.profile_advance(true).last)
129
132
  end
130
133
 
131
134
  def test_add_result_other
132
- d2 = $p1.add_dataset("ds_add_result_other")
135
+ d2 = $p1.add_dataset('ds_add_result_other')
133
136
  Dir.mkdir(File.expand_path(
134
- "data/07.annotation/01.function/01.essential/#{d2.name}.ess", $p1.path))
137
+ "data/07.annotation/01.function/01.essential/#{d2.name}.ess", $p1.path
138
+ ))
135
139
  to_test = {
136
- :trimmed_fasta => [
140
+ trimmed_fasta: [
137
141
  "data/04.trimmed_fasta/#{d2.name}.SingleReads.fa",
138
- "data/04.trimmed_fasta/#{d2.name}.done"],
139
- :assembly => [
142
+ "data/04.trimmed_fasta/#{d2.name}.done"
143
+ ],
144
+ assembly: [
140
145
  "data/05.assembly/#{d2.name}.LargeContigs.fna",
141
- "data/05.assembly/#{d2.name}.done"],
142
- :cds => [
146
+ "data/05.assembly/#{d2.name}.done"
147
+ ],
148
+ cds: [
143
149
  "data/06.cds/#{d2.name}.faa",
144
150
  "data/06.cds/#{d2.name}.fna",
145
- "data/06.cds/#{d2.name}.done"],
146
- :essential_genes => %w[ess.faa ess/log done].map { |x|
147
- "data/07.annotation/01.function/01.essential/#{d2.name}.#{x}" },
148
- :ssu => [
151
+ "data/06.cds/#{d2.name}.done"
152
+ ],
153
+ essential_genes: %w[ess.faa ess/log done]
154
+ .map do |x|
155
+ "data/07.annotation/01.function/01.essential/#{d2.name}.#{x}"
156
+ end,
157
+ ssu: [
149
158
  "data/07.annotation/01.function/02.ssu/#{d2.name}.ssu.fa",
150
- "data/07.annotation/01.function/02.ssu/#{d2.name}.done"],
151
- :mytaxa_scan => %w[pdf wintax mytaxa reg done].map { |x|
152
- "data/07.annotation/03.qa/02.mytaxa_scan/#{d2.name}.#{x}" },
153
- :distances => [
159
+ "data/07.annotation/01.function/02.ssu/#{d2.name}.done"
160
+ ],
161
+ mytaxa_scan: %w[pdf wintax mytaxa reg done]
162
+ .map do |x|
163
+ "data/07.annotation/03.qa/02.mytaxa_scan/#{d2.name}.#{x}"
164
+ end,
165
+ distances: [
154
166
  "data/09.distances/01.haai/#{d2.name}.db",
155
- "data/09.distances/#{d2.name}.done"]
167
+ "data/09.distances/#{d2.name}.done"
168
+ ]
156
169
  }
157
170
  to_test.each do |k,v|
158
171
  assert_nil(d2.add_result(k), "Result for #{k} should be nil.")
159
172
  v.each { |i| FileUtils.touch(File.expand_path(i, $p1.path)) }
160
173
  FileUtils.touch(File.expand_path(
161
- "data/04.trimmed_fasta/#{d2.name}.done",$p1.path))
162
- assert_equal(MiGA::Result, d2.add_result(k).class,
163
- "Result for #{k} should be MiGA::Result.")
174
+ "data/04.trimmed_fasta/#{d2.name}.done", $p1.path
175
+ ))
176
+ assert_equal(
177
+ MiGA::Result,
178
+ d2.add_result(k).class,
179
+ "Result for #{k} should be MiGA::Result."
180
+ )
164
181
  end
165
182
  end
166
183
 
data/test/hook_test.rb CHANGED
@@ -2,12 +2,12 @@ require 'test_helper'
2
2
  require 'miga/project'
3
3
 
4
4
  class HookTest < Test::Unit::TestCase
5
-
5
+
6
6
  def setup
7
7
  $tmp = Dir.mktmpdir
8
8
  ENV['MIGA_HOME'] = $tmp
9
- FileUtils.touch("#{ENV['MIGA_HOME']}/.miga_rc")
10
- FileUtils.touch("#{ENV['MIGA_HOME']}/.miga_daemon.json")
9
+ FileUtils.touch(File.expand_path('.miga_rc', ENV['MIGA_HOME']))
10
+ FileUtils.touch(File.expand_path('.miga_daemon.json', ENV['MIGA_HOME']))
11
11
  $p1 = MiGA::Project.new(File.expand_path('project1', $tmp))
12
12
  $d1 = $p1.add_dataset('dataset1')
13
13
  end
@@ -33,6 +33,8 @@ class HookTest < Test::Unit::TestCase
33
33
  end
34
34
  end
35
35
 
36
+ ##
37
+ # Dummy class with hooks
36
38
  class MyHanger
37
39
  include MiGA::Common::Hooks
38
40
  end
@@ -61,12 +63,15 @@ class HookTest < Test::Unit::TestCase
61
63
 
62
64
  def test_dataset_clear_run_counts
63
65
  $d1.metadata[:_try_something] = 1
66
+ $d1.metadata[:_step] = 'Boop'
64
67
  $d1.metadata[:_not_a_counter] = 1
65
68
  $d1.save
66
69
  assert_equal(1, $d1.metadata[:_try_something])
70
+ assert_equal('Boop', $d1.metadata[:_step])
67
71
  $d1.add_hook(:on_remove, :clear_run_counts)
68
72
  $d1.remove!
69
73
  assert_nil($d1.metadata[:_try_something])
74
+ assert_nil($d1.metadata[:_step])
70
75
  assert_equal(1, $d1.metadata[:_not_a_counter])
71
76
  end
72
77
 
@@ -91,13 +96,20 @@ class HookTest < Test::Unit::TestCase
91
96
  def test_project_result_hooks
92
97
  $res = :test
93
98
  $counter = 1
94
- $p1.add_hook(:on_result_ready,
95
- :run_lambda, Proc.new { |r| $res = r })
96
- $p1.add_hook(:on_result_ready_project_stats,
97
- :run_lambda, Proc.new { $counter += 1 })
99
+ $p1.add_hook(
100
+ :on_result_ready,
101
+ :run_lambda,
102
+ Proc.new { |r| $res = r }
103
+ )
104
+ $p1.add_hook(
105
+ :on_result_ready_project_stats,
106
+ :run_lambda,
107
+ Proc.new { $counter += 1 }
108
+ )
98
109
  %w[taxonomy.json metadata.db done].each do |ext|
99
110
  FileUtils.touch(File.expand_path(
100
- "data/90.stats/miga-project.#{ext}", $p1.path))
111
+ "data/90.stats/miga-project.#{ext}", $p1.path
112
+ ))
101
113
  end
102
114
  assert_equal(:project_stats, $p1.next_task(nil, false))
103
115
  assert_equal(:test, $res)
data/test/json_test.rb CHANGED
@@ -1,12 +1,16 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class JsonTest < Test::Unit::TestCase
4
-
4
+
5
5
  def test_parse
6
- assert_equal({a: 1, b: 2},
7
- MiGA::Json.parse('{"a": 1, "b": 2}', contents: true))
8
- assert_equal({'a' => 1, 'b' => 2},
9
- MiGA::Json.parse('{"a": 1, "b": 2}', contents: true, symbolize: false))
6
+ assert_equal(
7
+ {a: 1, b: 2},
8
+ MiGA::Json.parse('{"a": 1, "b": 2}', contents: true)
9
+ )
10
+ assert_equal(
11
+ {'a' => 1, 'b' => 2},
12
+ MiGA::Json.parse('{"a": 1, "b": 2}', contents: true, symbolize: false)
13
+ )
10
14
  assert_equal(1.0, MiGA::Json.parse('1.0', contents: true))
11
15
  end
12
16
 
@@ -23,15 +27,18 @@ class JsonTest < Test::Unit::TestCase
23
27
 
24
28
  assert_equal(
25
29
  {a: 123, k: false, kb: false, t: nil},
26
- MiGA::Json.parse(tmp1.path, default: tmp2.path))
30
+ MiGA::Json.parse(tmp1.path, default: tmp2.path)
31
+ )
27
32
  assert_equal(
28
33
  {a: 456, k: false, kb: false, t: 10.0},
29
- MiGA::Json.parse(tmp2.path, default: tmp1.path))
34
+ MiGA::Json.parse(tmp2.path, default: tmp1.path)
35
+ )
30
36
  end
31
37
 
32
38
  def test_generate
33
39
  assert_equal("{\n \"a\": 1,\n \"b\": 2\n}",
34
- MiGA::Json.generate({a: 1, b: 2}))
40
+ MiGA::Json.generate({a: 1, b: 2})
41
+ )
35
42
  end
36
43
 
37
44
  end
@@ -1,20 +1,20 @@
1
- require "test_helper"
2
- require "miga/metadata"
1
+ require 'test_helper'
2
+ require 'miga/metadata'
3
3
 
4
4
  class MetadataTest < Test::Unit::TestCase
5
-
5
+
6
6
  def setup
7
7
  $tmp = Dir.mktmpdir
8
- $jruby_tests = !ENV["JRUBY_TESTS"].nil?
8
+ $jruby_tests = !ENV['JRUBY_TESTS'].nil?
9
9
  end
10
10
 
11
11
  def teardown
12
12
  FileUtils.rm_rf $tmp
13
13
  end
14
-
14
+
15
15
  def test_save
16
- omit_if($jruby_tests, "JRuby doesn't implement fork.")
17
- md1 = MiGA::Metadata.new(File.expand_path("md_save.json", $tmp))
16
+ omit_if($jruby_tests, 'JRuby doesn\'t implement fork.')
17
+ md1 = MiGA::Metadata.new(File.expand_path('md_save.json', $tmp))
18
18
  FileUtils.touch(md1.lock_file)
19
19
  fork do
20
20
  sleep(1)
@@ -28,13 +28,13 @@ class MetadataTest < Test::Unit::TestCase
28
28
  end
29
29
 
30
30
  def test_load
31
- md1 = MiGA::Metadata.new(File.expand_path("md_load.json", $tmp), {:t=>1})
31
+ md1 = MiGA::Metadata.new(File.expand_path('md_load.json', $tmp), {t: 1})
32
32
  assert_equal(1, md1[:t])
33
- omit_if($jruby_tests, "JRuby doesn't implement fork.")
33
+ omit_if($jruby_tests, 'JRuby doesn\'t implement fork.')
34
34
  FileUtils.touch(md1.lock_file)
35
35
  fork do
36
36
  sleep(1)
37
- File.open(md1.path, "w"){ |fh| fh.print '{"t": 2}' }
37
+ File.open(md1.path, 'w') { |fh| fh.print '{"t": 2}' }
38
38
  File.unlink(md1.lock_file)
39
39
  end
40
40
  t1 = Time.new
data/test/project_test.rb CHANGED
@@ -1,23 +1,23 @@
1
- require "test_helper"
2
- require "miga/project"
1
+ require 'test_helper'
2
+ require 'miga/project'
3
3
 
4
4
  class ProjectTest < Test::Unit::TestCase
5
-
5
+
6
6
  def setup
7
7
  $tmp = Dir.mktmpdir
8
- ENV["MIGA_HOME"] = $tmp
9
- FileUtils.touch("#{ENV["MIGA_HOME"]}/.miga_rc")
10
- FileUtils.touch("#{ENV["MIGA_HOME"]}/.miga_daemon.json")
11
- $p1 = MiGA::Project.new(File.expand_path("project1", $tmp))
8
+ ENV['MIGA_HOME'] = $tmp
9
+ FileUtils.touch(File.expand_path('.miga_rc', ENV['MIGA_HOME']))
10
+ FileUtils.touch(File.expand_path('.miga_daemon.json', ENV['MIGA_HOME']))
11
+ $p1 = MiGA::Project.new(File.expand_path('project1', $tmp))
12
12
  end
13
13
 
14
14
  def teardown
15
15
  FileUtils.rm_rf $tmp
16
- ENV["MIGA_HOME"] = nil
16
+ ENV['MIGA_HOME'] = nil
17
17
  end
18
-
18
+
19
19
  def test_class_load
20
- assert_nil(MiGA::Project.load($tmp + "/O_o"))
20
+ assert_nil(MiGA::Project.load($tmp + '/O_o'))
21
21
  assert_equal(MiGA::Project, MiGA::Project.load($p1.path).class)
22
22
  end
23
23
 
@@ -25,15 +25,15 @@ class ProjectTest < Test::Unit::TestCase
25
25
  assert_equal("#{$tmp}/create", MiGA::Project.new("#{$tmp}/create").path)
26
26
  assert(Dir.exist?("#{$tmp}/create"))
27
27
  assert_raise do
28
- ENV["MIGA_HOME"] = $tmp + "/chez-moi"
29
- MiGA::Project.new($tmp + "/cuckoo")
28
+ ENV['MIGA_HOME'] = $tmp + '/chez-moi'
29
+ MiGA::Project.new($tmp + '/cuckoo')
30
30
  end
31
31
  ensure
32
- ENV["MIGA_HOME"] = $tmp
32
+ ENV['MIGA_HOME'] = $tmp
33
33
  end
34
34
 
35
35
  def test_load
36
- p = MiGA::Project.new($tmp + "/load")
36
+ p = MiGA::Project.new($tmp + '/load')
37
37
  assert_equal(MiGA::Project, p.class)
38
38
  File.unlink p.metadata.path
39
39
  assert_raise do
@@ -43,12 +43,12 @@ class ProjectTest < Test::Unit::TestCase
43
43
 
44
44
  def test_datasets
45
45
  p = $p1
46
- d = p.add_dataset("d1")
46
+ d = p.add_dataset('d1')
47
47
  assert_equal(MiGA::Dataset, d.class)
48
48
  assert_equal([d], p.datasets)
49
- assert_equal(["d1"], p.dataset_names)
49
+ assert_equal(['d1'], p.dataset_names)
50
50
  p.each_dataset{ |ds| assert_equal(d, ds) }
51
- dr = p.unlink_dataset("d1")
51
+ dr = p.unlink_dataset('d1')
52
52
  assert_equal(d, dr)
53
53
  assert_equal([], p.datasets)
54
54
  assert_equal([], p.dataset_names)
@@ -56,23 +56,27 @@ class ProjectTest < Test::Unit::TestCase
56
56
 
57
57
  def test_import_dataset
58
58
  p1 = $p1
59
- d1 = p1.add_dataset("d1")
60
- File.open("#{p1.path}/data/01.raw_reads/#{d1.name}.1.fastq",
61
- "w") { |f| f.puts ":-)" }
62
- File.open("#{p1.path}/data/01.raw_reads/#{d1.name}.done",
63
- "w") { |f| f.puts ":-)" }
59
+ d1 = p1.add_dataset('d1')
60
+ File.open(
61
+ "#{p1.path}/data/01.raw_reads/#{d1.name}.1.fastq", 'w'
62
+ ) { |f| f.puts ':-)' }
63
+ File.open(
64
+ "#{p1.path}/data/01.raw_reads/#{d1.name}.done", 'w'
65
+ ) { |f| f.puts ':-)' }
64
66
  d1.next_preprocessing(true)
65
- p2 = MiGA::Project.new(File.expand_path("import_dataset", $tmp))
67
+ p2 = MiGA::Project.new(File.expand_path('import_dataset', $tmp))
66
68
  assert(p2.datasets.empty?)
67
- assert_nil(p2.dataset("d1"))
69
+ assert_nil(p2.dataset('d1'))
68
70
  p2.import_dataset(d1)
69
71
  assert_equal(1, p2.datasets.size)
70
- assert_equal(MiGA::Dataset, p2.dataset("d1").class)
71
- assert_equal(1, p2.dataset("d1").results.size)
72
+ assert_equal(MiGA::Dataset, p2.dataset('d1').class)
73
+ assert_equal(1, p2.dataset('d1').results.size)
72
74
  assert(File.exist?(
73
- File.expand_path("data/01.raw_reads/#{d1.name}.1.fastq", p2.path)))
75
+ File.expand_path("data/01.raw_reads/#{d1.name}.1.fastq", p2.path)
76
+ ))
74
77
  assert(File.exist?(
75
- File.expand_path("metadata/#{d1.name}.json", p2.path)))
78
+ File.expand_path("metadata/#{d1.name}.json", p2.path)
79
+ ))
76
80
  end
77
81
 
78
82
  def test_add_result
@@ -81,7 +85,8 @@ class ProjectTest < Test::Unit::TestCase
81
85
  %w[.Rdata .log .txt .done].each do |x|
82
86
  assert_nil(p1.add_result(:haai_distances))
83
87
  FileUtils.touch(
84
- File.expand_path("data/09.distances/01.haai/miga-project#{x}",p1.path))
88
+ File.expand_path("data/09.distances/01.haai/miga-project#{x}",p1.path)
89
+ )
85
90
  end
86
91
  assert_equal(MiGA::Result, p1.add_result(:haai_distances).class)
87
92
  end
@@ -90,8 +95,9 @@ class ProjectTest < Test::Unit::TestCase
90
95
  p1 = $p1
91
96
  assert_nil(p1.result :n00b)
92
97
  assert_nil(p1.result :project_stats)
93
- File.open(File.expand_path("data/90.stats/miga-project.json",p1.path),
94
- "w"){ |fh| fh.puts "{}" }
98
+ File.open(
99
+ File.expand_path('data/90.stats/miga-project.json', p1.path), 'w'
100
+ ) { |fh| fh.puts '{}' }
95
101
  assert_not_nil(p1.result :project_stats)
96
102
  assert_equal(1, p1.results.size)
97
103
  end
@@ -99,8 +105,8 @@ class ProjectTest < Test::Unit::TestCase
99
105
  def test_preprocessing
100
106
  p1 = $p1
101
107
  assert(p1.done_preprocessing?)
102
- d1 = p1.add_dataset("BAH")
103
- assert(! p1.done_preprocessing?)
108
+ d1 = p1.add_dataset('BAH')
109
+ assert(!p1.done_preprocessing?)
104
110
  FileUtils.touch(File.expand_path("data/90.stats/#{d1.name}.done", p1.path))
105
111
  assert(p1.done_preprocessing?)
106
112
 
@@ -108,12 +114,14 @@ class ProjectTest < Test::Unit::TestCase
108
114
  assert_equal(:project_stats, p1.next_distances)
109
115
  d = MiGA::Project.RESULT_DIRS[:project_stats]
110
116
  %w[.done .taxonomy.json .metadata.db].each do |x|
111
- assert_nil(p1.add_result(:project_stats),
112
- "Premature registration of result project_stats at extension #{x}.")
117
+ assert_nil(
118
+ p1.add_result(:project_stats),
119
+ "Premature registration of result project_stats at extension #{x}."
120
+ )
113
121
  FileUtils.touch(File.expand_path("data/#{d}/miga-project#{x}", p1.path))
114
122
  end
115
123
  assert_equal(MiGA::Result, p1.add_result(:project_stats).class,
116
- "Imposible to add project_stats result.")
124
+ 'Imposible to add project_stats result.')
117
125
 
118
126
  # Distances
119
127
  [:haai_distances, :aai_distances, :ani_distances].each do |r|
@@ -121,15 +129,17 @@ class ProjectTest < Test::Unit::TestCase
121
129
  assert_equal(Symbol, p1.next_distances.class)
122
130
  d = MiGA::Project.RESULT_DIRS[r]
123
131
  %w[.done .Rdata .log .txt].each do |x|
124
- assert_nil(p1.add_result(r),
125
- "Premature registration of result #{r} at extension #{x}.")
132
+ assert_nil(
133
+ p1.add_result(r),
134
+ "Premature registration of result #{r} at extension #{x}."
135
+ )
126
136
  FileUtils.touch(File.expand_path("data/#{d}/miga-project#{x}", p1.path))
127
137
  end
128
138
  assert_equal(MiGA::Result, p1.add_result(r).class,
129
139
  "Imposible to add #{r} result.")
130
140
  end
131
141
  assert_equal(:clade_finding, p1.next_distances)
132
-
142
+
133
143
  # Clades
134
144
  assert_nil(p1.next_inclade)
135
145
  p1.metadata[:type] = :clade
@@ -144,15 +154,19 @@ class ProjectTest < Test::Unit::TestCase
144
154
  d = MiGA::Project.RESULT_DIRS[r]
145
155
  assert_equal(Symbol, p1.next_inclade.class)
146
156
  ([".done"] + xs).each do |x|
147
- assert_nil(p1.add_result(r),
148
- "Premature registration of result #{r} at extension #{x}.")
157
+ assert_nil(
158
+ p1.add_result(r),
159
+ "Premature registration of result #{r} at extension #{x}."
160
+ )
149
161
  FileUtils.touch(File.expand_path("data/#{d}/miga-project#{x}", p1.path))
150
162
  end
151
- assert_equal(MiGA::Result, p1.add_result(r).class,
152
- "Impossible to add #{r} result.")
163
+ assert_equal(
164
+ MiGA::Result,
165
+ p1.add_result(r).class,
166
+ "Impossible to add #{r} result."
167
+ )
153
168
  end
154
169
  assert_nil(p1.next_inclade)
155
-
156
170
  end
157
171
 
158
172
  end
@@ -1,23 +1,23 @@
1
- require "test_helper"
2
- require "miga/project"
3
- require "miga/remote_dataset"
1
+ require 'test_helper'
2
+ require 'miga/project'
3
+ require 'miga/remote_dataset'
4
4
 
5
5
  class RemoteDatasetTest < Test::Unit::TestCase
6
-
6
+
7
7
  def setup
8
8
  $tmp = Dir.mktmpdir
9
- ENV["MIGA_HOME"] = $tmp
10
- FileUtils.touch("#{ENV["MIGA_HOME"]}/.miga_rc")
11
- FileUtils.touch("#{ENV["MIGA_HOME"]}/.miga_daemon.json")
12
- $p1 = MiGA::Project.new(File.expand_path("project1", $tmp))
13
- $remote_tests = !ENV["REMOTE_TESTS"].nil?
9
+ ENV['MIGA_HOME'] = $tmp
10
+ FileUtils.touch(File.expand_path('.miga_rc', ENV["MIGA_HOME"]))
11
+ FileUtils.touch(File.expand_path('.miga_daemon.json', ENV["MIGA_HOME"]))
12
+ $p1 = MiGA::Project.new(File.expand_path('project1', $tmp))
13
+ $remote_tests = !ENV['REMOTE_TESTS'].nil?
14
14
  end
15
15
 
16
16
  def teardown
17
17
  FileUtils.rm_rf $tmp
18
- ENV["MIGA_HOME"] = nil
18
+ ENV['MIGA_HOME'] = nil
19
19
  end
20
-
20
+
21
21
  def test_class_universe
22
22
  assert_respond_to(MiGA::RemoteDataset, :UNIVERSE)
23
23
  assert(MiGA::RemoteDataset.UNIVERSE.keys.include? :ebi)
@@ -38,11 +38,16 @@ class RemoteDatasetTest < Test::Unit::TestCase
38
38
  msg = "Failed on #{universe}:#{db}"
39
39
  assert_equal(MiGA::Taxonomy, tx.class, msg)
40
40
  assert_equal('Lentivirus', tx[:g], msg)
41
- assert_equal('ns:ncbi o:Ortervirales f:Retroviridae ' \
42
- 'g:Lentivirus s:Human_immunodeficiency_virus_2', tx.to_s, msg)
43
- assert_equal('ns:ncbi d: k: p: c: o:Ortervirales f:Retroviridae ' \
44
- 'g:Lentivirus s:Human_immunodeficiency_virus_2 ssp: str: ds:',
45
- tx.to_s(true), msg)
41
+ assert_equal(
42
+ 'ns:ncbi o:Ortervirales f:Retroviridae ' \
43
+ 'g:Lentivirus s:Human_immunodeficiency_virus_2',
44
+ tx.to_s, msg
45
+ )
46
+ assert_equal(
47
+ 'ns:ncbi d: k: p: c: o:Ortervirales f:Retroviridae ' \
48
+ 'g:Lentivirus s:Human_immunodeficiency_virus_2 ssp: str: ds:',
49
+ tx.to_s(true), msg
50
+ )
46
51
  assert_equal('ncbi', tx.namespace, msg)
47
52
  end
48
53
  end
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+ require 'miga/project'
3
+
4
+ class ResultTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ $tmp = Dir.mktmpdir
8
+ ENV['MIGA_HOME'] = $tmp
9
+ FileUtils.touch(File.expand_path('.miga_rc', ENV['MIGA_HOME']))
10
+ FileUtils.touch(File.expand_path('.miga_daemon.json', ENV['MIGA_HOME']))
11
+ $p1 = MiGA::Project.new(File.expand_path('project1', $tmp))
12
+ $d1 = $p1.add_dataset('dataset1')
13
+ FileUtils.touch(File.expand_path(
14
+ "data/02.trimmed_reads/#{$d1.name}.1.clipped.fastq", $p1.path))
15
+ FileUtils.touch(File.expand_path(
16
+ "data/02.trimmed_reads/#{$d1.name}.done", $p1.path))
17
+ FileUtils.touch(File.expand_path(
18
+ 'data/10.clades/01.find/miga-project.empty', $p1.path))
19
+ FileUtils.touch(File.expand_path(
20
+ 'data/10.clades/01.find/miga-project.done', $p1.path))
21
+ end
22
+
23
+ def teardown
24
+ FileUtils.rm_rf $tmp
25
+ ENV['MIGA_HOME'] = nil
26
+ end
27
+
28
+ def test_add_result
29
+ r = $d1.add_result(:trimmed_reads)
30
+ assert_equal(MiGA::Result, r.class)
31
+ r = $d1.add_result(:asssembly)
32
+ assert_nil(r)
33
+ r = $p1.add_result(:clade_finding)
34
+ assert_equal(MiGA::Result, r.class)
35
+ end
36
+
37
+ def test_result_source
38
+ r = $d1.add_result(:trimmed_reads)
39
+ assert_equal($d1.name, r.source.name)
40
+ assert_equal(:trimmed_reads, r.key)
41
+ assert_equal('data/02.trimmed_reads', r.relative_dir)
42
+ assert_equal('data/02.trimmed_reads/dataset1.json', r.relative_path)
43
+ assert_equal($p1.path, r.project.path)
44
+ assert_equal($p1.path, r.project_path)
45
+ r = $p1.add_result(:clade_finding)
46
+ assert_equal($p1.path, r.source.path)
47
+ end
48
+
49
+ end