miga-base 0.2.3.1 → 0.2.4.0
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/create_dataset.rb +2 -1
- data/actions/create_project.rb +2 -2
- data/actions/daemon.rb +5 -1
- data/bin/miga +11 -5
- data/lib/miga/daemon.rb +16 -4
- data/lib/miga/dataset.rb +10 -3
- data/lib/miga/project.rb +3 -1
- data/lib/miga/version.rb +2 -2
- data/scripts/_distances_functions.bash +1 -1
- data/scripts/init.bash +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9353efac39e230da0d999efff1f3839dd5d0c1e
|
4
|
+
data.tar.gz: 2860e3b8c6ee0bb18bfb5f8ff753754762253eb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66086e7e08f1ca5cb27986ebd206d65c71562fe0b9c026673c08c20f543772b015dfe23fd6c1792e9747d1334d331b2feade1ea9225e579c9b4e691575bb16b2
|
7
|
+
data.tar.gz: b7801121cb4f332eebe6e88c907c9e68c0f6e3851cd445eb2467cdf84a9091243a0303fecad6505ae6efba7efa5287f4f5c3efc6b9bd44d54ce4af653e8ddc11
|
data/actions/create_dataset.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
o = {q:true, ref:true, update:false}
|
7
7
|
OptionParser.new do |opt|
|
8
8
|
opt_banner(opt)
|
9
|
-
opt_object(opt, o, [:project, :dataset, :
|
9
|
+
opt_object(opt, o, [:project, :dataset, :dataset_type_req])
|
10
10
|
opt.on("-q", "--query",
|
11
11
|
"If set, the dataset is registered as a query, not a reference dataset."
|
12
12
|
){ |v| o[:ref]=!v }
|
@@ -43,6 +43,7 @@ end.parse!
|
|
43
43
|
|
44
44
|
##=> Main <=
|
45
45
|
opt_require(o)
|
46
|
+
opt_require(o, type:"-t")
|
46
47
|
|
47
48
|
$stderr.puts "Loading project." unless o[:q]
|
48
49
|
p = MiGA::Project.load(o[:project])
|
data/actions/create_project.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
o = {q:true, update:false}
|
7
7
|
OptionParser.new do |opt|
|
8
8
|
opt_banner(opt)
|
9
|
-
opt_object(opt, o, [:project, :
|
9
|
+
opt_object(opt, o, [:project, :project_type_req])
|
10
10
|
opt.on("-n", "--name STRING",
|
11
11
|
"Name of the project."){ |v| o[:name]=v }
|
12
12
|
opt.on("-d", "--description STRING",
|
@@ -20,7 +20,7 @@ OptionParser.new do |opt|
|
|
20
20
|
end.parse!
|
21
21
|
|
22
22
|
##=> Main <=
|
23
|
-
opt_require(o, project:"-P")
|
23
|
+
opt_require(o, project:"-P", type:"-t")
|
24
24
|
|
25
25
|
unless File.exist? "#{ENV["HOME"]}/.miga_rc" and
|
26
26
|
File.exist? "#{ENV["HOME"]}/.miga_daemon.json"
|
data/actions/daemon.rb
CHANGED
@@ -22,6 +22,10 @@ OptionParser.new do |opt|
|
|
22
22
|
opt.separator ""
|
23
23
|
opt.separator "MiGA options:"
|
24
24
|
opt_object(opt, o, [:project])
|
25
|
+
opt.on("--shutdown-when-done",
|
26
|
+
"If passed, the daemon will exit when all processing is done.",
|
27
|
+
"Otherwise (default), it will stay idle awaiting for new data."
|
28
|
+
){ |v| o[:shutdown_when_done] = v }
|
25
29
|
opt.on("--latency INT",
|
26
30
|
"Number of seconds the daemon will be sleeping."
|
27
31
|
){ |v| o[:latency]=v.to_i }
|
@@ -45,7 +49,7 @@ opt_require(o, project:"-P")
|
|
45
49
|
raise "Project doesn't exist, aborting." unless MiGA::Project.exist? o[:project]
|
46
50
|
p = MiGA::Project.new(o[:project])
|
47
51
|
d = MiGA::Daemon.new(p)
|
48
|
-
[:latency, :maxjobs, :ppn].each do |k|
|
52
|
+
[:latency, :maxjobs, :ppn, :shutdown_when_done].each do |k|
|
49
53
|
d.runopts(k, o[k]) unless o[k].nil?
|
50
54
|
end
|
51
55
|
d.daemon(task, o[:daemon_opts])
|
data/bin/miga
CHANGED
@@ -53,18 +53,24 @@ end
|
|
53
53
|
def opt_object(opt, o, what=[:project, :dataset])
|
54
54
|
opt.on("-P", "--project PATH", "(Mandatory) Path to the project."
|
55
55
|
){ |v| o[:project]=v } if what.include? :project
|
56
|
-
opt.on("-D", "--dataset
|
57
|
-
)
|
58
|
-
|
56
|
+
opt.on("-D", "--dataset STRING",
|
57
|
+
(what.include?(:dataset) ? "(Mandatory) " : "") +
|
58
|
+
"Name of the dataset."){ |v| o[:dataset]=v } if what.include? :dataset or
|
59
|
+
what.include? :dataset_opt
|
60
|
+
opt.on("-D", "--dataset STRING", "Name of the dataset."
|
59
61
|
){ |v| o[:dataset]=v } if what.include? :dataset_opt
|
60
62
|
opt.on("-t", "--type STRING",
|
63
|
+
(what.include?(:dataset_type_req) ? "(Mandatory) " : "")+
|
61
64
|
"Type of dataset. Recognized types include:",
|
62
65
|
*MiGA::Dataset.KNOWN_TYPES.map{ |k,v| "~ #{k}: #{v[:description]}" }
|
63
|
-
){ |v| o[:type]=v.to_sym } if what.include? :dataset_type
|
66
|
+
){ |v| o[:type]=v.to_sym } if what.include? :dataset_type or
|
67
|
+
what.include? :dataset_type_req
|
64
68
|
opt.on("-t", "--type STRING",
|
69
|
+
(what.include?(:project_type_req) ? "(Mandatory) " : "") +
|
65
70
|
"Type of dataset. Recognized types include:",
|
66
71
|
*MiGA::Project.KNOWN_TYPES.map{ |k,v| "~ #{k}: #{v[:description]}"}
|
67
|
-
){ |v| o[:type]=v.to_sym } if what.include? :project_type
|
72
|
+
){ |v| o[:type]=v.to_sym } if what.include? :project_type or
|
73
|
+
what.include? :project_type_req
|
68
74
|
opt.on("-r", "--result STRING",
|
69
75
|
"(Mandatory) Name of the result to add.",
|
70
76
|
"Recognized names for dataset-specific results include:",
|
data/lib/miga/daemon.rb
CHANGED
@@ -66,6 +66,7 @@ class MiGA::Daemon < MiGA::MiGA
|
|
66
66
|
v = v.to_i if [:latency, :maxjobs, :ppn].include? k
|
67
67
|
raise "Daemon's #{k} cannot be set to zero." if
|
68
68
|
!force and v.is_a? Integer and v==0
|
69
|
+
v = !!v if [:shutdown_when_done].include? k
|
69
70
|
@runopts[k] = v
|
70
71
|
end
|
71
72
|
@runopts[k]
|
@@ -83,6 +84,11 @@ class MiGA::Daemon < MiGA::MiGA
|
|
83
84
|
# Returns Integer indicating the number of CPUs per job.
|
84
85
|
def ppn() runopts(:ppn) ; end
|
85
86
|
|
87
|
+
##
|
88
|
+
# Returns Boolean indicating if the daemon should shutdown when processing is
|
89
|
+
# complete.
|
90
|
+
def shutdown_when_done?() !!runopts(:shutdown_when_done) ; end
|
91
|
+
|
86
92
|
##
|
87
93
|
# Initializes the daemon with +opts+.
|
88
94
|
def start(opts=[]) daemon("start", opts) ; end
|
@@ -106,7 +112,9 @@ class MiGA::Daemon < MiGA::MiGA
|
|
106
112
|
options = default_options
|
107
113
|
opts.unshift(task)
|
108
114
|
options[:ARGV] = opts
|
109
|
-
Daemons.run_proc("MiGA:#{project.name}", options)
|
115
|
+
Daemons.run_proc("MiGA:#{project.name}", options) do
|
116
|
+
loop { break unless in_loop }
|
117
|
+
end
|
110
118
|
end
|
111
119
|
|
112
120
|
##
|
@@ -205,12 +213,12 @@ class MiGA::Daemon < MiGA::MiGA
|
|
205
213
|
# Launch job
|
206
214
|
if runopts(:type) == "bash"
|
207
215
|
job[:pid] = spawn job[:cmd]
|
208
|
-
Process.detach job[:pid] unless
|
216
|
+
Process.detach job[:pid] unless [nil, "", 0].include? job[:pid]
|
209
217
|
else
|
210
218
|
job[:pid] = `#{job[:cmd]}`.chomp
|
211
219
|
end
|
212
220
|
# Check if registered
|
213
|
-
if
|
221
|
+
if [nil, "", 0].include? job[:pid].nil?
|
214
222
|
job[:pid] = nil
|
215
223
|
@jobs_to_run << job
|
216
224
|
say "Unsuccessful #{job[:task_name]}, rescheduling."
|
@@ -230,7 +238,7 @@ class MiGA::Daemon < MiGA::MiGA
|
|
230
238
|
end
|
231
239
|
|
232
240
|
##
|
233
|
-
# Run one loop step.
|
241
|
+
# Run one loop step. Returns a Boolean indicating if the loop should continue.
|
234
242
|
def in_loop
|
235
243
|
if loop_i == -1
|
236
244
|
say "-----------------------------------"
|
@@ -250,6 +258,10 @@ class MiGA::Daemon < MiGA::MiGA
|
|
250
258
|
purge!
|
251
259
|
end
|
252
260
|
sleep(latency)
|
261
|
+
if shutdown_when_done? and jobs_running.size+jobs_to_run.size == 0
|
262
|
+
return false
|
263
|
+
end
|
264
|
+
true
|
253
265
|
end
|
254
266
|
|
255
267
|
##
|
data/lib/miga/dataset.rb
CHANGED
@@ -43,9 +43,10 @@ class MiGA::Dataset < MiGA::MiGA
|
|
43
43
|
metagenome: {description: "A metagenome (excluding viromes).",
|
44
44
|
multi: true},
|
45
45
|
virome: {description: "A viral metagenome.", multi: true},
|
46
|
-
scgenome: {description: "A
|
47
|
-
|
48
|
-
|
46
|
+
scgenome: {description: "A Single-cell Genome Amplification (SGA).",
|
47
|
+
multi: false},
|
48
|
+
popgenome: {description: "A population genome (including " +
|
49
|
+
"metagenomic bins).", :multi=>false}
|
49
50
|
}
|
50
51
|
|
51
52
|
##
|
@@ -108,6 +109,8 @@ class MiGA::Dataset < MiGA::MiGA
|
|
108
109
|
metadata[:ref] = is_ref
|
109
110
|
@metadata = MiGA::Metadata.new(
|
110
111
|
File.expand_path("metadata/#{name}.json", project.path), metadata )
|
112
|
+
raise "Unrecognized dataset type: #{type}." if
|
113
|
+
!type.nil? and @@KNOWN_TYPES[type].nil?
|
111
114
|
end
|
112
115
|
|
113
116
|
##
|
@@ -118,6 +121,10 @@ class MiGA::Dataset < MiGA::MiGA
|
|
118
121
|
self.metadata.save
|
119
122
|
end
|
120
123
|
|
124
|
+
##
|
125
|
+
# Get the type of dataset as Symbol.
|
126
|
+
def type ; metadata[:type] ; end
|
127
|
+
|
121
128
|
##
|
122
129
|
# Delete the dataset with all it's contents (including results) and returns
|
123
130
|
# nil.
|
data/lib/miga/project.rb
CHANGED
@@ -65,7 +65,7 @@ class MiGA::Project < MiGA::MiGA
|
|
65
65
|
single: true, multi: true},
|
66
66
|
genomes: {description: "Collection of genomes.",
|
67
67
|
single: true, multi: false},
|
68
|
-
clade: {description: "Collection of closely-related genomes (ANI
|
68
|
+
clade: {description: "Collection of closely-related genomes (ANI >= 90%).",
|
69
69
|
single: true, multi: false},
|
70
70
|
metagenomes: {description: "Collection of metagenomes and/or viromes.",
|
71
71
|
single: false, multi: true}
|
@@ -115,6 +115,8 @@ class MiGA::Project < MiGA::MiGA
|
|
115
115
|
self.create if not update and not Project.exist? self.path
|
116
116
|
self.load if self.metadata.nil?
|
117
117
|
self.load_plugins
|
118
|
+
self.metadata[:type] = :mixed if type.nil?
|
119
|
+
raise "Unrecognized project type: #{type}." if @@KNOWN_TYPES[type].nil?
|
118
120
|
end
|
119
121
|
|
120
122
|
##
|
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.2,
|
13
|
+
VERSION = [0.2, 4, 0]
|
14
14
|
|
15
15
|
##
|
16
16
|
# Nickname for the current major.minor version.
|
@@ -18,7 +18,7 @@ module MiGA
|
|
18
18
|
|
19
19
|
##
|
20
20
|
# Date of the current gem release.
|
21
|
-
VERSION_DATE = Date.new(2017, 3,
|
21
|
+
VERSION_DATE = Date.new(2017, 3, 23)
|
22
22
|
|
23
23
|
##
|
24
24
|
# Reference of MiGA.
|
@@ -56,7 +56,7 @@ fx_exists miga-haai || function miga-haai {
|
|
56
56
|
local HAAI=$(MIGA_AAI_SAVE_RBM="no-save-rbm" miga-aai "$F1" "$F2" "$TH" "$DB")
|
57
57
|
if [[ "$HAAI" != "" && $(perl -e "print 1 if '$HAAI' <= 90") == "1" ]] ; then
|
58
58
|
local AAI=$(perl -e "print (100-exp(2.435076 + 0.4275193*log(100-$HAAI)))")
|
59
|
-
[[ ! -s $AAI_DB ]] && make_empty_aai_db "$AAI_DB"
|
59
|
+
[[ ! -s $AAI_DB ]] && miga-make_empty_aai_db "$AAI_DB"
|
60
60
|
echo "insert into aai values('$N1','$N2','$AAI',0,0,0);" | sqlite3 "$AAI_DB"
|
61
61
|
echo "$AAI"
|
62
62
|
fi
|
data/scripts/init.bash
CHANGED
@@ -162,7 +162,7 @@ case "$dtype" in
|
|
162
162
|
dmaxjobs=$(ask_user "How many jobs can I launch at once?" "6")
|
163
163
|
dppn=$(ask_user "How many CPUs can I use per job?" "2")
|
164
164
|
echo "Setting up internal daemon defaults, if you don't understand this just leave default values:" >&2
|
165
|
-
dcmd=$(ask_user "How should I launch tasks? Use %1\$s for script path, %2\$s for variables, %3\$d for CPUs, %4\$s for log file, and %5\$s for task name." "%2\$s '%1\$s'
|
165
|
+
dcmd=$(ask_user "How should I launch tasks? Use %1\$s for script path, %2\$s for variables, %3\$d for CPUs, %4\$s for log file, and %5\$s for task name." "%2\$s '%1\$s' > '%4\$s' 2>&1")
|
166
166
|
dvar=$(ask_user "How should I pass variables? Use %1\$s for keys and %2\$s for values." "%1\$s=%2\$s")
|
167
167
|
dsep=$(ask_user "What should I use to separate variables?" " ")
|
168
168
|
dalive=$(ask_user "How can I know that a process is still alive? Use %1\$s for PID, output should be 1 for running and 0 for non-running." "ps -p '%1\$s'|tail -n+2|wc -l|awk '{print \$1}'")
|
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.2.
|
4
|
+
version: 0.2.4.0
|
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: 2017-03-
|
11
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -192,9 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
requirements: []
|
194
194
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.0.14
|
195
|
+
rubygems_version: 2.0.14
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: MiGA
|
199
199
|
test_files: []
|
200
|
-
has_rdoc: true
|