miga-base 0.7.9.0 → 0.7.12.1
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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/miga/cli/action/browse.rb +213 -0
- data/lib/miga/cli/action/browse/about.html +31 -0
- data/lib/miga/cli/action/browse/dataset.html +5 -0
- data/lib/miga/cli/action/browse/dataset_menu_item.html +3 -0
- data/lib/miga/cli/action/browse/datasets.html +4 -0
- data/lib/miga/cli/action/browse/favicon-32.png +0 -0
- data/lib/miga/cli/action/browse/index.html +8 -0
- data/lib/miga/cli/action/browse/layout.html +57 -0
- data/lib/miga/cli/action/browse/redirect.html +11 -0
- data/lib/miga/cli/action/browse/style.css +97 -0
- data/lib/miga/cli/action/classify_wf.rb +3 -1
- data/lib/miga/cli/action/derep_wf.rb +4 -0
- data/lib/miga/cli/action/edit.rb +9 -6
- data/lib/miga/cli/action/quality_wf.rb +4 -1
- data/lib/miga/cli/action/stats.rb +1 -1
- data/lib/miga/cli/action/wf.rb +11 -3
- data/lib/miga/cli/base.rb +27 -26
- data/lib/miga/common/format.rb +26 -6
- data/lib/miga/daemon.rb +6 -4
- data/lib/miga/dataset.rb +5 -1
- data/lib/miga/dataset/base.rb +3 -3
- data/lib/miga/dataset/hooks.rb +4 -4
- data/lib/miga/dataset/result.rb +18 -14
- data/lib/miga/lair.rb +1 -1
- data/lib/miga/project/dataset.rb +3 -5
- data/lib/miga/project/hooks.rb +4 -3
- data/lib/miga/remote_dataset/download.rb +2 -1
- data/lib/miga/result.rb +3 -1
- data/lib/miga/result/stats.rb +55 -23
- data/lib/miga/version.rb +2 -2
- data/scripts/cds.bash +0 -1
- data/scripts/distances.bash +6 -1
- data/test/daemon_test.rb +1 -1
- data/test/dataset_test.rb +3 -1
- data/test/project_test.rb +1 -1
- data/test/remote_dataset_test.rb +1 -1
- metadata +16 -6
data/lib/miga/project/hooks.rb
CHANGED
@@ -26,14 +26,15 @@ module MiGA::Project::Hooks
|
|
26
26
|
end
|
27
27
|
|
28
28
|
##
|
29
|
-
# Run +cmd+ in the command-line with {{variables}}:
|
30
|
-
# object (
|
29
|
+
# Run +cmd+ in the command-line with {{variables}}:
|
30
|
+
# project, project_name, miga, object (if defined by the event)
|
31
31
|
# - +hook_args+: +[cmd]+
|
32
32
|
# - +event_args+: +[object (optional)]+
|
33
33
|
def hook_run_cmd(hook_args, event_args)
|
34
34
|
Process.wait(
|
35
35
|
spawn hook_args.first.miga_variables(
|
36
|
-
project: path,
|
36
|
+
project: path, project_name: name,
|
37
|
+
miga: MiGA::MiGA.root_path, object: event_args.first
|
37
38
|
)
|
38
39
|
)
|
39
40
|
end
|
@@ -94,12 +94,13 @@ class MiGA::RemoteDataset
|
|
94
94
|
@timeout_try = 0
|
95
95
|
begin
|
96
96
|
DEBUG 'GET: ' + url
|
97
|
-
open(
|
97
|
+
URI.parse(url).open(read_timeout: 600) { |f| doc = f.read }
|
98
98
|
rescue => e
|
99
99
|
@timeout_try += 1
|
100
100
|
raise e if @timeout_try >= 3
|
101
101
|
|
102
102
|
sleep 5 # <- For: 429 Too Many Requests
|
103
|
+
DEBUG "RETRYING after: #{e}"
|
103
104
|
retry
|
104
105
|
end
|
105
106
|
doc
|
data/lib/miga/result.rb
CHANGED
@@ -164,7 +164,9 @@ class MiGA::Result < MiGA::MiGA
|
|
164
164
|
# Unlink result by removing the .done and .start timestamps and the
|
165
165
|
# .json descriptor, but don't remove any other associated files
|
166
166
|
def unlink
|
167
|
-
%i(start done).each
|
167
|
+
%i(start done).each do |i|
|
168
|
+
f = path(i) and File.exists?(f) and File.unlink(f)
|
169
|
+
end
|
168
170
|
File.unlink path
|
169
171
|
end
|
170
172
|
|
data/lib/miga/result/stats.rb
CHANGED
@@ -8,6 +8,7 @@ module MiGA::Result::Stats
|
|
8
8
|
# (Re-)calculate and save the statistics for the result
|
9
9
|
def compute_stats
|
10
10
|
method = :"compute_stats_#{key}"
|
11
|
+
MiGA::MiGA.DEBUG "Result(#{key}).compute_stats"
|
11
12
|
stats = self.respond_to?(method, true) ? send(method) : nil
|
12
13
|
unless stats.nil?
|
13
14
|
self[:stats] = stats
|
@@ -16,32 +17,45 @@ module MiGA::Result::Stats
|
|
16
17
|
self[:stats]
|
17
18
|
end
|
18
19
|
|
20
|
+
##
|
21
|
+
# Access the stats entry of results
|
22
|
+
def stats
|
23
|
+
self[:stats]
|
24
|
+
end
|
25
|
+
|
19
26
|
private
|
20
27
|
|
21
28
|
def compute_stats_raw_reads
|
22
29
|
stats = {}
|
30
|
+
seq_opts = { gc: true, x: true, skew: true }
|
23
31
|
if self[:files][:pair1].nil?
|
24
|
-
s = MiGA::MiGA.seqs_length(file_path(:single), :fastq,
|
32
|
+
s = MiGA::MiGA.seqs_length(file_path(:single), :fastq, seq_opts)
|
25
33
|
stats = {
|
26
34
|
reads: s[:n],
|
27
35
|
length_average: [s[:avg], 'bp'],
|
28
36
|
length_standard_deviation: [s[:sd], 'bp'],
|
29
37
|
g_c_content: [s[:gc], '%'],
|
30
|
-
x_content: [s[:x], '%']
|
38
|
+
x_content: [s[:x], '%'],
|
39
|
+
g_c_skew: [s[:gc_skew], '%'],
|
40
|
+
a_t_skew: [s[:at_skew], '%']
|
31
41
|
}
|
32
42
|
else
|
33
|
-
s1 = MiGA::MiGA.seqs_length(file_path(:pair1), :fastq,
|
34
|
-
s2 = MiGA::MiGA.seqs_length(file_path(:pair2), :fastq,
|
43
|
+
s1 = MiGA::MiGA.seqs_length(file_path(:pair1), :fastq, seq_opts)
|
44
|
+
s2 = MiGA::MiGA.seqs_length(file_path(:pair2), :fastq, seq_opts)
|
35
45
|
stats = {
|
36
46
|
read_pairs: s1[:n],
|
37
47
|
forward_length_average: [s1[:avg], 'bp'],
|
38
48
|
forward_length_standard_deviation: [s1[:sd], 'bp'],
|
39
49
|
forward_g_c_content: [s1[:gc], '%'],
|
40
50
|
forward_x_content: [s1[:x], '%'],
|
51
|
+
forward_g_c_skew: [s1[:gc_skew], '%'],
|
52
|
+
forward_a_t_skew: [s1[:at_skew], '%'],
|
41
53
|
reverse_length_average: [s2[:avg], 'bp'],
|
42
54
|
reverse_length_standard_deviation: [s2[:sd], 'bp'],
|
43
55
|
reverse_g_c_content: [s2[:gc], '%'],
|
44
|
-
reverse_x_content: [s2[:x], '%']
|
56
|
+
reverse_x_content: [s2[:x], '%'],
|
57
|
+
reverse_g_c_skew: [s2[:gc_skew], '%'],
|
58
|
+
reverse_a_t_skew: [s2[:at_skew], '%']
|
45
59
|
}
|
46
60
|
end
|
47
61
|
stats
|
@@ -49,19 +63,22 @@ module MiGA::Result::Stats
|
|
49
63
|
|
50
64
|
def compute_stats_trimmed_fasta
|
51
65
|
f = self[:files][:coupled].nil? ? file_path(:single) : file_path(:coupled)
|
52
|
-
s = MiGA::MiGA.seqs_length(f, :fasta, gc: true, x: true)
|
66
|
+
s = MiGA::MiGA.seqs_length(f, :fasta, gc: true, x: true, skew: true)
|
53
67
|
{
|
54
68
|
reads: s[:n],
|
55
69
|
length_average: [s[:avg], 'bp'],
|
56
70
|
length_standard_deviation: [s[:sd], 'bp'],
|
57
71
|
g_c_content: [s[:gc], '%'],
|
58
|
-
x_content: [s[:x], '%']
|
72
|
+
x_content: [s[:x], '%'],
|
73
|
+
g_c_skew: [s[:gc_skew], '%'],
|
74
|
+
a_t_skew: [s[:at_skew], '%']
|
59
75
|
}
|
60
76
|
end
|
61
77
|
|
62
78
|
def compute_stats_assembly
|
63
79
|
s = MiGA::MiGA.seqs_length(
|
64
|
-
file_path(:largecontigs), :fasta,
|
80
|
+
file_path(:largecontigs), :fasta,
|
81
|
+
n50: true, gc: true, x: true, skew: true
|
65
82
|
)
|
66
83
|
{
|
67
84
|
contigs: s[:n],
|
@@ -69,7 +86,9 @@ module MiGA::Result::Stats
|
|
69
86
|
total_length: [s[:tot], 'bp'],
|
70
87
|
longest_sequence: [s[:max], 'bp'],
|
71
88
|
g_c_content: [s[:gc], '%'],
|
72
|
-
x_content: [s[:x], '%']
|
89
|
+
x_content: [s[:x], '%'],
|
90
|
+
g_c_skew: [s[:gc_skew], '%'],
|
91
|
+
a_t_skew: [s[:at_skew], '%']
|
73
92
|
}
|
74
93
|
end
|
75
94
|
|
@@ -109,20 +128,8 @@ module MiGA::Result::Stats
|
|
109
128
|
end
|
110
129
|
end
|
111
130
|
else
|
112
|
-
#
|
113
|
-
|
114
|
-
%w[Archaea Bacteria].include?(tax[:d]) &&
|
115
|
-
file_path(:raw_report).nil?
|
116
|
-
scr = "#{MiGA::MiGA.root_path}/utils/domain-ess-genes.rb"
|
117
|
-
rep = file_path(:report)
|
118
|
-
rc_p = File.expand_path('.miga_rc', ENV['HOME'])
|
119
|
-
rc = File.exist?(rc_p) ? ". '#{rc_p}' && " : ''
|
120
|
-
$stderr.print `#{rc} ruby '#{scr}' \
|
121
|
-
'#{rep}' '#{rep}.domain' '#{tax[:d][0]}'`
|
122
|
-
add_file(:raw_report, "#{source.name}.ess/log")
|
123
|
-
add_file(:report, "#{source.name}.ess/log.domain")
|
124
|
-
end
|
125
|
-
# Extract/compute quality values
|
131
|
+
# Estimate quality metrics
|
132
|
+
fix_essential_genes_by_domain
|
126
133
|
stats = { completeness: [0.0, '%'], contamination: [0.0, '%'] }
|
127
134
|
File.open(file_path(:report), 'r') do |fh|
|
128
135
|
fh.each_line do |ln|
|
@@ -131,6 +138,8 @@ module MiGA::Result::Stats
|
|
131
138
|
end
|
132
139
|
end
|
133
140
|
end
|
141
|
+
|
142
|
+
# Determine qualitative range
|
134
143
|
stats[:quality] = stats[:completeness][0] - stats[:contamination][0] * 5
|
135
144
|
source.metadata[:quality] =
|
136
145
|
case stats[:quality]
|
@@ -140,6 +149,12 @@ module MiGA::Result::Stats
|
|
140
149
|
else; :low
|
141
150
|
end
|
142
151
|
source.save
|
152
|
+
|
153
|
+
# Inactivate low-quality datasets
|
154
|
+
min_qual = (project.metadata[:min_qual] || 25)
|
155
|
+
if min_qual != 'no' && stats[:quality] < min_qual
|
156
|
+
source.inactivate! 'Low quality genome'
|
157
|
+
end
|
143
158
|
end
|
144
159
|
stats
|
145
160
|
end
|
@@ -175,4 +190,21 @@ module MiGA::Result::Stats
|
|
175
190
|
end
|
176
191
|
stats
|
177
192
|
end
|
193
|
+
|
194
|
+
# Fix estimates based on essential genes based on taxonomy
|
195
|
+
def fix_essential_genes_by_domain
|
196
|
+
return if (tax = source.metadata[:tax]).nil? ||
|
197
|
+
!%w[Archaea Bacteria].include?(tax[:d]) ||
|
198
|
+
file_path(:raw_report)
|
199
|
+
|
200
|
+
MiGA::MiGA.DEBUG "Fixing essential genes by domain"
|
201
|
+
scr = "#{MiGA::MiGA.root_path}/utils/domain-ess-genes.rb"
|
202
|
+
rep = file_path(:report)
|
203
|
+
rc_p = File.expand_path('.miga_rc', ENV['HOME'])
|
204
|
+
rc = File.exist?(rc_p) ? ". '#{rc_p}' && " : ''
|
205
|
+
$stderr.print `#{rc} ruby '#{scr}' \
|
206
|
+
'#{rep}' '#{rep}.domain' '#{tax[:d][0]}'`
|
207
|
+
add_file(:raw_report, "#{source.name}.ess/log")
|
208
|
+
add_file(:report, "#{source.name}.ess/log.domain")
|
209
|
+
end
|
178
210
|
end
|
data/lib/miga/version.rb
CHANGED
@@ -8,7 +8,7 @@ module MiGA
|
|
8
8
|
# - Float representing the major.minor version.
|
9
9
|
# - Integer representing gem releases of the current version.
|
10
10
|
# - Integer representing minor changes that require new version number.
|
11
|
-
VERSION = [0.7,
|
11
|
+
VERSION = [0.7, 12, 1]
|
12
12
|
|
13
13
|
##
|
14
14
|
# Nickname for the current major.minor version.
|
@@ -16,7 +16,7 @@ module MiGA
|
|
16
16
|
|
17
17
|
##
|
18
18
|
# Date of the current gem release.
|
19
|
-
VERSION_DATE = Date.new(2020,
|
19
|
+
VERSION_DATE = Date.new(2020, 7, 24)
|
20
20
|
|
21
21
|
##
|
22
22
|
# Reference of MiGA.
|
data/scripts/cds.bash
CHANGED
@@ -20,7 +20,6 @@ fi
|
|
20
20
|
TYPE=$(miga ls -P "$PROJECT" -D "$DATASET" -m type | cut -f 2)
|
21
21
|
case "$TYPE" in
|
22
22
|
metagenome|virome)
|
23
|
-
$CMD -p meta
|
24
23
|
prodigal -a "${DATASET}.faa" -d "${DATASET}.fna" -o "${DATASET}.gff3" \
|
25
24
|
-f gff -q -i "../05.assembly/${DATASET}.LargeContigs.fna" -p meta
|
26
25
|
;;
|
data/scripts/distances.bash
CHANGED
@@ -9,7 +9,12 @@ cd "$PROJECT/data/09.distances"
|
|
9
9
|
# Initialize
|
10
10
|
miga date > "$DATASET.start"
|
11
11
|
|
12
|
-
#
|
12
|
+
# Check quality first
|
13
|
+
miga stats -P "$PROJECT" -D "$DATASET" -r essential_genes --compute-and-save
|
14
|
+
inactive=$(miga ls -P "$PROJECT" -D "$DATASET" -m inactive | cut -f 2)
|
15
|
+
[[ "$inactive" == "true" ]] && exit
|
16
|
+
|
17
|
+
# Run distances
|
13
18
|
ruby -I "$MIGA/lib" "$MIGA/utils/distances.rb" "$PROJECT" "$DATASET"
|
14
19
|
|
15
20
|
# Finalize
|
data/test/daemon_test.rb
CHANGED
@@ -93,7 +93,7 @@ class DaemonTest < Test::Unit::TestCase
|
|
93
93
|
0 => /-{20}\n/,
|
94
94
|
1 => /MiGA:#{p.name} launched/,
|
95
95
|
2 => /-{20}\n/,
|
96
|
-
|
96
|
+
6 => /Probing running jobs\n/
|
97
97
|
}.each { |k, v| assert_match(v, l[k], "unexpected line: #{k}") }
|
98
98
|
ensure
|
99
99
|
begin
|
data/test/dataset_test.rb
CHANGED
@@ -185,11 +185,13 @@ class DatasetTest < Test::Unit::TestCase
|
|
185
185
|
d = dataset
|
186
186
|
assert_equal(:incomplete, d.status)
|
187
187
|
assert_predicate(d, :active?)
|
188
|
-
d.inactivate!
|
188
|
+
d.inactivate! 'Too annoying'
|
189
189
|
assert_equal(:inactive, d.status)
|
190
|
+
assert_equal('Inactive: Too annoying', d.metadata[:warn])
|
190
191
|
assert_not_predicate(d, :active?)
|
191
192
|
d.activate!
|
192
193
|
assert_equal(:incomplete, d.status)
|
194
|
+
assert_nil(d.metadata[:warn])
|
193
195
|
assert_predicate(d, :active?)
|
194
196
|
end
|
195
197
|
|
data/test/project_test.rb
CHANGED
@@ -108,7 +108,7 @@ class ProjectTest < Test::Unit::TestCase
|
|
108
108
|
d1 = p1.add_dataset('BAH')
|
109
109
|
assert_not_predicate(p1, :done_preprocessing?)
|
110
110
|
FileUtils.touch(File.join(p1.path, 'data', '90.stats', "#{d1.name}.done"))
|
111
|
-
|
111
|
+
assert { p1.done_preprocessing? true }
|
112
112
|
assert_nil(p1.next_inclade)
|
113
113
|
p1.metadata[:type] = :clade
|
114
114
|
assert_equal(:subclades, p1.next_inclade)
|
data/test/remote_dataset_test.rb
CHANGED
@@ -101,7 +101,7 @@ class RemoteDatasetTest < Test::Unit::TestCase
|
|
101
101
|
|
102
102
|
def test_ref_type_status
|
103
103
|
declare_remote_access
|
104
|
-
rd = MiGA::RemoteDataset.new('
|
104
|
+
rd = MiGA::RemoteDataset.new('GCA_003144295.1', :assembly, :ncbi)
|
105
105
|
assert { !rd.get_metadata[:is_type] }
|
106
106
|
assert { rd.get_metadata[:is_ref_type] }
|
107
107
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miga-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis M. Rodriguez-R
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daemons
|
@@ -118,6 +118,16 @@ files:
|
|
118
118
|
- lib/miga/cli/action/add.rb
|
119
119
|
- lib/miga/cli/action/add_result.rb
|
120
120
|
- lib/miga/cli/action/archive.rb
|
121
|
+
- lib/miga/cli/action/browse.rb
|
122
|
+
- lib/miga/cli/action/browse/about.html
|
123
|
+
- lib/miga/cli/action/browse/dataset.html
|
124
|
+
- lib/miga/cli/action/browse/dataset_menu_item.html
|
125
|
+
- lib/miga/cli/action/browse/datasets.html
|
126
|
+
- lib/miga/cli/action/browse/favicon-32.png
|
127
|
+
- lib/miga/cli/action/browse/index.html
|
128
|
+
- lib/miga/cli/action/browse/layout.html
|
129
|
+
- lib/miga/cli/action/browse/redirect.html
|
130
|
+
- lib/miga/cli/action/browse/style.css
|
121
131
|
- lib/miga/cli/action/classify_wf.rb
|
122
132
|
- lib/miga/cli/action/console.rb
|
123
133
|
- lib/miga/cli/action/daemon.rb
|
@@ -529,7 +539,7 @@ homepage: http://enve-omics.ce.gatech.edu/miga
|
|
529
539
|
licenses:
|
530
540
|
- Artistic-2.0
|
531
541
|
metadata: {}
|
532
|
-
post_install_message:
|
542
|
+
post_install_message:
|
533
543
|
rdoc_options:
|
534
544
|
- lib
|
535
545
|
- README.md
|
@@ -550,8 +560,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
550
560
|
- !ruby/object:Gem::Version
|
551
561
|
version: '0'
|
552
562
|
requirements: []
|
553
|
-
rubygems_version: 3.
|
554
|
-
signing_key:
|
563
|
+
rubygems_version: 3.1.2
|
564
|
+
signing_key:
|
555
565
|
specification_version: 4
|
556
566
|
summary: MiGA
|
557
567
|
test_files: []
|