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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d9d8a12b9eaa48b63df43b871f3cc7da598997f3d208cde9fcf31f2d605d66c
4
- data.tar.gz: 72d58adbbbea43886e1e60a608f3f7e0da542c26b3b29ecf202a3b34b9f8ac35
3
+ metadata.gz: 869314efef2d92764d569f6ba5bc7cf03182a8a4dddb27405349923ca1518100
4
+ data.tar.gz: 9bd3e4a7fb5d34c0d34b850a0f300b4f6ddbc4607d63fc92a5240c7674ce53b6
5
5
  SHA512:
6
- metadata.gz: cc2c81a38d915c7bb13d53853e0be3c822a0ba7703d2e97cf16615ac4d8f8b4fc3203bc83b76584b48ddd7f13787545d5327d9dd5cd846bbc1be1db868b120a4
7
- data.tar.gz: 8cf8bd65e94e6bb551143ebb4fbb4ca37a74e58f777011e3c2c5823f7c9b6a242de63ddda1c496d9c91df01f2471446989267828b69e0de7fd024d3e84d70afa
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
- next unless [1, 2].map { |i| p.dataset(r[i]).nil? }.any?
62
+ names = [r[0], r[1]]
63
+ next unless names.any? { |i| p.dataset(i).nil? }
63
64
 
64
- [1, 2].each do |i|
65
- if p.dataset(r[i]).nil? || !p.dataset(r[i]).active?
66
- notok[r[i]] = true
65
+ names.each do |i|
66
+ if p.dataset(i).nil? || !p.dataset(i).active?
67
+ notok[i] = true
67
68
  else
68
- fix[r[i]] = true
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, 1].freeze
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, 24)
23
+ VERSION_DATE = Date.new(2021, 11, 26)
24
24
 
25
25
  ##
26
26
  # References of MiGA
@@ -153,18 +153,27 @@ module MiGA::DistanceRunner::Commands
153
153
  return nil if donors.empty?
154
154
 
155
155
  # Build target database
156
- File.open(f0 = tmp_file, 'w') { |fh| donors.each { |i| fh.puts i } }
157
- run_cmd <<~CMD
158
- FastAAI merge_db --donor_file "#{f0}" \
159
- --recipient "#{f1 = tmp_file}" --threads #{opts[:thr]}
160
- CMD
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 <<~CMD
164
- FastAAI db_query --query "#{qry_idx}" --target "#{f1}" \
165
- --output "#{f2 = tmp_file}" --threads #{opts[:thr]} \
166
- --do_stdev
167
- CMD
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
@@ -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? ogs_file
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 "G>#{r[0]}\tG>#{r[1]}\t#{r[2]}" if r[2].to_f >= par[1]
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 ln if lno > 0
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 ogs_file
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.ani95-medoids '#{opts[:run_clades] ? 'cluster' : 'empty'}'`
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 && !file.exists(dist_rds)){
30
- # Read from ani_file
31
- ani.d <- ani_distance(ani_file, sel)
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
- saveRDS(ani.d, dist_rds)
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.1
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-24 00:00:00.000000000 Z
11
+ date: 2021-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons