miga-base 1.1.3.1 → 1.1.3.2
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/lib/miga/cli/action/doctor/base.rb +6 -5
- data/lib/miga/version.rb +2 -2
- data/utils/distance/commands.rb +20 -11
- data/utils/subclade/pipeline.rb +9 -8
- data/utils/subclades.R +22 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 869314efef2d92764d569f6ba5bc7cf03182a8a4dddb27405349923ca1518100
|
4
|
+
data.tar.gz: 9bd3e4a7fb5d34c0d34b850a0f300b4f6ddbc4607d63fc92a5240c7674ce53b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2deb4fd773f70d362d2d22224917bc4c72ed39e61951a403d6b9a8584cc99580425d140db4c6048dbf3680d696e26d6683802f88797a08f851b92d70389b79a
|
7
|
+
data.tar.gz: 1448247c7b883b5a52f92000a7085301b27645f8dc8ef069620815d8dd29f3a0c2ad2d9e3ace1821530bccaa91623793bd8b1f33f158ecf0d731b87c0cd6bc25
|
@@ -59,13 +59,14 @@ module MiGA::Cli::Action::Doctor::Base
|
|
59
59
|
next if (lineno += 1) == 1
|
60
60
|
|
61
61
|
r = ln.split("\t")
|
62
|
-
|
62
|
+
names = [r[0], r[1]]
|
63
|
+
next unless names.any? { |i| p.dataset(i).nil? }
|
63
64
|
|
64
|
-
|
65
|
-
if p.dataset(
|
66
|
-
notok[
|
65
|
+
names.each do |i|
|
66
|
+
if p.dataset(i).nil? || !p.dataset(i).active?
|
67
|
+
notok[i] = true
|
67
68
|
else
|
68
|
-
fix[
|
69
|
+
fix[i] = true
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
data/lib/miga/version.rb
CHANGED
@@ -12,7 +12,7 @@ module MiGA
|
|
12
12
|
# - String indicating release status:
|
13
13
|
# - rc* release candidate, not released as gem
|
14
14
|
# - [0-9]+ stable release, released as gem
|
15
|
-
VERSION = [1.1, 3,
|
15
|
+
VERSION = [1.1, 3, 2].freeze
|
16
16
|
|
17
17
|
##
|
18
18
|
# Nickname for the current major.minor version.
|
@@ -20,7 +20,7 @@ module MiGA
|
|
20
20
|
|
21
21
|
##
|
22
22
|
# Date of the current gem relese.
|
23
|
-
VERSION_DATE = Date.new(2021, 11,
|
23
|
+
VERSION_DATE = Date.new(2021, 11, 26)
|
24
24
|
|
25
25
|
##
|
26
26
|
# References of MiGA
|
data/utils/distance/commands.rb
CHANGED
@@ -153,18 +153,27 @@ module MiGA::DistanceRunner::Commands
|
|
153
153
|
return nil if donors.empty?
|
154
154
|
|
155
155
|
# Build target database
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
156
|
+
f1 = donors.first
|
157
|
+
if donors.size > 1
|
158
|
+
File.open(f0 = tmp_file, 'w') { |fh| donors.each { |i| fh.puts i } }
|
159
|
+
run_cmd(
|
160
|
+
<<~CMD
|
161
|
+
FastAAI merge_db --threads #{opts[:thr]} \
|
162
|
+
--donor_file "#{f0}" --recipient "#{f1 = tmp_file}"
|
163
|
+
CMD
|
164
|
+
)
|
165
|
+
raise "Cannot merge databases into: #{f1}" unless File.size?(f1)
|
166
|
+
end
|
161
167
|
|
162
168
|
# Run FastAAI
|
163
|
-
run_cmd
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
169
|
+
run_cmd(
|
170
|
+
<<~CMD
|
171
|
+
FastAAI db_query --query "#{qry_idx}" --target "#{f1}" \
|
172
|
+
--output "#{f2 = tmp_file}" --threads #{opts[:thr]} \
|
173
|
+
--do_stdev
|
174
|
+
CMD
|
175
|
+
)
|
176
|
+
raise "Cannot find FastAAI output directory: #{f2}" unless Dir.exist?(f2)
|
168
177
|
|
169
178
|
# Save values in the databases
|
170
179
|
haai_data = {}
|
@@ -217,6 +226,6 @@ module MiGA::DistanceRunner::Commands
|
|
217
226
|
|
218
227
|
def run_cmd(cmd)
|
219
228
|
puts "CMD: #{cmd}"
|
220
|
-
`#{cmd}`
|
229
|
+
puts `#{cmd} 2>&1`
|
221
230
|
end
|
222
231
|
end
|
data/utils/subclade/pipeline.rb
CHANGED
@@ -7,9 +7,12 @@ module MiGA::SubcladeRunner::Pipeline
|
|
7
7
|
aai90: [:aai_distances, opts[:gsp_aai], :aai]
|
8
8
|
}
|
9
9
|
tasks.each do |k, par|
|
10
|
+
# Run only the requested metric
|
11
|
+
next unless par[2].to_s == opts[:gsp_metric]
|
12
|
+
|
10
13
|
# Final output
|
11
14
|
ogs_file = "miga-project.#{k}-clades"
|
12
|
-
next if File.size?
|
15
|
+
next if File.size?(ogs_file)
|
13
16
|
|
14
17
|
# Build ABC files
|
15
18
|
abc_path = tmp_file("#{k}.abc")
|
@@ -20,7 +23,7 @@ module MiGA::SubcladeRunner::Pipeline
|
|
20
23
|
next if ln =~ /^a\tb\tvalue\t/
|
21
24
|
|
22
25
|
r = ln.chomp.split("\t")
|
23
|
-
ofh.puts
|
26
|
+
ofh.puts("G>#{r[0]}\tG>#{r[1]}\t#{r[2]}") if r[2].to_f >= par[1]
|
24
27
|
end
|
25
28
|
end
|
26
29
|
ofh.close
|
@@ -29,16 +32,14 @@ module MiGA::SubcladeRunner::Pipeline
|
|
29
32
|
`ogs.mcl.rb -o '#{ogs_file}.tmp' --abc '#{abc_path}' -t '#{opts[:thr]}'`
|
30
33
|
File.open(ogs_file, 'w') do |fh|
|
31
34
|
File.foreach("#{ogs_file}.tmp").with_index do |ln, lno|
|
32
|
-
fh.puts
|
35
|
+
fh.puts(ln) if lno > 0
|
33
36
|
end
|
34
37
|
end
|
35
38
|
File.unlink "#{ogs_file}.tmp"
|
36
39
|
else
|
37
|
-
FileUtils.touch
|
38
|
-
end
|
39
|
-
if par[2].to_s == opts[:gsp_metric]
|
40
|
-
FileUtils.cp(ogs_file, "miga-project.gsp-clades")
|
40
|
+
FileUtils.touch(ogs_file)
|
41
41
|
end
|
42
|
+
FileUtils.cp(ogs_file, 'miga-project.gsp-clades')
|
42
43
|
end
|
43
44
|
|
44
45
|
# Find genomospecies medoids
|
@@ -67,7 +68,7 @@ module MiGA::SubcladeRunner::Pipeline
|
|
67
68
|
metric_res = project.result(step) or raise "Incomplete step #{step}"
|
68
69
|
matrix = metric_res.file_path(:matrix)
|
69
70
|
`Rscript '#{src}' '#{matrix}' miga-project '#{opts[:thr]}' \
|
70
|
-
miga-project.
|
71
|
+
miga-project.gsp-medoids '#{opts[:run_clades] ? 'cluster' : 'empty'}'`
|
71
72
|
if File.exist? 'miga-project.nwk'
|
72
73
|
File.rename('miga-project.nwk', "miga-project.#{metric}.nwk")
|
73
74
|
end
|
data/utils/subclades.R
CHANGED
@@ -26,14 +26,18 @@ subclades <- function(ani_file, out_base, thr = 1, ani.d = dist(0), sel = NA) {
|
|
26
26
|
# Normalize input matrix
|
27
27
|
dist_rds <- paste(out_base, "dist.rds", sep = ".")
|
28
28
|
if (!missing(ani_file)) {
|
29
|
-
if(length(ani.d) == 0
|
30
|
-
|
31
|
-
|
32
|
-
if (is.null(ani.d)) {
|
33
|
-
generate_empty_files(out_base)
|
34
|
-
return(NULL)
|
29
|
+
if (length(ani.d) == 0) {
|
30
|
+
if (file.exists(dist_rds)) {
|
31
|
+
ani.d <- readRDS(dist_rds)
|
35
32
|
} else {
|
36
|
-
|
33
|
+
# Read from ani_file
|
34
|
+
ani.d <- ani_distance(ani_file, sel)
|
35
|
+
if (is.null(ani.d)) {
|
36
|
+
generate_empty_files(out_base)
|
37
|
+
return(NULL)
|
38
|
+
} else {
|
39
|
+
saveRDS(ani.d, dist_rds)
|
40
|
+
}
|
37
41
|
}
|
38
42
|
}
|
39
43
|
}
|
@@ -104,17 +108,6 @@ subclade_clustering <- function (out_base, thr, ani.d, dist_rds) {
|
|
104
108
|
}
|
105
109
|
if (length(labels(ani.d)) <= 8L) return(list())
|
106
110
|
|
107
|
-
# Build tree
|
108
|
-
say("Tree")
|
109
|
-
ani.ph <- bionj(ani.d)
|
110
|
-
say("- Write")
|
111
|
-
express.ori <- options("expressions")$expressions
|
112
|
-
if(express.ori < ani.ph$Nnode * 4){
|
113
|
-
options(expressions=min(c(5e7, ani.ph$Nnode * 4)))
|
114
|
-
}
|
115
|
-
write.tree(ani.ph, paste(out_base, ".nwk", sep = ""))
|
116
|
-
options(expressions=express.ori)
|
117
|
-
|
118
111
|
# Silhouette
|
119
112
|
say("Silhouette")
|
120
113
|
nn <- length(labels(ani.d))
|
@@ -146,6 +139,17 @@ subclade_clustering <- function (out_base, thr, ani.d, dist_rds) {
|
|
146
139
|
ani.types <- ani.cl$clustering
|
147
140
|
ani.medoids <- ani.cl$medoids
|
148
141
|
|
142
|
+
# Build tree
|
143
|
+
say("Tree")
|
144
|
+
ani.ph <- bionj(ani.d)
|
145
|
+
say("- Write")
|
146
|
+
express.ori <- options("expressions")$expressions
|
147
|
+
if(express.ori < ani.ph$Nnode * 4){
|
148
|
+
options(expressions=min(c(5e7, ani.ph$Nnode * 4)))
|
149
|
+
}
|
150
|
+
write.tree(ani.ph, paste(out_base, ".nwk", sep = ""))
|
151
|
+
options(expressions=express.ori)
|
152
|
+
|
149
153
|
# Generate graphic report
|
150
154
|
say("Graphic report")
|
151
155
|
pdf(paste(out_base, ".pdf", sep = ""), 7, 12)
|
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: 1.1.3.
|
4
|
+
version: 1.1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis M. Rodriguez-R
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daemons
|