miga-base 1.1.3.1 → 1.1.3.5

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: 7d5222e454ab660cb92d71aceb0e470784d82cb6e70f925a5f10802dac1566cd
4
+ data.tar.gz: 9a1e35792498d1a0bf47e9adcf3a2b79ab1a603da4791285e2374286f409e419
5
5
  SHA512:
6
- metadata.gz: cc2c81a38d915c7bb13d53853e0be3c822a0ba7703d2e97cf16615ac4d8f8b4fc3203bc83b76584b48ddd7f13787545d5327d9dd5cd846bbc1be1db868b120a4
7
- data.tar.gz: 8cf8bd65e94e6bb551143ebb4fbb4ca37a74e58f777011e3c2c5823f7c9b6a242de63ddda1c496d9c91df01f2471446989267828b69e0de7fd024d3e84d70afa
6
+ metadata.gz: b6021862c6f14267e9d92d1167daabf60bc59e352c21cdb44d1adf28db0d9df1a86e854793ba4cda58b23ac00bf5d23ad607493672f8ed240a47d827ca5a8ded
7
+ data.tar.gz: 77c88d561c67f6a5e2012195044d2966f228c4d57b31377a199dcafe687b7e7f323a060403772f3e12b9f7994a849f2772ef6f03ac9a167e60615dfe5568b43b
@@ -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/project.rb CHANGED
@@ -121,4 +121,11 @@ class MiGA::Project < MiGA::MiGA
121
121
  def active?
122
122
  true
123
123
  end
124
+
125
+ ##
126
+ # Load or recover the project's daemon
127
+ def daemon
128
+ require 'miga/daemon'
129
+ @daemon ||= MiGA::Daemon.new(self)
130
+ end
124
131
  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, 5].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, 30)
24
24
 
25
25
  ##
26
26
  # References of MiGA
@@ -2954,10 +2954,12 @@ def merge_db(recipient, donors, donor_file, verbose, threads):
2954
2954
  pass
2955
2955
  except:
2956
2956
  #Error
2957
- shutil.rmtree(temp_dir)
2957
+ if os.path.exists(temp_dir):
2958
+ shutil.rmtree(temp_dir)
2958
2959
  finally:
2959
2960
  #Success
2960
- shutil.rmtree(temp_dir)
2961
+ if os.path.exists(temp_dir):
2962
+ shutil.rmtree(temp_dir)
2961
2963
 
2962
2964
  print("\nDatabases merged!")
2963
2965
 
@@ -153,18 +153,29 @@ 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 = tmp_file
157
+ if donors.size == 1
158
+ File.copy(donors.first, f1)
159
+ else
160
+ File.open(f0 = tmp_file, 'w') { |fh| donors.each { |i| fh.puts i } }
161
+ run_cmd(
162
+ <<~CMD
163
+ FastAAI merge_db --threads #{opts[:thr]} \
164
+ --donor_file "#{f0}" --recipient "#{f1}"
165
+ CMD
166
+ )
167
+ raise "Cannot merge databases into: #{f1}" unless File.size?(f1)
168
+ end
161
169
 
162
170
  # 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
171
+ run_cmd(
172
+ <<~CMD
173
+ FastAAI db_query --query "#{qry_idx}" --target "#{f1}" \
174
+ --output "#{f2 = tmp_file}" --threads #{opts[:thr]} \
175
+ --do_stdev
176
+ CMD
177
+ )
178
+ raise "Cannot find FastAAI output directory: #{f2}" unless Dir.exist?(f2)
168
179
 
169
180
  # Save values in the databases
170
181
  haai_data = {}
@@ -217,6 +228,6 @@ module MiGA::DistanceRunner::Commands
217
228
 
218
229
  def run_cmd(cmd)
219
230
  puts "CMD: #{cmd}"
220
- `#{cmd}`
231
+ puts `#{cmd} 2>&1`
221
232
  end
222
233
  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.5
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-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons