miga-base 0.3.6.1 → 0.3.6.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/actions/init.rb +2 -2
- data/lib/miga/daemon.rb +20 -3
- data/lib/miga/version.rb +1 -1
- data/utils/distance/commands.rb +5 -4
- data/utils/distance/pipeline.rb +12 -9
- data/utils/find-medoid.R +6 -2
- data/utils/subclade/pipeline.rb +3 -5
- 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: 18d4ed2342a1b2d1e1b35b1bbb060a79bd573af5cdc9c286fe9dc9d7b7b9c6aa
|
4
|
+
data.tar.gz: 723c593505c7a54c26316862d0a5eef7072dbd2de174154517f7cb14a8bd3bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d955e1011f1f02730adb0fdf689740cb494b15552fccc07ce86c4427170f42f599a87fc527512809af99d0d7365fb7a5af55c101e87e7b16df013e3e648781e7
|
7
|
+
data.tar.gz: 63fa2a296df01ba78e281be1bf4fed252bdad7959d355d5b112228b25f71a79e1a6af1094a623967eaaf69431fb440529b481a9b5b9a06ff90c6660a22d2c73f
|
data/actions/init.rb
CHANGED
@@ -87,7 +87,7 @@ if File.exist? o[:config]
|
|
87
87
|
o[:config] = File.expand_path o[:config]
|
88
88
|
$stderr.puts "Found bash configuration script: #{o[:config]}."
|
89
89
|
rc_fh.puts "MIGA_STARTUP='#{o[:config]}'"
|
90
|
-
rc_fh.puts "
|
90
|
+
rc_fh.puts ". \"$MIGA_STARTUP\""
|
91
91
|
end
|
92
92
|
$stderr.puts ""
|
93
93
|
|
@@ -108,7 +108,7 @@ File.open(File.expand_path("utils/requirements.txt", miga), "r") do |fh|
|
|
108
108
|
path = nil
|
109
109
|
loop do
|
110
110
|
if File.exist? o[:config]
|
111
|
-
d_path = File.dirname(
|
111
|
+
d_path = File.dirname(`. "#{o[:config]}" && which "#{r[1]}"`)
|
112
112
|
else
|
113
113
|
d_path = File.dirname(`which "#{r[1]}"`)
|
114
114
|
end
|
data/lib/miga/daemon.rb
CHANGED
@@ -86,10 +86,26 @@ class MiGA::Daemon < MiGA::MiGA
|
|
86
86
|
def report_status
|
87
87
|
f = File.open(File.expand_path('daemon/status.json', project.path), 'w')
|
88
88
|
f.print JSON.pretty_generate(
|
89
|
-
jobs_running
|
89
|
+
jobs_running: @jobs_running, jobs_to_run: @jobs_to_run)
|
90
90
|
f.close
|
91
91
|
end
|
92
92
|
|
93
|
+
##
|
94
|
+
# Load the status of a previous instance.
|
95
|
+
def load_status
|
96
|
+
f_path = File.expand_path('daemon/status.json', project.path)
|
97
|
+
return unless File.size? f_path
|
98
|
+
status = JSON.parse(File.read(f_path), symbolize_names: true)
|
99
|
+
status.keys.each do |i|
|
100
|
+
status[i].map! do |j|
|
101
|
+
j.tap { |k| k[:ds] = project.dataset(k[:ds_name]) unless k[:ds].nil? }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
@jobs_to_run = status[:jobs_to_run]
|
105
|
+
@jobs_running = status[:jobs_running]
|
106
|
+
purge!
|
107
|
+
end
|
108
|
+
|
93
109
|
##
|
94
110
|
# Traverse datasets
|
95
111
|
def check_datasets
|
@@ -192,15 +208,16 @@ class MiGA::Daemon < MiGA::MiGA
|
|
192
208
|
##
|
193
209
|
# Run one loop step. Returns a Boolean indicating if the loop should continue.
|
194
210
|
def in_loop
|
211
|
+
declare_alive
|
212
|
+
project.load
|
195
213
|
if loop_i == -1
|
196
214
|
say '-----------------------------------'
|
197
215
|
say 'MiGA:%s launched.' % project.name
|
198
216
|
say '-----------------------------------'
|
217
|
+
load_status
|
199
218
|
@loop_i = 0
|
200
219
|
end
|
201
220
|
@loop_i += 1
|
202
|
-
declare_alive
|
203
|
-
project.load
|
204
221
|
check_datasets
|
205
222
|
check_project
|
206
223
|
flush!
|
data/lib/miga/version.rb
CHANGED
@@ -10,7 +10,7 @@ module MiGA
|
|
10
10
|
# - Float representing the major.minor version.
|
11
11
|
# - Integer representing gem releases of the current version.
|
12
12
|
# - Integer representing minor changes that require new version number.
|
13
|
-
VERSION = [0.3, 6,
|
13
|
+
VERSION = [0.3, 6, 2]
|
14
14
|
|
15
15
|
##
|
16
16
|
# Nickname for the current major.minor version.
|
data/utils/distance/commands.rb
CHANGED
@@ -14,17 +14,17 @@ module MiGA::DistanceRunner::Commands
|
|
14
14
|
end
|
15
15
|
# Full AAI
|
16
16
|
aai_cmd(
|
17
|
-
tmp_file(
|
17
|
+
tmp_file('proteins.fa'), target.result(:cds).file_path(:proteins),
|
18
18
|
dataset.name, target.name, tmp_dbs[:aai]).tap{ checkpoint :aai }
|
19
19
|
end
|
20
20
|
|
21
21
|
##
|
22
22
|
# Estimates AAI against +target+ using hAAI
|
23
23
|
def haai(target)
|
24
|
-
haai = aai_cmd(tmp_file(
|
24
|
+
haai = aai_cmd(tmp_file('ess_genes.fa'),
|
25
25
|
target.result(:essential_genes).file_path(:ess_genes),
|
26
26
|
dataset.name, target.name, tmp_dbs[:haai],
|
27
|
-
aai_save_rbm:
|
27
|
+
aai_save_rbm: 'no-save-rbm', aai_p: opts[:haai_p])
|
28
28
|
checkpoint :haai
|
29
29
|
return nil if haai.nil? or haai.zero? or haai > 90.0
|
30
30
|
aai = 100.0 - Math.exp(2.435076 + 0.4275193*Math.log(100.0-haai))
|
@@ -32,6 +32,7 @@ module MiGA::DistanceRunner::Commands
|
|
32
32
|
conn.execute "insert into aai values(?, ?, ?, 0, 0, 0)",
|
33
33
|
[dataset.name, target.name, aai]
|
34
34
|
end
|
35
|
+
checkpoint :aai
|
35
36
|
aai
|
36
37
|
end
|
37
38
|
|
@@ -39,7 +40,7 @@ module MiGA::DistanceRunner::Commands
|
|
39
40
|
# Calculates ANI against +target+
|
40
41
|
def ani(target)
|
41
42
|
# Check if the request makes sense
|
42
|
-
t = tmp_file(
|
43
|
+
t = tmp_file('largecontigs.fa')
|
43
44
|
r = target.result(:assembly)
|
44
45
|
return nil if r.nil? or !File.size?(t)
|
45
46
|
# Check if it's been calculated
|
data/utils/distance/pipeline.rb
CHANGED
@@ -64,9 +64,9 @@ module MiGA::DistanceRunner::Pipeline
|
|
64
64
|
# Get taxonomy of closest relative
|
65
65
|
from_ref_project = (project != ref_project)
|
66
66
|
res_dir = from_ref_project ?
|
67
|
-
|
67
|
+
File.expand_path('data/09.distances/05.taxonomy', project.path) : home
|
68
68
|
Dir.mkdir res_dir unless Dir.exist? res_dir
|
69
|
-
File.open(File.expand_path("#{dataset.name}.done", res_dir),
|
69
|
+
File.open(File.expand_path("#{dataset.name}.done", res_dir), 'w') do |fh|
|
70
70
|
fh.puts Time.now.to_s
|
71
71
|
end
|
72
72
|
dataset.add_result(from_ref_project ? :taxonomy : :distances, true)
|
@@ -75,25 +75,28 @@ module MiGA::DistanceRunner::Pipeline
|
|
75
75
|
tax = ref_project.dataset(cr[0][0]).metadata[:tax] || {}
|
76
76
|
# Run the test for each rank
|
77
77
|
r = MiGA::TaxDist.aai_pvalues(cr[0][1], :intax).map do |k,v|
|
78
|
-
sig =
|
79
|
-
[0.5,0.1,0.05,0.01].each{ |i| sig <<
|
80
|
-
[MiGA::Taxonomy.LONG_RANKS[k], (tax[k] ||
|
78
|
+
sig = ''
|
79
|
+
[0.5,0.1,0.05,0.01].each{ |i| sig << '*' if v<i }
|
80
|
+
[MiGA::Taxonomy.LONG_RANKS[k], (tax[k] || '?'), v, sig]
|
81
81
|
end
|
82
82
|
# Save test
|
83
83
|
File.open(File.expand_path("#{dataset.name}.intax.txt", home), "w") do |fh|
|
84
84
|
fh.puts "Closest relative: #{cr[0][0]} with AAI: #{cr[0][1]}."
|
85
|
-
fh.puts
|
85
|
+
fh.puts ''
|
86
86
|
fh.puts MiGA::MiGA.tabulate(%w[Rank Taxonomy P-value Signif.], r)
|
87
|
-
fh.puts
|
88
|
-
fh.puts
|
87
|
+
fh.puts ''
|
88
|
+
fh.puts 'Significance at p-value below: *0.5, **0.1, ***0.05, ****0.01.'
|
89
89
|
end
|
90
90
|
return r
|
91
91
|
end
|
92
92
|
|
93
93
|
# Transfer the taxonomy to the current dataset
|
94
94
|
def transfer_taxonomy(tax)
|
95
|
+
return if tax.nil?
|
95
96
|
pval = (project.metadata[:tax_pvalue] || 0.05).to_f
|
96
|
-
tax_a = tax.
|
97
|
+
tax_a = tax.
|
98
|
+
select { |i| i[1] != '?' && i[2] <= pval }.
|
99
|
+
map { |i| i[0,2].join(':') }
|
97
100
|
dataset.metadata[:tax] = MiGA::Taxonomy.new(tax_a)
|
98
101
|
dataset.save
|
99
102
|
end
|
data/utils/find-medoid.R
CHANGED
@@ -7,8 +7,12 @@
|
|
7
7
|
#= Load stuff
|
8
8
|
argv <- commandArgs(trailingOnly=T)
|
9
9
|
suppressPackageStartupMessages(library(ape))
|
10
|
+
suppressPackageStartupMessages(library(enveomics.R))
|
10
11
|
|
11
|
-
find_medoids <- function(
|
12
|
+
find_medoids <- function(ani.df, out, clades) {
|
13
|
+
if(nrow(ani.df)==0) return(NULL)
|
14
|
+
ani.df$d <- 1 - (ani.df$value/100)
|
15
|
+
dist <- enve.df2dist(ani.df, 'a', 'b', 'd', default.d = max(ani.df$d)*1.2)
|
12
16
|
dist <- as.matrix(dist)
|
13
17
|
cl <- read.table(clades, header = FALSE, sep = '\t', as.is = TRUE)[,1]
|
14
18
|
medoids <- c()
|
@@ -27,5 +31,5 @@ find_medoids <- function(dist, out, clades) {
|
|
27
31
|
|
28
32
|
#= Main
|
29
33
|
load(argv[1])
|
30
|
-
find_medoids(
|
34
|
+
find_medoids(ani.df = ani, out = argv[2], clades = argv[3])
|
31
35
|
|
data/utils/subclade/pipeline.rb
CHANGED
@@ -33,11 +33,9 @@ module MiGA::SubcladeRunner::Pipeline
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Find species medoids
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
miga-project.ani95-medoids miga-project.ani95-clades`
|
40
|
-
end
|
36
|
+
src = File.expand_path('utils/find-medoid.R', MiGA::MiGA.root_path)
|
37
|
+
`Rscript '#{src}' ../../09.distances/03.ani/miga-project.Rdata \
|
38
|
+
miga-project.ani95-medoids miga-project.ani95-clades`
|
41
39
|
|
42
40
|
# Propose clades
|
43
41
|
ofh = File.open('miga-project.proposed-clades', 'w')
|
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.3.6.
|
4
|
+
version: 0.3.6.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: 2018-
|
11
|
+
date: 2018-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daemons
|