miga-base 0.3.2.3 → 0.3.3.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/about.rb +5 -3
- data/actions/ls.rb +6 -3
- data/actions/summary.rb +55 -0
- data/bin/miga +6 -0
- data/lib/miga/common/format.rb +5 -4
- data/lib/miga/version.rb +1 -1
- data/scripts/distances.bash +0 -1
- data/utils/distance/pipeline.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 518860e2b5fbd03ec6887055a40f1d3fe5761f2bbab7550ccf575fa6a2b7b5bf
|
4
|
+
data.tar.gz: 620c88f6eca40d4f054191a871b52d1ec35bd0caf7dc580a8e27f2fcec7fa19f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 957cf133b881d048a1804b276a331fa9f459275290b8108685e9338173f80300d145c01dc0e0c4ec6f1504248c26651799ebc4fb00bbee94ffc0be01247b051e
|
7
|
+
data.tar.gz: 338cf79cd3dd467b0997b51d6a4677b63eda00f55e957dd85b723b358eb9f207836b1e2df0d8258e2fef1db44081fd08289471b6e872a7f82e94712c844d8ec4
|
data/actions/about.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# @package MiGA
|
4
4
|
# @license Artistic-2.0
|
5
5
|
|
6
|
-
o = {q:true, info:false, processing:false}
|
6
|
+
o = {q:true, info:false, processing:false, tabular:false}
|
7
7
|
OptionParser.new do |opt|
|
8
8
|
opt_banner(opt)
|
9
9
|
opt_object(opt, o, [:project])
|
@@ -12,6 +12,8 @@ OptionParser.new do |opt|
|
|
12
12
|
opt.on("-m", "--metadata STRING",
|
13
13
|
"Print name and metadata field only."
|
14
14
|
){ |v| o[:datum]=v }
|
15
|
+
opt.on("--tab STRING",
|
16
|
+
"Returns a tab-delimited table."){ |v| o[:tabular] = v }
|
15
17
|
opt_common(opt, o)
|
16
18
|
end.parse!
|
17
19
|
|
@@ -30,12 +32,12 @@ elsif o[:processing]
|
|
30
32
|
keys = MiGA::Project.DISTANCE_TASKS + MiGA::Project.INCLADE_TASKS
|
31
33
|
puts MiGA::MiGA.tabulate([:task, :status], keys.map do |k|
|
32
34
|
[k, p.add_result(k, false).nil? ? "queued" : "done"]
|
33
|
-
end)
|
35
|
+
end, o[:tabular])
|
34
36
|
else
|
35
37
|
puts MiGA::MiGA.tabulate([:key, :value], p.metadata.data.keys.map do |k|
|
36
38
|
v = p.metadata[k]
|
37
39
|
[k, k==:datasets ? v.size : v]
|
38
|
-
end)
|
40
|
+
end, o[:tabular])
|
39
41
|
end
|
40
42
|
|
41
43
|
$stderr.puts "Done." unless o[:q]
|
data/actions/ls.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# @package MiGA
|
4
4
|
# @license Artistic-2.0
|
5
5
|
|
6
|
-
o = {q:true, info:false, processing:false, silent:false}
|
6
|
+
o = {q:true, info:false, processing:false, silent:false, tabular:false}
|
7
7
|
OptionParser.new do |opt|
|
8
8
|
opt_banner(opt)
|
9
9
|
opt_object(opt, o, [:project, :dataset_opt])
|
@@ -15,6 +15,8 @@ OptionParser.new do |opt|
|
|
15
15
|
opt.on("-m", "--metadata STRING",
|
16
16
|
"Print name and metadata field only. If set, ignores -i."
|
17
17
|
){ |v| o[:datum]=v }
|
18
|
+
opt.on("--tab STRING",
|
19
|
+
"Returns a tab-delimited table."){ |v| o[:tabular] = v }
|
18
20
|
opt.on("-s", "--silent",
|
19
21
|
"No output and exit with non-zero status if the dataset list is empty."
|
20
22
|
){ |v| o[:silent] = v }
|
@@ -43,11 +45,12 @@ exit(1) if o[:silent] and ds.empty?
|
|
43
45
|
if not o[:datum].nil?
|
44
46
|
ds.each{|d| puts "#{d.name}\t#{d.metadata[ o[:datum] ] || "?"}"}
|
45
47
|
elsif o[:info]
|
46
|
-
puts MiGA::MiGA.tabulate(
|
48
|
+
puts MiGA::MiGA.tabulate(
|
49
|
+
MiGA::Dataset.INFO_FIELDS, ds.map{ |d| d.info }, o[:tabular])
|
47
50
|
elsif o[:processing]
|
48
51
|
comp = ["-","done","queued"]
|
49
52
|
puts MiGA::MiGA.tabulate([:name] + MiGA::Dataset.PREPROCESSING_TASKS,
|
50
|
-
ds.map{ |d| [d.name] + d.profile_advance.map{ |i| comp[i] } })
|
53
|
+
ds.map{ |d| [d.name] + d.profile_advance.map{ |i| comp[i] } }, o[:tabular])
|
51
54
|
else
|
52
55
|
ds.each{|d| puts d.name}
|
53
56
|
end
|
data/actions/summary.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# @package MiGA
|
4
|
+
# @license Artistic-2.0
|
5
|
+
|
6
|
+
o = {q:true, units:false, tabular:false}
|
7
|
+
opts = OptionParser.new do |opt|
|
8
|
+
opt_banner(opt)
|
9
|
+
opt_object(opt, o, [:project, :dataset_opt, :result_dataset])
|
10
|
+
opt.on("--tab STRING",
|
11
|
+
"Returns a tab-delimited table."){ |v| o[:tabular] = v }
|
12
|
+
opt.on("--key STRING",
|
13
|
+
"Returns only the value of the requested key."){ |v| o[:key] = v }
|
14
|
+
opt.on("--with-units",
|
15
|
+
"Includes units in each cell."){ |v| o[:units] = v }
|
16
|
+
opt_common(opt, o)
|
17
|
+
end.parse!
|
18
|
+
|
19
|
+
##=> Main <=
|
20
|
+
opts.parse!
|
21
|
+
opt_require(o, project:"-P", name:"-r")
|
22
|
+
|
23
|
+
$stderr.puts "Loading project." unless o[:q]
|
24
|
+
p = MiGA::Project.load(o[:project])
|
25
|
+
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
26
|
+
|
27
|
+
$stderr.puts "Listing datasets." unless o[:q]
|
28
|
+
if o[:dataset].nil?
|
29
|
+
ds = p.datasets
|
30
|
+
elsif MiGA::Dataset.exist? p, o[:dataset]
|
31
|
+
ds = [p.dataset(o[:dataset])]
|
32
|
+
else
|
33
|
+
ds = []
|
34
|
+
end
|
35
|
+
ds = filter_datasets!(ds, o)
|
36
|
+
|
37
|
+
$stderr.puts "Loading results." unless o[:q]
|
38
|
+
stats = ds.map do |d|
|
39
|
+
r = d.add_result(o[:name].to_sym, false)
|
40
|
+
s = r.nil? ? {} : r[:stats]
|
41
|
+
s.tap{ |i| i[:dataset] = d.name }
|
42
|
+
end
|
43
|
+
keys = o[:key].nil? ? stats.map(&:keys).flatten.uniq :
|
44
|
+
[:dataset, o[:key].downcase.miga_name.to_sym]
|
45
|
+
keys.delete :dataset
|
46
|
+
keys.unshift :dataset
|
47
|
+
|
48
|
+
table = o[:units] ?
|
49
|
+
stats.map{ |s| keys.map{ |k|
|
50
|
+
s[k].is_a?(Array) ? s[k].map(&:to_s).join('') : s[k] } } :
|
51
|
+
stats.map{ |s| keys.map{ |k| s[k].is_a?(Array) ? s[k].first : s[k] } }
|
52
|
+
puts MiGA::MiGA.tabulate(keys, table, o[:tabular])
|
53
|
+
|
54
|
+
$stderr.puts "Done." unless o[:q]
|
55
|
+
|
data/bin/miga
CHANGED
@@ -29,6 +29,7 @@ $task_desc = {
|
|
29
29
|
stats: "Extracts statistics for the given result.",
|
30
30
|
files: "Lists all registered files from the results of a dataset or project.",
|
31
31
|
run: "Executes locally one step analysis producing the given result.",
|
32
|
+
summary: "Generates a summary table for the statistics of all datasets.",
|
32
33
|
# System
|
33
34
|
init: "Initialize MiGA to process new projects.",
|
34
35
|
daemon: "Controls the daemon of a MiGA project.",
|
@@ -56,6 +57,7 @@ $task_alias = {
|
|
56
57
|
result_stats: :stats,
|
57
58
|
list_files: :files,
|
58
59
|
run_local: :run,
|
60
|
+
sum_stats: :summary,
|
59
61
|
# System
|
60
62
|
c: :console,
|
61
63
|
# Taxonomy
|
@@ -114,6 +116,10 @@ def opt_object(opt, o, what=[:project, :dataset])
|
|
114
116
|
"Recognized names for project-wide results include:",
|
115
117
|
*MiGA::Project.RESULT_DIRS.keys.map{|n| " ~ #{n}"}
|
116
118
|
){ |v| o[:name]=v.downcase.to_sym } if what.include? :result
|
119
|
+
opt.on("-r", "--result STRING",
|
120
|
+
"(Mandatory) Name of the result to add. One of:",
|
121
|
+
*MiGA::Dataset.RESULT_DIRS.keys.map{|n| " ~ #{n}"}
|
122
|
+
){ |v| o[:name]=v.downcase.to_sym } if what.include? :result_dataset
|
117
123
|
end
|
118
124
|
|
119
125
|
# OptParse flags common to all actions.
|
data/lib/miga/common/format.rb
CHANGED
@@ -6,15 +6,16 @@ module MiGA::Common::Format
|
|
6
6
|
##
|
7
7
|
# Tabulates an +values+, and Array of Arrays, all with the same number of
|
8
8
|
# entries as +header+. Returns an Array of String, one per line.
|
9
|
-
def tabulate(header, values)
|
9
|
+
def tabulate(header, values, tabular=false)
|
10
10
|
fields = [header.map(&:to_s)]
|
11
|
-
fields << fields.first.map { |h| h.gsub(/\S/, '-') }
|
11
|
+
fields << fields.first.map { |h| h.gsub(/\S/, '-') } unless tabular
|
12
12
|
fields += values.map { |r| r.map { |cell| cell.nil? ? '?' : cell.to_s } }
|
13
|
-
clen =
|
13
|
+
clen = tabular ? Array.new(header.size, 0) :
|
14
|
+
fields.map { |r| r.map(&:length) }.transpose.map(&:max)
|
14
15
|
fields.map do |r|
|
15
16
|
(0 .. clen.size - 1).map do |col_n|
|
16
17
|
col_n == 0 ? r[col_n].rjust(clen[col_n]) : r[col_n].ljust(clen[col_n])
|
17
|
-
end.join(' ')
|
18
|
+
end.join(tabular ? "\t" : ' ')
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
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,
|
13
|
+
VERSION = [0.3, 3, 0]
|
14
14
|
|
15
15
|
##
|
16
16
|
# Nickname for the current major.minor version.
|
data/scripts/distances.bash
CHANGED
data/utils/distance/pipeline.rb
CHANGED
@@ -81,6 +81,8 @@ module MiGA::DistanceRunner::Pipeline
|
|
81
81
|
end
|
82
82
|
# Save test
|
83
83
|
File.open(File.expand_path("#{dataset.name}.intax.txt", home), "w") do |fh|
|
84
|
+
fh.puts "Closest relative: #{cr[0][0]} with AAI: #{cr[0][1]}."
|
85
|
+
fh.puts ""
|
84
86
|
fh.puts MiGA::MiGA.tabulate(%w[Rank Taxonomy P-value Signif.], r)
|
85
87
|
fh.puts ""
|
86
88
|
fh.puts "Significance at p-value below: *0.5, **0.1, ***0.05, ****0.01."
|
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.
|
4
|
+
version: 0.3.3.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: 2018-
|
11
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- actions/rm.rb
|
137
137
|
- actions/run.rb
|
138
138
|
- actions/stats.rb
|
139
|
+
- actions/summary.rb
|
139
140
|
- actions/tax_dist.rb
|
140
141
|
- actions/tax_index.rb
|
141
142
|
- actions/tax_set.rb
|