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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83a243d552f8c0f850cd46e827069e2a0b6abb5b8ed3f2cda41cec21a5b93c85
4
- data.tar.gz: 85d9838dc0f9708d50e7d4375b8e641bc85ef096d95c88fcc43e8b5d1421e449
3
+ metadata.gz: 518860e2b5fbd03ec6887055a40f1d3fe5761f2bbab7550ccf575fa6a2b7b5bf
4
+ data.tar.gz: 620c88f6eca40d4f054191a871b52d1ec35bd0caf7dc580a8e27f2fcec7fa19f
5
5
  SHA512:
6
- metadata.gz: 7705f7987ae8a13a6664d8d3a9ca586bbbebc5447c5858fb5c9980c9d31d97a57e779e6987d4ca49dc06b7ccbb8602f22a2747cb1f55acfda3a5bf4edaa1798f
7
- data.tar.gz: 3920ee4cdbd9b6666e0d0233c3557218ad30abe4a4e9276de8db9532da628626ba764080766bf27ca5cee335c892cf7c72d610d2fc356dd2da464b24c881c228
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(MiGA::Dataset.INFO_FIELDS, ds.map{ |d| d.info })
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
@@ -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.
@@ -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 = fields.map { |r| r.map(&:length) }.transpose.map(&:max)
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, 2, 3]
13
+ VERSION = [0.3, 3, 0]
14
14
 
15
15
  ##
16
16
  # Nickname for the current major.minor version.
@@ -15,6 +15,5 @@ miga date > "$DATASET.start"
15
15
  ruby -I "$MIGA/lib" "$MIGA/utils/distances.rb" "$PROJECT" "$DATASET"
16
16
 
17
17
  # Finalize
18
- rm -R "$TMPDIR"
19
18
  miga date > "$DATASET.done"
20
19
  miga add_result -P "$PROJECT" -D "$DATASET" -r "$SCRIPT" -f
@@ -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.2.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-07-31 00:00:00.000000000 Z
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