miga-base 0.7.4.0 → 0.7.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/miga/cli.rb +10 -8
- data/lib/miga/cli/action.rb +2 -3
- data/lib/miga/cli/action/about.rb +5 -6
- data/lib/miga/cli/action/add.rb +18 -12
- data/lib/miga/cli/action/add_result.rb +2 -3
- data/lib/miga/cli/action/archive.rb +1 -2
- data/lib/miga/cli/action/classify_wf.rb +8 -6
- data/lib/miga/cli/action/console.rb +0 -1
- data/lib/miga/cli/action/daemon.rb +7 -7
- data/lib/miga/cli/action/date.rb +0 -1
- data/lib/miga/cli/action/derep_wf.rb +5 -4
- data/lib/miga/cli/action/doctor.rb +28 -20
- data/lib/miga/cli/action/doctor/base.rb +29 -6
- data/lib/miga/cli/action/edit.rb +1 -2
- data/lib/miga/cli/action/files.rb +8 -8
- data/lib/miga/cli/action/find.rb +5 -6
- data/lib/miga/cli/action/generic.rb +7 -7
- data/lib/miga/cli/action/get.rb +20 -17
- data/lib/miga/cli/action/get_db.rb +8 -2
- data/lib/miga/cli/action/index_wf.rb +1 -1
- data/lib/miga/cli/action/init.rb +34 -29
- data/lib/miga/cli/action/init/daemon_helper.rb +65 -43
- data/lib/miga/cli/action/lair.rb +7 -7
- data/lib/miga/cli/action/ln.rb +6 -6
- data/lib/miga/cli/action/ls.rb +1 -2
- data/lib/miga/cli/action/ncbi_get.rb +11 -3
- data/lib/miga/cli/action/new.rb +4 -4
- data/lib/miga/cli/action/next_step.rb +0 -1
- data/lib/miga/cli/action/preproc_wf.rb +3 -3
- data/lib/miga/cli/action/quality_wf.rb +1 -1
- data/lib/miga/cli/action/rm.rb +2 -3
- data/lib/miga/cli/action/run.rb +8 -8
- data/lib/miga/cli/action/stats.rb +3 -3
- data/lib/miga/cli/action/summary.rb +7 -6
- data/lib/miga/cli/action/tax_dist.rb +8 -4
- data/lib/miga/cli/action/tax_index.rb +3 -4
- data/lib/miga/cli/action/tax_set.rb +7 -6
- data/lib/miga/cli/action/tax_test.rb +6 -5
- data/lib/miga/cli/action/wf.rb +21 -19
- data/lib/miga/cli/base.rb +34 -32
- data/lib/miga/cli/objects_helper.rb +24 -17
- data/lib/miga/cli/opt_helper.rb +3 -2
- data/lib/miga/common.rb +2 -5
- data/lib/miga/common/base.rb +15 -16
- data/lib/miga/common/format.rb +8 -5
- data/lib/miga/common/hooks.rb +1 -4
- data/lib/miga/common/path.rb +4 -9
- data/lib/miga/common/with_daemon.rb +5 -2
- data/lib/miga/common/with_daemon_class.rb +1 -1
- data/lib/miga/common/with_result.rb +2 -1
- data/lib/miga/daemon.rb +51 -35
- data/lib/miga/daemon/base.rb +0 -2
- data/lib/miga/dataset.rb +47 -37
- data/lib/miga/dataset/base.rb +52 -37
- data/lib/miga/dataset/hooks.rb +3 -4
- data/lib/miga/dataset/result.rb +17 -1
- data/lib/miga/json.rb +5 -7
- data/lib/miga/lair.rb +4 -0
- data/lib/miga/metadata.rb +4 -3
- data/lib/miga/project.rb +29 -20
- data/lib/miga/project/base.rb +52 -37
- data/lib/miga/project/dataset.rb +27 -13
- data/lib/miga/project/hooks.rb +0 -3
- data/lib/miga/project/result.rb +14 -5
- data/lib/miga/remote_dataset.rb +85 -72
- data/lib/miga/remote_dataset/base.rb +11 -13
- data/lib/miga/remote_dataset/download.rb +33 -12
- data/lib/miga/result.rb +34 -25
- data/lib/miga/result/base.rb +0 -2
- data/lib/miga/result/dates.rb +1 -3
- data/lib/miga/result/source.rb +15 -16
- data/lib/miga/result/stats.rb +36 -25
- data/lib/miga/tax_dist.rb +6 -3
- data/lib/miga/tax_index.rb +17 -17
- data/lib/miga/taxonomy.rb +6 -1
- data/lib/miga/taxonomy/base.rb +19 -15
- data/lib/miga/version.rb +19 -16
- data/test/common_test.rb +3 -11
- data/test/daemon_helper.rb +38 -0
- data/test/daemon_test.rb +73 -101
- data/test/dataset_test.rb +58 -59
- data/test/format_test.rb +3 -11
- data/test/hook_test.rb +50 -55
- data/test/json_test.rb +7 -8
- data/test/lair_test.rb +22 -28
- data/test/metadata_test.rb +6 -14
- data/test/project_test.rb +33 -39
- data/test/remote_dataset_test.rb +20 -28
- data/test/result_stats_test.rb +17 -27
- data/test/result_test.rb +41 -34
- data/test/tax_dist_test.rb +0 -2
- data/test/tax_index_test.rb +4 -10
- data/test/taxonomy_test.rb +7 -9
- data/test/test_helper.rb +42 -1
- data/test/with_daemon_test.rb +14 -22
- data/utils/cleanup-databases.rb +6 -5
- data/utils/distance/base.rb +0 -1
- data/utils/distance/commands.rb +19 -12
- data/utils/distance/database.rb +24 -21
- data/utils/distance/pipeline.rb +12 -9
- data/utils/distance/runner.rb +14 -13
- data/utils/distance/temporal.rb +1 -3
- data/utils/distances.rb +1 -1
- data/utils/domain-ess-genes.rb +7 -7
- data/utils/index_metadata.rb +4 -2
- data/utils/mytaxa_scan.rb +18 -16
- data/utils/representatives.rb +5 -4
- data/utils/requirements.txt +1 -1
- data/utils/subclade/base.rb +0 -1
- data/utils/subclade/pipeline.rb +7 -6
- data/utils/subclade/runner.rb +9 -9
- data/utils/subclade/temporal.rb +0 -2
- data/utils/subclades-compile.rb +39 -37
- data/utils/subclades.rb +1 -1
- metadata +3 -2
data/test/metadata_test.rb
CHANGED
@@ -2,19 +2,11 @@ require 'test_helper'
|
|
2
2
|
require 'miga/metadata'
|
3
3
|
|
4
4
|
class MetadataTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
$tmp = Dir.mktmpdir
|
8
|
-
$jruby_tests = !ENV['JRUBY_TESTS'].nil?
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
FileUtils.rm_rf $tmp
|
13
|
-
end
|
5
|
+
include TestHelper
|
14
6
|
|
15
7
|
def test_save
|
16
|
-
|
17
|
-
md1 = MiGA::Metadata.new(
|
8
|
+
declare_forks
|
9
|
+
md1 = MiGA::Metadata.new(tmpfile('md_save.json'))
|
18
10
|
FileUtils.touch(md1.lock_file)
|
19
11
|
fork do
|
20
12
|
sleep(1)
|
@@ -28,9 +20,10 @@ class MetadataTest < Test::Unit::TestCase
|
|
28
20
|
end
|
29
21
|
|
30
22
|
def test_load
|
31
|
-
md1 = MiGA::Metadata.new(
|
23
|
+
md1 = MiGA::Metadata.new(tmpfile('md_load.json'), { t: 1 })
|
32
24
|
assert_equal(1, md1[:t])
|
33
|
-
|
25
|
+
|
26
|
+
declare_forks
|
34
27
|
FileUtils.touch(md1.lock_file)
|
35
28
|
fork do
|
36
29
|
sleep(1)
|
@@ -44,5 +37,4 @@ class MetadataTest < Test::Unit::TestCase
|
|
44
37
|
assert_path_not_exist(md1.lock_file)
|
45
38
|
assert_ge(t2 - t1, 1.0)
|
46
39
|
end
|
47
|
-
|
48
40
|
end
|
data/test/project_test.rb
CHANGED
@@ -2,17 +2,10 @@ require 'test_helper'
|
|
2
2
|
require 'miga/project'
|
3
3
|
|
4
4
|
class ProjectTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
$tmp = Dir.mktmpdir
|
7
|
-
ENV['MIGA_HOME'] = $tmp
|
8
|
-
FileUtils.touch(File.expand_path('.miga_rc', ENV['MIGA_HOME']))
|
9
|
-
FileUtils.touch(File.expand_path('.miga_daemon.json', ENV['MIGA_HOME']))
|
10
|
-
$p1 = MiGA::Project.new(File.expand_path('project1', $tmp))
|
11
|
-
end
|
5
|
+
include TestHelper
|
12
6
|
|
13
|
-
def
|
14
|
-
|
15
|
-
ENV['MIGA_HOME'] = nil
|
7
|
+
def setup
|
8
|
+
initialize_miga_home
|
16
9
|
end
|
17
10
|
|
18
11
|
def create_result_files(project, res, exts)
|
@@ -22,28 +15,26 @@ class ProjectTest < Test::Unit::TestCase
|
|
22
15
|
project.add_result(res),
|
23
16
|
"Premature registration of result #{res} at extension #{x}"
|
24
17
|
)
|
25
|
-
FileUtils.touch(File.join(project.path,
|
18
|
+
FileUtils.touch(File.join(project.path, 'data', d, "miga-project#{x}"))
|
26
19
|
end
|
27
20
|
end
|
28
21
|
|
29
22
|
def test_class_load
|
30
|
-
assert_nil(MiGA::Project.load(
|
31
|
-
|
23
|
+
assert_nil(MiGA::Project.load(tmpfile('O_o')))
|
24
|
+
assert_instance_of(MiGA::Project, MiGA::Project.load(project.path))
|
32
25
|
end
|
33
26
|
|
34
27
|
def test_create
|
35
|
-
assert_equal(
|
36
|
-
assert_path_exist(
|
28
|
+
assert_equal(tmpfile('create'), project('create').path)
|
29
|
+
assert_path_exist(tmpfile('create'))
|
37
30
|
assert_raise do
|
38
|
-
ENV['MIGA_HOME'] =
|
39
|
-
|
31
|
+
ENV['MIGA_HOME'] = tmpfile('chez-moi')
|
32
|
+
project('cuckoo')
|
40
33
|
end
|
41
|
-
ensure
|
42
|
-
ENV['MIGA_HOME'] = $tmp
|
43
34
|
end
|
44
35
|
|
45
36
|
def test_load
|
46
|
-
p =
|
37
|
+
p = project('load')
|
47
38
|
assert_equal(MiGA::Project, p.class)
|
48
39
|
File.unlink p.metadata.path
|
49
40
|
assert_raise do
|
@@ -52,8 +43,8 @@ class ProjectTest < Test::Unit::TestCase
|
|
52
43
|
end
|
53
44
|
|
54
45
|
def test_datasets
|
55
|
-
p =
|
56
|
-
d =
|
46
|
+
p = project
|
47
|
+
d = dataset(0, 'd1')
|
57
48
|
assert_equal(MiGA::Dataset, d.class)
|
58
49
|
assert_equal([d], p.datasets)
|
59
50
|
assert_equal(['d1'], p.dataset_names)
|
@@ -65,55 +56,58 @@ class ProjectTest < Test::Unit::TestCase
|
|
65
56
|
end
|
66
57
|
|
67
58
|
def test_import_dataset
|
68
|
-
p1 =
|
59
|
+
p1 = project
|
69
60
|
d = p1.add_dataset('d1')
|
70
61
|
File.open(
|
71
|
-
|
62
|
+
File.join(p1.path, 'data', '01.raw_reads', "#{d.name}.1.fastq"), 'w'
|
72
63
|
) { |f| f.puts ':-)' }
|
73
64
|
File.open(
|
74
|
-
|
65
|
+
File.join(p1.path, 'data', '01.raw_reads', "#{d.name}.done"), 'w'
|
75
66
|
) { |f| f.puts ':-)' }
|
76
67
|
d.next_preprocessing(true)
|
77
|
-
p2 =
|
68
|
+
p2 = project('import_dataset')
|
78
69
|
assert_empty(p2.datasets)
|
79
70
|
assert_nil(p2.dataset('d1'))
|
80
71
|
p2.import_dataset(d)
|
81
72
|
assert_equal(1, p2.datasets.size)
|
82
73
|
assert_equal(MiGA::Dataset, p2.dataset('d1').class)
|
83
74
|
assert_equal(1, p2.dataset('d1').results.size)
|
84
|
-
assert_path_exist(
|
85
|
-
|
75
|
+
assert_path_exist(
|
76
|
+
File.join(p2.path, 'data', '01.raw_reads', "#{d.name}.1.fastq")
|
77
|
+
)
|
78
|
+
assert_path_exist(File.join(p2.path, 'metadata', "#{d.name}.json"))
|
86
79
|
end
|
87
80
|
|
88
81
|
def test_add_result
|
89
|
-
p1 =
|
82
|
+
p1 = project
|
90
83
|
assert_nil(p1.add_result(:doom))
|
91
84
|
%w[.Rdata .log .txt .done].each do |x|
|
92
85
|
assert_nil(p1.add_result(:haai_distances))
|
93
86
|
FileUtils.touch(
|
94
|
-
File.join(
|
87
|
+
File.join(
|
88
|
+
p1.path, 'data', '09.distances', '01.haai', "miga-project#{x}"
|
89
|
+
)
|
95
90
|
)
|
96
91
|
end
|
97
92
|
assert_equal(MiGA::Result, p1.add_result(:haai_distances).class)
|
98
93
|
end
|
99
94
|
|
100
95
|
def test_result
|
101
|
-
p1 =
|
96
|
+
p1 = project
|
102
97
|
assert_nil(p1.result(:n00b))
|
103
98
|
assert_nil(p1.result(:project_stats))
|
104
|
-
File.
|
105
|
-
|
106
|
-
) { |fh| fh.puts '{}' }
|
99
|
+
json = File.join(p1.path, 'data', '90.stats', 'miga-project.json')
|
100
|
+
File.open(json, 'w') { |fh| fh.puts '{}' }
|
107
101
|
assert_not_nil(p1.result(:project_stats))
|
108
102
|
assert_equal(1, p1.results.size)
|
109
103
|
end
|
110
104
|
|
111
105
|
def test_preprocessing
|
112
|
-
p1 =
|
106
|
+
p1 = project
|
113
107
|
assert_predicate(p1, :done_preprocessing?)
|
114
108
|
d1 = p1.add_dataset('BAH')
|
115
109
|
assert_not_predicate(p1, :done_preprocessing?)
|
116
|
-
FileUtils.touch(File.
|
110
|
+
FileUtils.touch(File.join(p1.path, 'data', '90.stats', "#{d1.name}.done"))
|
117
111
|
assert_predicate(p1, :done_preprocessing?)
|
118
112
|
assert_nil(p1.next_inclade)
|
119
113
|
p1.metadata[:type] = :clade
|
@@ -126,7 +120,7 @@ class ProjectTest < Test::Unit::TestCase
|
|
126
120
|
aai_distances: %w[.Rdata .log .txt],
|
127
121
|
ani_distances: %w[.Rdata .log .txt],
|
128
122
|
clade_finding: %w[.pdf .classif .medoids
|
129
|
-
|
123
|
+
.class.tsv .class.nwk .proposed-clades],
|
130
124
|
subclades: %w[.pdf .classif .medoids .class.tsv .class.nwk],
|
131
125
|
ogs: %w[.ogs .stats]
|
132
126
|
}
|
@@ -140,7 +134,7 @@ class ProjectTest < Test::Unit::TestCase
|
|
140
134
|
end
|
141
135
|
|
142
136
|
def test_empty_results
|
143
|
-
p1 =
|
137
|
+
p1 = project
|
144
138
|
p1.metadata[:type] = :clade
|
145
139
|
%i[clade_finding subclades ogs].each do |r|
|
146
140
|
assert_nil(p1.add_result(r), "Unexpected result exists: #{r}")
|
@@ -150,7 +144,7 @@ class ProjectTest < Test::Unit::TestCase
|
|
150
144
|
end
|
151
145
|
|
152
146
|
def test_force_result
|
153
|
-
p1 =
|
147
|
+
p1 = project
|
154
148
|
create_result_files(p1, :ogs, %w[.empty])
|
155
149
|
date1 = p1.add_result(:ogs)[:created]
|
156
150
|
sleep(1)
|
data/test/remote_dataset_test.rb
CHANGED
@@ -3,19 +3,10 @@ require 'miga/project'
|
|
3
3
|
require 'miga/remote_dataset'
|
4
4
|
|
5
5
|
class RemoteDatasetTest < Test::Unit::TestCase
|
6
|
+
include TestHelper
|
6
7
|
|
7
8
|
def setup
|
8
|
-
|
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
|
-
end
|
15
|
-
|
16
|
-
def teardown
|
17
|
-
FileUtils.rm_rf $tmp
|
18
|
-
ENV['MIGA_HOME'] = nil
|
9
|
+
initialize_miga_home
|
19
10
|
end
|
20
11
|
|
21
12
|
def test_class_universe
|
@@ -33,7 +24,8 @@ class RemoteDatasetTest < Test::Unit::TestCase
|
|
33
24
|
{ embl: :ebi, nuccore: :ncbi }.each do |db, universe|
|
34
25
|
rd = MiGA::RemoteDataset.new(hiv2, db, universe)
|
35
26
|
assert_equal([hiv2], rd.ids)
|
36
|
-
|
27
|
+
|
28
|
+
declare_remote_access
|
37
29
|
tx = rd.get_ncbi_taxonomy
|
38
30
|
msg = "Failed on #{universe}:#{db}"
|
39
31
|
assert_equal(MiGA::Taxonomy, tx.class, msg)
|
@@ -57,8 +49,9 @@ class RemoteDatasetTest < Test::Unit::TestCase
|
|
57
49
|
n = 'Cjac_L14'
|
58
50
|
rd = MiGA::RemoteDataset.new(cjac, :assembly_gz, :web)
|
59
51
|
assert_equal([cjac], rd.ids)
|
60
|
-
|
61
|
-
|
52
|
+
|
53
|
+
declare_remote_access
|
54
|
+
p = project
|
62
55
|
assert_nil(p.dataset(n))
|
63
56
|
rd.save_to(p, n)
|
64
57
|
p.add_dataset(n)
|
@@ -67,7 +60,7 @@ class RemoteDatasetTest < Test::Unit::TestCase
|
|
67
60
|
end
|
68
61
|
|
69
62
|
def test_asm_acc2id
|
70
|
-
|
63
|
+
declare_remote_access
|
71
64
|
assert_nil(MiGA::RemoteDataset.ncbi_asm_acc2id('NotAnAccession'))
|
72
65
|
id = MiGA::RemoteDataset.ncbi_asm_acc2id('GCA_004684205.1')
|
73
66
|
assert_equal('2514661', id)
|
@@ -75,9 +68,9 @@ class RemoteDatasetTest < Test::Unit::TestCase
|
|
75
68
|
end
|
76
69
|
|
77
70
|
def test_update_metadata
|
78
|
-
|
71
|
+
declare_remote_access
|
79
72
|
hiv1 = 'GCF_000856385.1'
|
80
|
-
d1 = MiGA::Dataset.new(
|
73
|
+
d1 = MiGA::Dataset.new(project, 'd1')
|
81
74
|
assert_nil(d1.metadata[:ncbi_assembly])
|
82
75
|
rd = MiGA::RemoteDataset.new(hiv1, :assembly, :ncbi)
|
83
76
|
rd.update_metadata(d1, passthrough: 123, metadata_only: true)
|
@@ -87,36 +80,35 @@ class RemoteDatasetTest < Test::Unit::TestCase
|
|
87
80
|
end
|
88
81
|
|
89
82
|
def test_type_status_asm
|
90
|
-
|
83
|
+
declare_remote_access
|
91
84
|
rd = MiGA::RemoteDataset.new('GCF_000018105.1', :assembly, :ncbi)
|
92
85
|
assert { rd.get_metadata[:is_type] }
|
93
86
|
end
|
94
87
|
|
95
88
|
def test_nontype_status_asm
|
96
|
-
|
89
|
+
declare_remote_access
|
97
90
|
rd = MiGA::RemoteDataset.new('GCA_004684205.1', :assembly, :ncbi)
|
98
91
|
assert { !rd.get_metadata[:is_type] }
|
99
92
|
end
|
100
93
|
|
101
94
|
def test_type_status_nuccore
|
102
|
-
|
95
|
+
declare_remote_access
|
103
96
|
rd = MiGA::RemoteDataset.new('NC_019748.1', :nuccore, :ncbi)
|
104
97
|
assert { rd.get_metadata[:is_type] }
|
105
98
|
end
|
106
99
|
|
107
100
|
def test_ref_type_status
|
108
|
-
|
101
|
+
declare_remote_access
|
109
102
|
rd = MiGA::RemoteDataset.new('GCA_002849345', :assembly, :ncbi)
|
110
103
|
assert { !rd.get_metadata[:is_type] }
|
111
104
|
assert { rd.get_metadata[:is_ref_type] }
|
112
105
|
end
|
113
106
|
|
114
107
|
# This test is too expensive (too much time to run it!)
|
115
|
-
#def test_net_timeout
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#end
|
121
|
-
|
108
|
+
# def test_net_timeout
|
109
|
+
# declare_remote_access
|
110
|
+
# bad = "ftp://example.com/miga"
|
111
|
+
# rd = MiGA::RemoteDataset.new(bad, :assembly, :web)
|
112
|
+
# assert_raise(Net::ReadTimeout) { rd.save_to(project, "bad") }
|
113
|
+
# end
|
122
114
|
end
|
data/test/result_stats_test.rb
CHANGED
@@ -3,23 +3,14 @@ require 'miga/project'
|
|
3
3
|
require 'zlib'
|
4
4
|
|
5
5
|
class ResultStatsTest < Test::Unit::TestCase
|
6
|
+
include TestHelper
|
6
7
|
|
7
8
|
def setup
|
8
|
-
|
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
|
-
$p = MiGA::Project.new(File.expand_path('project1', $tmp))
|
13
|
-
$d = $p.add_dataset('dataset1')
|
14
|
-
end
|
15
|
-
|
16
|
-
def teardown
|
17
|
-
FileUtils.rm_rf $tmp
|
18
|
-
ENV['MIGA_HOME'] = nil
|
9
|
+
initialize_miga_home
|
19
10
|
end
|
20
11
|
|
21
12
|
def file_path(dir, ext)
|
22
|
-
File.join(
|
13
|
+
File.join(project.path, dir, "#{dataset.name}#{ext}")
|
23
14
|
end
|
24
15
|
|
25
16
|
def touch_done(dir)
|
@@ -29,9 +20,9 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
29
20
|
def test_single_raw_reads
|
30
21
|
dir = 'data/01.raw_reads'
|
31
22
|
fq = file_path(dir, '.1.fastq')
|
32
|
-
File.open(fq, 'w') { |fh| fh.puts '@1','ACTAC','+','####' }
|
23
|
+
File.open(fq, 'w') { |fh| fh.puts '@1', 'ACTAC', '+', '####' }
|
33
24
|
touch_done(dir)
|
34
|
-
r =
|
25
|
+
r = dataset.add_result(:raw_reads)
|
35
26
|
assert_equal({}, r[:stats])
|
36
27
|
r.compute_stats
|
37
28
|
assert_not_empty(r[:stats])
|
@@ -43,11 +34,11 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
43
34
|
def test_coupled_raw_reads
|
44
35
|
dir = 'data/01.raw_reads'
|
45
36
|
fq = file_path(dir, '.1.fastq')
|
46
|
-
File.open(fq, 'w') { |fh| fh.puts '@1','ACTAC','+','####' }
|
37
|
+
File.open(fq, 'w') { |fh| fh.puts '@1', 'ACTAC', '+', '####' }
|
47
38
|
fq = file_path(dir, '.2.fastq')
|
48
|
-
File.open(fq, 'w') { |fh| fh.puts '@1','ACTAC','+','####' }
|
39
|
+
File.open(fq, 'w') { |fh| fh.puts '@1', 'ACTAC', '+', '####' }
|
49
40
|
touch_done(dir)
|
50
|
-
r =
|
41
|
+
r = dataset.add_result(:raw_reads)
|
51
42
|
r.compute_stats
|
52
43
|
assert_not_empty(r[:stats])
|
53
44
|
assert_nil(r[:stats][:reads])
|
@@ -59,7 +50,7 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
59
50
|
dir = 'data/02.trimmed_reads'
|
60
51
|
FileUtils.touch(file_path(dir, '.1.clipped.fastq'))
|
61
52
|
touch_done(dir)
|
62
|
-
r =
|
53
|
+
r = dataset.add_result(:trimmed_reads)
|
63
54
|
assert_equal({}, r[:stats])
|
64
55
|
r.compute_stats
|
65
56
|
assert_equal({}, r[:stats])
|
@@ -70,7 +61,7 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
70
61
|
Dir.mkdir(file_path(dir, '.solexaqa'))
|
71
62
|
Dir.mkdir(file_path(dir, '.fastqc'))
|
72
63
|
touch_done(dir)
|
73
|
-
r =
|
64
|
+
r = dataset.add_result(:read_quality)
|
74
65
|
assert_equal({}, r[:stats])
|
75
66
|
r.compute_stats
|
76
67
|
assert_equal({}, r[:stats])
|
@@ -79,9 +70,9 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
79
70
|
def test_trimmed_fasta
|
80
71
|
dir = 'data/04.trimmed_fasta'
|
81
72
|
fa = file_path(dir, '.CoupledReads.fa')
|
82
|
-
File.open(fa, 'w') { |fh| fh.puts '>1','ACTAC' }
|
73
|
+
File.open(fa, 'w') { |fh| fh.puts '>1', 'ACTAC' }
|
83
74
|
touch_done(dir)
|
84
|
-
r =
|
75
|
+
r = dataset.add_result(:trimmed_fasta)
|
85
76
|
assert_equal({}, r[:stats])
|
86
77
|
r.compute_stats
|
87
78
|
assert_equal(1, r[:stats][:reads])
|
@@ -92,9 +83,9 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
92
83
|
# Prepare result
|
93
84
|
dir = 'data/05.assembly'
|
94
85
|
fa = file_path(dir, '.LargeContigs.fna')
|
95
|
-
File.open(fa, 'w') { |fh| fh.puts '>1','ACTAC' }
|
86
|
+
File.open(fa, 'w') { |fh| fh.puts '>1', 'ACTAC' }
|
96
87
|
touch_done(dir)
|
97
|
-
r =
|
88
|
+
r = dataset.add_result(:assembly)
|
98
89
|
|
99
90
|
# Test assertions
|
100
91
|
assert_equal({}, r[:stats])
|
@@ -108,13 +99,13 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
108
99
|
# Prepare result
|
109
100
|
dir = 'data/06.cds'
|
110
101
|
fa = file_path(dir, '.faa')
|
111
|
-
File.open(fa, 'w') { |fh| fh.puts '>1','M' }
|
102
|
+
File.open(fa, 'w') { |fh| fh.puts '>1', 'M' }
|
112
103
|
gff = file_path(dir, '.gff3.gz')
|
113
104
|
Zlib::GzipWriter.open(gff) do |fh|
|
114
105
|
fh.puts '# Model Data: a=b;transl_table=11;'
|
115
106
|
end
|
116
107
|
touch_done(dir)
|
117
|
-
r =
|
108
|
+
r = dataset.add_result(:cds)
|
118
109
|
|
119
110
|
# Test assertions
|
120
111
|
assert_equal({}, r[:stats])
|
@@ -139,7 +130,7 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
139
130
|
fh.puts ' phylum Abc 0.0 **** '
|
140
131
|
end
|
141
132
|
touch_done(dir)
|
142
|
-
r =
|
133
|
+
r = dataset.add_result(:taxonomy)
|
143
134
|
|
144
135
|
# Test assertions
|
145
136
|
assert_nil(r[:stats][:closest_relative])
|
@@ -148,5 +139,4 @@ class ResultStatsTest < Test::Unit::TestCase
|
|
148
139
|
assert_equal([100.0, '%'], r[:stats][:aai])
|
149
140
|
assert_equal(0.0, r[:stats][:phylum_pvalue])
|
150
141
|
end
|
151
|
-
|
152
142
|
end
|
data/test/result_test.rb
CHANGED
@@ -2,62 +2,69 @@ require 'test_helper'
|
|
2
2
|
require 'miga/project'
|
3
3
|
|
4
4
|
class ResultTest < Test::Unit::TestCase
|
5
|
+
include TestHelper
|
5
6
|
|
6
7
|
def setup
|
7
|
-
|
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')
|
8
|
+
initialize_miga_home
|
13
9
|
FileUtils.touch(
|
14
|
-
File.join(
|
10
|
+
File.join(
|
11
|
+
project.path, 'data', '02.trimmed_reads',
|
12
|
+
"#{dataset.name}.1.clipped.fastq"
|
13
|
+
)
|
14
|
+
)
|
15
15
|
FileUtils.touch(
|
16
|
-
File.join(
|
16
|
+
File.join(
|
17
|
+
project.path, 'data', '02.trimmed_reads', "#{dataset.name}.done"
|
18
|
+
)
|
19
|
+
)
|
17
20
|
FileUtils.touch(
|
18
|
-
File.join(
|
21
|
+
File.join(
|
22
|
+
project.path, 'data', '10.clades', '01.find', 'miga-project.empty'
|
23
|
+
)
|
24
|
+
)
|
19
25
|
FileUtils.touch(
|
20
|
-
File.join(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
FileUtils.rm_rf $tmp
|
25
|
-
ENV['MIGA_HOME'] = nil
|
26
|
+
File.join(
|
27
|
+
project.path, 'data', '10.clades', '01.find', 'miga-project.done'
|
28
|
+
)
|
29
|
+
)
|
26
30
|
end
|
27
31
|
|
28
32
|
def test_add_result
|
29
|
-
r =
|
30
|
-
|
31
|
-
r =
|
33
|
+
r = dataset.add_result(:trimmed_reads)
|
34
|
+
assert_instance_of(MiGA::Result, r)
|
35
|
+
r = dataset.add_result(:asssembly)
|
32
36
|
assert_nil(r)
|
33
|
-
r =
|
34
|
-
|
37
|
+
r = project.add_result(:clade_finding)
|
38
|
+
assert_instance_of(MiGA::Result, r)
|
35
39
|
end
|
36
40
|
|
37
41
|
def test_result_source
|
38
|
-
r =
|
39
|
-
assert_equal(
|
42
|
+
r = dataset.add_result(:trimmed_reads)
|
43
|
+
assert_equal(dataset.name, r.source.name)
|
40
44
|
assert_equal(:trimmed_reads, r.key)
|
41
45
|
assert_equal('data/02.trimmed_reads', r.relative_dir)
|
42
|
-
assert_equal('data/02.trimmed_reads/
|
43
|
-
assert_equal(
|
44
|
-
assert_equal(
|
45
|
-
r =
|
46
|
-
assert_equal(
|
46
|
+
assert_equal('data/02.trimmed_reads/dataset0.json', r.relative_path)
|
47
|
+
assert_equal(project.path, r.project.path)
|
48
|
+
assert_equal(project.path, r.project_path)
|
49
|
+
r = project.add_result(:clade_finding)
|
50
|
+
assert_equal(project.path, r.source.path)
|
47
51
|
end
|
48
52
|
|
49
53
|
def test_dates
|
50
|
-
r =
|
54
|
+
r = dataset.add_result(:trimmed_reads)
|
51
55
|
assert_nil(r.done_at)
|
52
56
|
assert_nil(r.started_at)
|
53
|
-
tf = File.join(
|
54
|
-
|
57
|
+
tf = File.join(
|
58
|
+
project.path, 'data', '02.trimmed_reads', "#{dataset.name}.done"
|
59
|
+
)
|
60
|
+
File.open(tf, 'w') { |fh| fh.puts Time.new(1, 2, 3, 4, 5) }
|
55
61
|
assert_equal(Time, r.done_at.class)
|
56
62
|
assert_nil(r.running_time)
|
57
|
-
tf = File.join(
|
58
|
-
|
59
|
-
|
63
|
+
tf = File.join(
|
64
|
+
project.path, 'data', '02.trimmed_reads', "#{dataset.name}.start"
|
65
|
+
)
|
66
|
+
File.open(tf, 'w') { |fh| fh.puts Time.new(1, 2, 3, 4, 0) }
|
67
|
+
r = dataset.add_result(:trimmed_reads)
|
60
68
|
assert_equal(5.0, r.running_time)
|
61
69
|
end
|
62
|
-
|
63
70
|
end
|