miga-base 0.4.1.0 → 0.4.2.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/bin/miga +2 -244
- data/lib/miga/cli/action/about.rb +44 -0
- data/lib/miga/cli/action/add.rb +139 -0
- data/lib/miga/cli/action/add_result.rb +26 -0
- data/lib/miga/cli/action/console.rb +19 -0
- data/lib/miga/cli/action/daemon.rb +74 -0
- data/lib/miga/cli/action/date.rb +18 -0
- data/lib/miga/cli/action/doctor.rb +210 -0
- data/lib/miga/cli/action/edit.rb +24 -0
- data/lib/miga/cli/action/files.rb +31 -0
- data/lib/miga/cli/action/find.rb +48 -0
- data/lib/miga/cli/action/generic.rb +44 -0
- data/lib/miga/cli/action/get.rb +132 -0
- data/lib/miga/cli/action/init.rb +343 -0
- data/lib/miga/cli/action/ln.rb +42 -0
- data/lib/miga/cli/action/ls.rb +55 -0
- data/lib/miga/cli/action/ncbi_get.rb +218 -0
- data/lib/miga/cli/action/new.rb +45 -0
- data/lib/miga/cli/action/next_step.rb +27 -0
- data/lib/miga/cli/action/plugins.rb +28 -0
- data/lib/miga/cli/action/rm.rb +25 -0
- data/lib/miga/cli/action/run.rb +39 -0
- data/lib/miga/cli/action/stats.rb +140 -0
- data/lib/miga/cli/action/summary.rb +49 -0
- data/lib/miga/cli/action/tax_dist.rb +102 -0
- data/lib/miga/cli/action/tax_index.rb +47 -0
- data/lib/miga/cli/action/tax_set.rb +59 -0
- data/lib/miga/cli/action/tax_test.rb +77 -0
- data/lib/miga/cli/action.rb +66 -0
- data/lib/miga/cli/base.rb +90 -0
- data/lib/miga/cli.rb +426 -0
- data/lib/miga/project/result.rb +14 -6
- data/lib/miga/remote_dataset.rb +1 -1
- data/lib/miga/tax_index.rb +5 -4
- data/lib/miga/taxonomy/base.rb +63 -0
- data/lib/miga/taxonomy.rb +87 -92
- data/lib/miga/version.rb +6 -6
- data/test/taxonomy_test.rb +49 -9
- data/utils/distance/commands.rb +11 -11
- data/utils/distance/pipeline.rb +5 -5
- metadata +43 -49
- data/actions/about.rb +0 -43
- data/actions/add.rb +0 -129
- data/actions/add_result.rb +0 -30
- data/actions/daemon.rb +0 -55
- data/actions/date.rb +0 -14
- data/actions/doctor.rb +0 -201
- data/actions/edit.rb +0 -33
- data/actions/files.rb +0 -43
- data/actions/find.rb +0 -41
- data/actions/get.rb +0 -105
- data/actions/init.rb +0 -301
- data/actions/ln.rb +0 -47
- data/actions/ls.rb +0 -61
- data/actions/ncbi_get.rb +0 -192
- data/actions/new.rb +0 -44
- data/actions/next_step.rb +0 -33
- data/actions/plugins.rb +0 -25
- data/actions/rm.rb +0 -29
- data/actions/run.rb +0 -45
- data/actions/stats.rb +0 -149
- data/actions/summary.rb +0 -57
- data/actions/tax_dist.rb +0 -106
- data/actions/tax_index.rb +0 -46
- data/actions/tax_set.rb +0 -63
- data/actions/tax_test.rb +0 -80
data/actions/tax_index.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# @package MiGA
|
4
|
-
# @license Artistic-2.0
|
5
|
-
|
6
|
-
require "miga/tax_index"
|
7
|
-
|
8
|
-
o = {q:true, format: :json}
|
9
|
-
OptionParser.new do |opt|
|
10
|
-
opt_banner(opt)
|
11
|
-
opt_object(opt, o, [:project])
|
12
|
-
opt.on("-i", "--index PATH",
|
13
|
-
"(Mandatory) File to create with the index."){ |v| o[:index]=v }
|
14
|
-
opt.on("-f", "--format STRING",
|
15
|
-
"Format of the index file. By default: #{o[:format]}. Supported: " +
|
16
|
-
"json, tab."){ |v| o[:format]=v.to_sym }
|
17
|
-
opt_filter_datasets(opt, o)
|
18
|
-
opt_common(opt, o)
|
19
|
-
end.parse!
|
20
|
-
|
21
|
-
##=> Main <=
|
22
|
-
opt_require(o, project:"-P", index:"-i")
|
23
|
-
|
24
|
-
$stderr.puts "Loading project." unless o[:q]
|
25
|
-
p = MiGA::Project.load(o[:project])
|
26
|
-
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
27
|
-
|
28
|
-
$stderr.puts "Loading datasets." unless o[:q]
|
29
|
-
ds = p.datasets
|
30
|
-
ds.select!{|d| not d.metadata[:tax].nil? }
|
31
|
-
ds = filter_datasets!(ds, o)
|
32
|
-
|
33
|
-
$stderr.puts "Indexing taxonomy." unless o[:q]
|
34
|
-
tax_index = MiGA::TaxIndex.new
|
35
|
-
ds.each { |d| tax_index << d }
|
36
|
-
|
37
|
-
$stderr.puts "Saving index." unless o[:q]
|
38
|
-
fh = File.open(o[:index], "w")
|
39
|
-
if o[:format]==:json
|
40
|
-
fh.print tax_index.to_json
|
41
|
-
elsif o[:format]==:tab
|
42
|
-
fh.print tax_index.to_tab
|
43
|
-
end
|
44
|
-
fh.close
|
45
|
-
|
46
|
-
$stderr.puts "Done." unless o[:q]
|
data/actions/tax_set.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# @package MiGA
|
4
|
-
# @license Artistic-2.0
|
5
|
-
|
6
|
-
o = {q:true}
|
7
|
-
OptionParser.new do |opt|
|
8
|
-
opt_banner(opt)
|
9
|
-
opt_object(opt, o, [:project, :dataset_opt])
|
10
|
-
opt.on("-s", "--tax-string STRING",
|
11
|
-
"String corresponding to the taxonomy of the dataset.",
|
12
|
-
"The MiGA format of string taxonomy is a space-delimited",
|
13
|
-
"set of 'rank:name' pairs."){ |v| o[:taxstring]=v }
|
14
|
-
opt.on("-t", "--tax-file PATH",
|
15
|
-
"(Mandatory unless -D and -s are provided) Tab-delimited file containing",
|
16
|
-
"datasets taxonomy. Each row corresponds to a datasets and each column",
|
17
|
-
"corresponds to a rank. The first row must be a header with the rank ",
|
18
|
-
"names, and the first column must contain dataset names."
|
19
|
-
){ |v| o[:taxfile]=v }
|
20
|
-
opt_common(opt, o)
|
21
|
-
end.parse!
|
22
|
-
|
23
|
-
##=> Main <=
|
24
|
-
opt_require(o, project:"-P")
|
25
|
-
raise "-D is mandatory unless -t is provided." if
|
26
|
-
o[:dataset].nil? and o[:taxfile].nil?
|
27
|
-
raise "-s is mandatory unless -t is provided." if
|
28
|
-
o[:taxstring].nil? and o[:taxfile].nil?
|
29
|
-
|
30
|
-
$stderr.puts "Loading project." unless o[:q]
|
31
|
-
p = MiGA::Project.load(o[:project])
|
32
|
-
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
33
|
-
|
34
|
-
if not o[:taxfile].nil?
|
35
|
-
$stderr.puts "Reading tax-file and registering taxonomy." unless o[:q]
|
36
|
-
tfh = File.open(o[:taxfile], "r")
|
37
|
-
header = nil
|
38
|
-
tfh.each_line do |ln|
|
39
|
-
next if ln =~ /^\s*?$/
|
40
|
-
r = ln.chomp.split(/\t/, -1)
|
41
|
-
dn = r.shift
|
42
|
-
if header.nil?
|
43
|
-
header = r
|
44
|
-
next
|
45
|
-
end
|
46
|
-
d = p.dataset dn
|
47
|
-
if d.nil?
|
48
|
-
warn "Impossible to find dataset at line #{$.}: #{dn}. Ignoring..."
|
49
|
-
next
|
50
|
-
end
|
51
|
-
d.metadata[:tax] = MiGA::Taxonomy.new(r, header)
|
52
|
-
d.save
|
53
|
-
$stderr.puts " #{d.name} registered." unless o[:q]
|
54
|
-
end
|
55
|
-
tfh.close
|
56
|
-
else
|
57
|
-
$stderr.puts "Registering taxonomy." unless o[:q]
|
58
|
-
d = p.dataset o[:dataset]
|
59
|
-
d.metadata[:tax] = MiGA::Taxonomy.new(o[:taxstring])
|
60
|
-
d.save
|
61
|
-
end
|
62
|
-
|
63
|
-
$stderr.puts "Done." unless o[:q]
|
data/actions/tax_test.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# @package MiGA
|
4
|
-
# @license Artistic-2.0
|
5
|
-
|
6
|
-
require "miga/tax_dist"
|
7
|
-
|
8
|
-
o = {q:true, test:"both", ref_project:false}
|
9
|
-
OptionParser.new do |opt|
|
10
|
-
opt_banner(opt)
|
11
|
-
opt_object(opt, o, [:project, :dataset])
|
12
|
-
opt.on("--ref-project",
|
13
|
-
"Use the taxonomy from the reference project, not the current project."
|
14
|
-
){ |v| o[:ref_project]=v }
|
15
|
-
opt.on("-t", "--test STRING",
|
16
|
-
"Test to perform. Supported values: intax, novel, both."
|
17
|
-
){ |v| o[:test]=v.downcase }
|
18
|
-
opt_common(opt, o)
|
19
|
-
end.parse!
|
20
|
-
|
21
|
-
##=> Main <=
|
22
|
-
opt_require(o, project:"-P", dataset:"-D")
|
23
|
-
|
24
|
-
$stderr.puts "Loading project." unless o[:q]
|
25
|
-
p = MiGA::Project.load(o[:project])
|
26
|
-
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
27
|
-
|
28
|
-
$stderr.puts "Loading dataset." unless o[:q]
|
29
|
-
ds = p.dataset(o[:dataset])
|
30
|
-
|
31
|
-
$stderr.puts "Finding closest relative." unless o[:q]
|
32
|
-
cr = ds.closest_relatives(1, o[:ref_project])
|
33
|
-
|
34
|
-
if cr.nil? or cr.empty?
|
35
|
-
raise "This action is not supported for the project or dataset." if cr.nil?
|
36
|
-
raise "No close relatives found."
|
37
|
-
else
|
38
|
-
$stderr.puts "Querying probability distributions." unless o[:q]
|
39
|
-
cr = cr[0]
|
40
|
-
puts "Closest relative: #{cr[0]} with AAI: #{cr[1]}."
|
41
|
-
if o[:ref_project]
|
42
|
-
ref = p.metadata[:ref_project]
|
43
|
-
raise "--ref-project requested, but no reference project has been set." if ref.nil?
|
44
|
-
q = MiGA::Project.load(ref)
|
45
|
-
raise "--ref-project requested, but reference project doesn't exist." if q.nil?
|
46
|
-
tax = q.dataset(cr[0]).metadata[:tax]
|
47
|
-
else
|
48
|
-
tax = p.dataset(cr[0]).metadata[:tax]
|
49
|
-
end
|
50
|
-
tax ||= {}
|
51
|
-
|
52
|
-
if %w[intax both].include? o[:test]
|
53
|
-
# Intax
|
54
|
-
r = MiGA::TaxDist.aai_pvalues(cr[1], :intax).map do |k,v|
|
55
|
-
sig = ""
|
56
|
-
[0.5,0.1,0.05,0.01].each{ |i| sig << "*" if v<i }
|
57
|
-
[MiGA::Taxonomy.LONG_RANKS[k], (tax[k] || "?"), v, sig]
|
58
|
-
end
|
59
|
-
puts ""
|
60
|
-
puts "Taxonomic classification"
|
61
|
-
puts MiGA::MiGA.tabulate(%w[Rank Taxonomy P-value Signif.], r)
|
62
|
-
end
|
63
|
-
|
64
|
-
if %w[novel both].include? o[:test]
|
65
|
-
# Novel
|
66
|
-
r = MiGA::TaxDist.aai_pvalues(cr[1], :novel).map do |k,v|
|
67
|
-
sig = ""
|
68
|
-
[0.5,0.1,0.05,0.01].each{ |i| sig << "*" if v<i }
|
69
|
-
[MiGA::Taxonomy.LONG_RANKS[k], v, sig]
|
70
|
-
end
|
71
|
-
puts ""
|
72
|
-
puts "Taxonomic novelty"
|
73
|
-
puts MiGA::MiGA.tabulate(%w[Rank P-value Signif.], r)
|
74
|
-
end
|
75
|
-
|
76
|
-
puts ""
|
77
|
-
puts "Significance at p-value below: *0.5, **0.1, ***0.05, ****0.01."
|
78
|
-
end
|
79
|
-
|
80
|
-
$stderr.puts "Done." unless o[:q]
|