miga-base 0.2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +351 -0
- data/actions/add_result +61 -0
- data/actions/add_taxonomy +86 -0
- data/actions/create_dataset +62 -0
- data/actions/create_project +70 -0
- data/actions/daemon +69 -0
- data/actions/download_dataset +77 -0
- data/actions/find_datasets +63 -0
- data/actions/import_datasets +86 -0
- data/actions/index_taxonomy +71 -0
- data/actions/list_datasets +83 -0
- data/actions/list_files +67 -0
- data/actions/unlink_dataset +52 -0
- data/bin/miga +48 -0
- data/lib/miga/daemon.rb +178 -0
- data/lib/miga/dataset.rb +286 -0
- data/lib/miga/gui.rb +289 -0
- data/lib/miga/metadata.rb +74 -0
- data/lib/miga/project.rb +268 -0
- data/lib/miga/remote_dataset.rb +154 -0
- data/lib/miga/result.rb +102 -0
- data/lib/miga/tax_index.rb +70 -0
- data/lib/miga/taxonomy.rb +107 -0
- data/lib/miga.rb +83 -0
- data/scripts/_distances_noref_nomulti.bash +86 -0
- data/scripts/_distances_ref_nomulti.bash +105 -0
- data/scripts/aai_distances.bash +40 -0
- data/scripts/ani_distances.bash +39 -0
- data/scripts/assembly.bash +38 -0
- data/scripts/cds.bash +45 -0
- data/scripts/clade_finding.bash +27 -0
- data/scripts/distances.bash +30 -0
- data/scripts/essential_genes.bash +29 -0
- data/scripts/haai_distances.bash +39 -0
- data/scripts/init.bash +211 -0
- data/scripts/miga.bash +12 -0
- data/scripts/mytaxa.bash +93 -0
- data/scripts/mytaxa_scan.bash +85 -0
- data/scripts/ogs.bash +36 -0
- data/scripts/read_quality.bash +37 -0
- data/scripts/ssu.bash +35 -0
- data/scripts/subclades.bash +26 -0
- data/scripts/trimmed_fasta.bash +47 -0
- data/scripts/trimmed_reads.bash +57 -0
- data/utils/adapters.fa +302 -0
- data/utils/mytaxa_scan.R +89 -0
- data/utils/mytaxa_scan.rb +58 -0
- data/utils/requirements.txt +19 -0
- data/utils/subclades-compile.rb +48 -0
- data/utils/subclades.R +171 -0
- metadata +185 -0
data/actions/daemon
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# @package MiGA
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Oct-01-2015
|
7
|
+
#
|
8
|
+
|
9
|
+
require "miga/daemon"
|
10
|
+
|
11
|
+
task = ARGV.shift unless ["-h","--help"].include? ARGV.first
|
12
|
+
ARGV << "-h" if ARGV.empty?
|
13
|
+
o = {q:true, update:false, daemon_opts:[]}
|
14
|
+
OptionParser.new do |opt|
|
15
|
+
opt.banner = <<BAN
|
16
|
+
Controls the daemon of a MiGA project.
|
17
|
+
|
18
|
+
Usage: #{$0} #{File.basename(__FILE__)} {task} [options]
|
19
|
+
BAN
|
20
|
+
opt.separator "task:"
|
21
|
+
{ start: "Start an instance of the application.",
|
22
|
+
stop: "Start an instance of the application.",
|
23
|
+
restart: "Stop all instances and restart them afterwards.",
|
24
|
+
reload: "Send a SIGHUP to all instances of the application.",
|
25
|
+
run: "Start the application and stay on top.",
|
26
|
+
zap: "Set the application to a stopped state.",
|
27
|
+
status: "Show status (PID) of application instances."
|
28
|
+
}.each{ |k,v| opt.separator sprintf " %*s%s", -33, k, v }
|
29
|
+
opt.separator ""
|
30
|
+
opt.separator "MiGA options:"
|
31
|
+
opt.on("-P", "--project PATH",
|
32
|
+
"(Mandatory) Path to the project to use."){ |v| o[:project]=v }
|
33
|
+
opt.on("--latency INT",
|
34
|
+
"Number of seconds the daemon will be sleeping."
|
35
|
+
){ |v| o[:latency]=v.to_i }
|
36
|
+
opt.on("--max-jobs INT",
|
37
|
+
"Maximum number of jobs to use simultaneously."){ |v| o[:maxjobs]=v.to_i }
|
38
|
+
opt.on("--ppn INT",
|
39
|
+
"Maximum number of cores to use in a single job."){ |v| o[:ppn]=v.to_i }
|
40
|
+
opt.on("-v", "--verbose",
|
41
|
+
"Print additional information to STDERR."){ o[:q]=false }
|
42
|
+
opt.on("-d", "--debug INT", "Print debugging information to STDERR.") do |v|
|
43
|
+
v.to_i>1 ? MiGA::MiGA.DEBUG_TRACE_ON : MiGA::MiGA.DEBUG_ON
|
44
|
+
end
|
45
|
+
opt.on("-h", "--help", "Display this screen.") do
|
46
|
+
puts opt
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
opt.separator ""
|
50
|
+
opt.separator "Daemon options:"
|
51
|
+
opt.on("-t", "--ontop",
|
52
|
+
"Stay on top (does not daemonize)"){ o[:daemon_opts] << '-t' }
|
53
|
+
opt.on("-f", "--force", "Force operation"){ o[:daemon_opts] << '-f' }
|
54
|
+
opt.on("-n", "--no_wait",
|
55
|
+
"Do not wait for processes to stop"){ o[:daemon_opts] << '-n' }
|
56
|
+
end.parse!
|
57
|
+
|
58
|
+
### MAIN
|
59
|
+
raise "Project is mandatory." if o[:project].nil?
|
60
|
+
|
61
|
+
raise "Project doesn't exist, aborting." unless
|
62
|
+
MiGA::Project.exist? o[:project]
|
63
|
+
p = MiGA::Project.new(o[:project])
|
64
|
+
d = MiGA::Daemon.new(p)
|
65
|
+
[:latency, :maxjobs, :ppn].each do |k|
|
66
|
+
d.runopts(k, o[k]) unless o[k].nil?
|
67
|
+
end
|
68
|
+
d.daemon(task, o[:daemon_opts])
|
69
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# @package MiGA
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Oct-01-2015
|
7
|
+
#
|
8
|
+
|
9
|
+
require "miga/remote_dataset"
|
10
|
+
|
11
|
+
o = {q:true, ref:true, universe: :ebi, db: :embl}
|
12
|
+
OptionParser.new do |opt|
|
13
|
+
opt.banner = <<BAN
|
14
|
+
Creates an empty dataset in a pre-existing MiGA project.
|
15
|
+
|
16
|
+
Usage: #{$0} #{File.basename(__FILE__)} [options]
|
17
|
+
BAN
|
18
|
+
opt.separator ""
|
19
|
+
opt.on("-P", "--project PATH",
|
20
|
+
"(Mandatory) Path to the project to use."){ |v| o[:project]=v }
|
21
|
+
opt.on("-D", "--dataset STRING",
|
22
|
+
"(Mandatory) ID of the dataset to create."){ |v| o[:dataset]=v }
|
23
|
+
opt.on("-I", "--ids ID1,ID2,...",
|
24
|
+
"(Mandatory) IDs in the remote database separated by commas."
|
25
|
+
){ |v| o[:ids]=v }
|
26
|
+
opt.on("-U", "--universe STRING",
|
27
|
+
"Universe where the remote database lives. By default: #{o[:universe]}."
|
28
|
+
){ |v| o[:universe]=v.to_sym }
|
29
|
+
opt.on("--db STRING",
|
30
|
+
"Name of the remote database. By default: #{o[:db]}."
|
31
|
+
){ |v| o[:db]=v.to_sym }
|
32
|
+
opt.on("-t", "--type STRING",
|
33
|
+
"Type of dataset. Recognized types include:",
|
34
|
+
*MiGA::Dataset.KNOWN_TYPES.map{ |k,v| "~ #{k}: #{v[:description]}"}
|
35
|
+
){ |v| o[:type]=v.to_sym }
|
36
|
+
opt.on("-q", "--query",
|
37
|
+
"If set, the dataset is registered as a query, not a reference dataset."
|
38
|
+
){ |v| o[:ref]=!v }
|
39
|
+
opt.on("-d", "--description STRING",
|
40
|
+
"Description of the dataset."){ |v| o[:description]=v }
|
41
|
+
opt.on("-u", "--user STRING",
|
42
|
+
"Owner of the dataset."){ |v| o[:user]=v }
|
43
|
+
opt.on("-c", "--comments STRING",
|
44
|
+
"Comments on the dataset."){ |v| o[:comments]=v }
|
45
|
+
opt.on("-v", "--verbose",
|
46
|
+
"Print additional information to STDERR."){ o[:q]=false }
|
47
|
+
opt.on("-d", "--debug INT", "Print debugging information to STDERR.") do |v|
|
48
|
+
v.to_i>1 ? MiGA::MiGA.DEBUG_TRACE_ON : MiGA::MiGA.DEBUG_ON
|
49
|
+
end
|
50
|
+
opt.on("-h", "--help", "Display this screen.") do
|
51
|
+
puts opt
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
opt.separator ""
|
55
|
+
end.parse!
|
56
|
+
|
57
|
+
|
58
|
+
### MAIN
|
59
|
+
raise "-P is mandatory." if o[:project].nil?
|
60
|
+
raise "-D is mandatory." if o[:dataset].nil?
|
61
|
+
raise "-I is mandatory." if o[:ids].nil?
|
62
|
+
|
63
|
+
$stderr.puts "Locating remote dataset." unless o[:q]
|
64
|
+
rd = MiGA::RemoteDataset.new(o[:ids], o[:db], o[:universe])
|
65
|
+
|
66
|
+
$stderr.puts "Loading project." unless o[:q]
|
67
|
+
p = MiGA::Project.load(o[:project])
|
68
|
+
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
69
|
+
|
70
|
+
$stderr.puts "Creating dataset." unless o[:q]
|
71
|
+
md = {}
|
72
|
+
[:type, :description, :user, :comments].each{ |k| md[k]=o[k] unless o[k].nil? }
|
73
|
+
d = rd.save_to(p, o[:dataset], o[:ref], md)
|
74
|
+
p.add_dataset(o[:dataset])
|
75
|
+
|
76
|
+
$stderr.puts "Done." unless o[:q]
|
77
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# @package MiGA
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Oct-01-2015
|
7
|
+
#
|
8
|
+
|
9
|
+
o = {q:true, add:false, ref:false}
|
10
|
+
OptionParser.new do |opt|
|
11
|
+
opt.banner = <<BAN
|
12
|
+
Finds unregistered datasets based on result files.
|
13
|
+
|
14
|
+
Usage: #{$0} #{File.basename(__FILE__)} [options]
|
15
|
+
BAN
|
16
|
+
opt.separator ""
|
17
|
+
opt.on("-P", "--project PATH",
|
18
|
+
"(Mandatory) Path to the project to use."){ |v| o[:project]=v }
|
19
|
+
opt.on("-a", "--add",
|
20
|
+
"Register the datasets found. By default, only lists them (dry run)."
|
21
|
+
){ |v| o[:add]=v }
|
22
|
+
opt.on("-t", "--type STRING",
|
23
|
+
"Type of datasets. Recognized types include:",
|
24
|
+
*MiGA::Dataset.KNOWN_TYPES.map{ |k,v| "~ #{k}: #{v[:description]}"}
|
25
|
+
){ |v| o[:type]=v.to_sym }
|
26
|
+
opt.on("-r", "--ref",
|
27
|
+
"If set, all datasets are registered as reference datasets."
|
28
|
+
){ |v| o[:ref]=v }
|
29
|
+
opt.on("-u", "--user STRING", "Owner of the dataset."){ |v| o[:user]=v }
|
30
|
+
opt.on("-v", "--verbose",
|
31
|
+
"Print additional information to STDERR."){ o[:q]=false }
|
32
|
+
opt.on("-d", "--debug INT", "Print debugging information to STDERR.") do |v|
|
33
|
+
v.to_i>1 ? MiGA::MiGA.DEBUG_TRACE_ON : MiGA::MiGA.DEBUG_ON
|
34
|
+
end
|
35
|
+
opt.on("-h", "--help", "Display this screen.") do
|
36
|
+
puts opt
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
opt.separator ""
|
40
|
+
end.parse!
|
41
|
+
|
42
|
+
|
43
|
+
### MAIN
|
44
|
+
raise "-P is mandatory." if o[:project].nil?
|
45
|
+
|
46
|
+
$stderr.puts "Loading project." unless o[:q]
|
47
|
+
p = MiGA::Project.load(o[:project])
|
48
|
+
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
49
|
+
|
50
|
+
$stderr.puts "Finding datasets." unless o[:q]
|
51
|
+
ud = p.unregistered_datasets
|
52
|
+
ud.each do |dn|
|
53
|
+
puts dn
|
54
|
+
if o[:add]
|
55
|
+
md = {}
|
56
|
+
[:type, :user].each{ |k| md[k]=o[k] unless o[k].nil? }
|
57
|
+
d = MiGA::Dataset.new(p, dn, o[:ref], md)
|
58
|
+
p.add_dataset(dn)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
$stderr.puts "Done." unless o[:q]
|
63
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# @package MiGA
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Oct-01-2015
|
7
|
+
#
|
8
|
+
|
9
|
+
o = {q:true, info:false, force:false, method: :hardlink }
|
10
|
+
OptionParser.new do |opt|
|
11
|
+
opt.banner = <<BAN
|
12
|
+
Link datasets (including results) from one project to another.
|
13
|
+
|
14
|
+
Usage: #{$0} #{File.basename(__FILE__)} [options]
|
15
|
+
BAN
|
16
|
+
opt.separator ""
|
17
|
+
opt.on("-P", "--project-source PATH",
|
18
|
+
"(Mandatory) Path to the project that contains the dataset."
|
19
|
+
){ |v| o[:project1]=v }
|
20
|
+
opt.on("-Q", "--project-target PATH",
|
21
|
+
"(Mandatory) Path to the project where to link the dataset."
|
22
|
+
){ |v| o[:project2]=v }
|
23
|
+
opt.on("-D", "--dataset STRING",
|
24
|
+
"ID of the dataset to link."){ |v| o[:dataset]=v.miga_name }
|
25
|
+
opt.on("-f", "--force",
|
26
|
+
"Forces linking, even if dataset's preprocessing is incomplete."
|
27
|
+
){ |v| o[:force]=v }
|
28
|
+
opt.on("-s", "--symlink",
|
29
|
+
"Creates symlinks instead of the default hard links."
|
30
|
+
){ o[:method] = :symlink }
|
31
|
+
opt.on("-c", "--copy",
|
32
|
+
"Creates copies instead of the default hard links."){ o[:method] = :copy }
|
33
|
+
opt.on("--[no-]ref",
|
34
|
+
"If set, links only reference (or only non-reference) datasets."
|
35
|
+
){ |v| o[:ref]=v }
|
36
|
+
opt.on("--[no-]multi",
|
37
|
+
"If set, links only multi-species (or only single-species) datasets."
|
38
|
+
){ |v| o[:multi]=v }
|
39
|
+
opt.on("-t", "--taxonomy RANK:TAXON",
|
40
|
+
"Filter by taxonomy."){ |v| o[:taxonomy]=MiGA::Taxonomy.new v }
|
41
|
+
opt.on("-v", "--verbose",
|
42
|
+
"Print additional information to STDERR."){ o[:q]=false }
|
43
|
+
opt.on("-d", "--debug INT", "Print debugging information to STDERR.") do |v|
|
44
|
+
v.to_i>1 ? MiGA::MiGA.DEBUG_TRACE_ON : MiGA::MiGA.DEBUG_ON
|
45
|
+
end
|
46
|
+
opt.on("-h", "--help", "Display this screen.") do
|
47
|
+
puts opt
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
opt.separator ""
|
51
|
+
end.parse!
|
52
|
+
|
53
|
+
|
54
|
+
### MAIN
|
55
|
+
raise "-P is mandatory." if o[:project1].nil?
|
56
|
+
raise "-Q is mandatory." if o[:project2].nil?
|
57
|
+
|
58
|
+
$stderr.puts "Loading project." unless o[:q]
|
59
|
+
p = MiGA::Project.load(o[:project1])
|
60
|
+
raise "Impossible to load project: #{o[:project1]}" if p.nil?
|
61
|
+
q = MiGA::Project.load(o[:project2])
|
62
|
+
raise "Impossible to load project: #{o[:project2]}" if q.nil?
|
63
|
+
|
64
|
+
$stderr.puts "Listing dataset." unless o[:q]
|
65
|
+
if o[:dataset].nil?
|
66
|
+
ds = p.datasets
|
67
|
+
else
|
68
|
+
ds = [p.dataset(o[:dataset])]
|
69
|
+
end
|
70
|
+
ds.select!{|d| d.name == o[:dataset]} unless o[:dataset].nil?
|
71
|
+
ds.select!{|d| d.is_ref? == o[:ref] } unless o[:ref].nil?
|
72
|
+
ds.select! do |d|
|
73
|
+
(not d.metadata[:type].nil?) and
|
74
|
+
(MiGA::Dataset.KNOWN_TYPES[d.metadata[:type]][:multi] == o[:multi])
|
75
|
+
end unless o[:multi].nil?
|
76
|
+
ds.select! do |d|
|
77
|
+
(not d.metadata[:tax].nil?) and d.metadata[:tax].is_in?(o[:taxonomy])
|
78
|
+
end unless o[:taxonomy].nil?
|
79
|
+
ds.each do |d|
|
80
|
+
next unless o[:force] or d.done_preprocessing?
|
81
|
+
puts d.name
|
82
|
+
q.import_dataset(d, o[:method])
|
83
|
+
end
|
84
|
+
|
85
|
+
$stderr.puts "Done." unless o[:q]
|
86
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# @package MiGA
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Oct-01-2015
|
7
|
+
#
|
8
|
+
|
9
|
+
require "miga/tax_index"
|
10
|
+
|
11
|
+
o = {q:true, format: :json}
|
12
|
+
OptionParser.new do |opt|
|
13
|
+
opt.banner = <<BAN
|
14
|
+
Creates a taxonomy-indexed list of the datasets.
|
15
|
+
|
16
|
+
Usage: #{$0} #{File.basename(__FILE__)} [options]
|
17
|
+
BAN
|
18
|
+
opt.separator ""
|
19
|
+
opt.on("-P", "--project PATH",
|
20
|
+
"(Mandatory) Path to the project to read."){ |v| o[:project]=v }
|
21
|
+
opt.on("-i", "--index PATH",
|
22
|
+
"(Mandatory) File to create with the index."){ |v| o[:index]=v }
|
23
|
+
opt.on("-f", "--format STRING",
|
24
|
+
"Format of the index file. By default: #{o[:format]}. Supported: " +
|
25
|
+
"json, tab."){ |v| o[:format]=v.to_sym }
|
26
|
+
opt.on("--[no-]multi",
|
27
|
+
"If set, lists only multi-species (or only single-species) datasets."
|
28
|
+
){ |v| o[:multi]=v }
|
29
|
+
opt.on("-v", "--verbose",
|
30
|
+
"Print additional information to STDERR."){ o[:q]=false }
|
31
|
+
opt.on("-d", "--debug INT", "Print debugging information to STDERR.") do |v|
|
32
|
+
v.to_i>1 ? MiGA::MiGA.DEBUG_TRACE_ON : MiGA::MiGA.DEBUG_ON
|
33
|
+
end
|
34
|
+
opt.on("-h", "--help", "Display this screen.") do
|
35
|
+
puts opt
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
opt.separator ""
|
39
|
+
end.parse!
|
40
|
+
|
41
|
+
### MAIN
|
42
|
+
raise "-P is mandatory." if o[:project].nil?
|
43
|
+
raise "-i is mandatory." if o[:index].nil?
|
44
|
+
|
45
|
+
$stderr.puts "Loading project." unless o[:q]
|
46
|
+
p = MiGA::Project.load(o[:project])
|
47
|
+
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
48
|
+
|
49
|
+
$stderr.puts "Loading datasets." unless o[:q]
|
50
|
+
ds = p.datasets
|
51
|
+
ds.select!{|d| not d.metadata[:tax].nil? }
|
52
|
+
ds.select! do |d|
|
53
|
+
(not d.metadata[:type].nil?) and
|
54
|
+
(MiGA::Dataset.KNOWN_TYPES[d.metadata[:type]][:multi] == o[:multi])
|
55
|
+
end unless o[:multi].nil?
|
56
|
+
|
57
|
+
$stderr.puts "Indexing taxonomy." unless o[:q]
|
58
|
+
tax_index = MiGA::TaxIndex.new
|
59
|
+
ds.each { |d| tax_index << d }
|
60
|
+
|
61
|
+
$stderr.puts "Saving index." unless o[:q]
|
62
|
+
fh = File.open(o[:index], "w")
|
63
|
+
if o[:format]==:json
|
64
|
+
fh.print tax_index.to_json
|
65
|
+
elsif o[:format]==:tab
|
66
|
+
fh.print tax_index.to_tab
|
67
|
+
end
|
68
|
+
fh.close
|
69
|
+
|
70
|
+
$stderr.puts "Done." unless o[:q]
|
71
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# @package MiGA
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Oct-01-2015
|
7
|
+
#
|
8
|
+
|
9
|
+
o = {q:true, info:false}
|
10
|
+
OptionParser.new do |opt|
|
11
|
+
opt.banner = <<BAN
|
12
|
+
Lists all registered datasets in an MiGA project.
|
13
|
+
|
14
|
+
Usage: #{$0} #{File.basename(__FILE__)} [options]
|
15
|
+
BAN
|
16
|
+
opt.separator ""
|
17
|
+
opt.on("-P", "--project PATH",
|
18
|
+
"(Mandatory) Path to the project to read."){ |v| o[:project]=v }
|
19
|
+
opt.on("-D", "--dataset STRING",
|
20
|
+
"ID of the dataset to read."){ |v| o[:dataset]=v.miga_name }
|
21
|
+
opt.on("--[no-]ref",
|
22
|
+
"If set, lists only reference (or only non-reference) datasets."
|
23
|
+
){ |v| o[:ref]=v }
|
24
|
+
opt.on("--[no-]multi",
|
25
|
+
"If set, lists only multi-species (or only single-species) datasets."
|
26
|
+
){ |v| o[:multi]=v }
|
27
|
+
opt.on("-i", "--info",
|
28
|
+
"Print additional information on each dataset."){ o[:info]=true }
|
29
|
+
opt.on("-t", "--taxonomy RANK:TAXON",
|
30
|
+
"Filter by taxonomy."){ |v| o[:taxonomy]=MiGA::Taxonomy.new v }
|
31
|
+
opt.on("-m", "--metadata STRING",
|
32
|
+
"Print name and metadata field only. If set, ignores -i."
|
33
|
+
){ |v| o[:datum]=v }
|
34
|
+
opt.on("-v", "--verbose",
|
35
|
+
"Print additional information to STDERR."){ o[:q]=false }
|
36
|
+
opt.on("-d", "--debug INT", "Print debugging information to STDERR.") do |v|
|
37
|
+
v.to_i>1 ? MiGA::MiGA.DEBUG_TRACE_ON : MiGA::MiGA.DEBUG_ON
|
38
|
+
end
|
39
|
+
opt.on("-h", "--help", "Display this screen.") do
|
40
|
+
puts opt
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
opt.separator ""
|
44
|
+
end.parse!
|
45
|
+
|
46
|
+
|
47
|
+
### MAIN
|
48
|
+
raise "-P is mandatory." if o[:project].nil?
|
49
|
+
|
50
|
+
$stderr.puts "Loading project." unless o[:q]
|
51
|
+
p = MiGA::Project.load(o[:project])
|
52
|
+
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
53
|
+
|
54
|
+
$stderr.puts "Listing datasets." unless o[:q]
|
55
|
+
if o[:dataset].nil?
|
56
|
+
ds = p.datasets
|
57
|
+
elsif MiGA::Dataset.exist? p, o[:dataset]
|
58
|
+
ds = [p.dataset(o[:dataset])]
|
59
|
+
else
|
60
|
+
ds = []
|
61
|
+
end
|
62
|
+
ds.select!{|d| d.is_ref? == o[:ref] } unless o[:ref].nil?
|
63
|
+
ds.select! do |d|
|
64
|
+
(not d.metadata[:type].nil?) and
|
65
|
+
(MiGA::Dataset.KNOWN_TYPES[d.metadata[:type]][:multi] == o[:multi])
|
66
|
+
end unless o[:multi].nil?
|
67
|
+
ds.select! do |d|
|
68
|
+
(not d.metadata[:tax].nil?) and d.metadata[:tax].is_in?(o[:taxonomy])
|
69
|
+
end unless o[:taxonomy].nil?
|
70
|
+
if not o[:datum].nil?
|
71
|
+
ds.each{|d| puts "#{d.name}\t#{(d.metadata[ o[:datum] ] || "?").to_s}"}
|
72
|
+
elsif o[:info]
|
73
|
+
header = MiGA::Dataset.INFO_FIELDS.map{|i| i.ljust(25)}.join(" ")
|
74
|
+
puts header, header.gsub(/\S/,"-")
|
75
|
+
ds.each do |d|
|
76
|
+
puts d.info.map{|i| i.nil? ? "?" : i.to_s}.map{|i| i.ljust(25)}.join(" ")
|
77
|
+
end
|
78
|
+
else
|
79
|
+
ds.each{|d| puts d.name}
|
80
|
+
end
|
81
|
+
|
82
|
+
$stderr.puts "Done." unless o[:q]
|
83
|
+
|
data/actions/list_files
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# @package MiGA
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Oct-01-2015
|
7
|
+
#
|
8
|
+
|
9
|
+
o = {q:true, details:false, json:true}
|
10
|
+
OptionParser.new do |opt|
|
11
|
+
opt.banner = <<BAN
|
12
|
+
Lists all registered files from the results of a dataset or a project.
|
13
|
+
|
14
|
+
Usage: #{$0} #{File.basename(__FILE__)} [options]
|
15
|
+
BAN
|
16
|
+
opt.separator ""
|
17
|
+
opt.on("-P", "--project PATH",
|
18
|
+
"(Mandatory) Path to the project to read."){ |v| o[:project]=v }
|
19
|
+
opt.on("-D", "--dataset STRING",
|
20
|
+
"ID of the dataset to read. If not set, project-wide results are shown."
|
21
|
+
){ |v| o[:dataset]=v.miga_name }
|
22
|
+
opt.on("-i", "--info",
|
23
|
+
"If set, it prints additional details for each file."
|
24
|
+
){ |v| o[:details]=v }
|
25
|
+
opt.on("--exclude-json",
|
26
|
+
"If set, excludes json files containing results metadata."
|
27
|
+
){ |v| o[:json]=!v }
|
28
|
+
opt.on("-v", "--verbose",
|
29
|
+
"Print additional information to STDERR."){ o[:q]=false }
|
30
|
+
opt.on("-d", "--debug INT", "Print debugging information to STDERR.") do |v|
|
31
|
+
v.to_i>1 ? MiGA::MiGA.DEBUG_TRACE_ON : MiGA::MiGA.DEBUG_ON
|
32
|
+
end
|
33
|
+
opt.on("-h", "--help", "Display this screen.") do
|
34
|
+
puts opt
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
opt.separator ""
|
38
|
+
end.parse!
|
39
|
+
|
40
|
+
|
41
|
+
### MAIN
|
42
|
+
raise "-P is mandatory." if o[:project].nil?
|
43
|
+
|
44
|
+
$stderr.puts "Loading project." unless o[:q]
|
45
|
+
p = MiGA::Project.load(o[:project])
|
46
|
+
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
47
|
+
|
48
|
+
if o[:dataset].nil?
|
49
|
+
results = p.results
|
50
|
+
else
|
51
|
+
$stderr.puts "Loading dataset." unless o[:q]
|
52
|
+
ds = p.dataset(o[:dataset])
|
53
|
+
raise "Impossible to load dataset: #{o[:dataset]}" if ds.nil?
|
54
|
+
results = ds.results
|
55
|
+
end
|
56
|
+
|
57
|
+
$stderr.puts "Listing files." unless o[:q]
|
58
|
+
results.each do |result|
|
59
|
+
puts (o[:details] ? result.path + "\t" + "\t" : "") + result.path if o[:json]
|
60
|
+
result.each_file do |k,f|
|
61
|
+
puts (o[:details] ? result.path + "\t" + k.to_s + "\t" : "") +
|
62
|
+
File.dirname(result.path) + "/" + f.to_s
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
$stderr.puts "Done." unless o[:q]
|
67
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# @package MiGA
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Oct-01-2015
|
7
|
+
#
|
8
|
+
|
9
|
+
o = {q:true, remove:false}
|
10
|
+
OptionParser.new do |opt|
|
11
|
+
opt.banner = <<BAN
|
12
|
+
Removes a dataset from an MiGA project.
|
13
|
+
|
14
|
+
Usage: #{$0} #{File.basename(__FILE__)} [options]
|
15
|
+
BAN
|
16
|
+
opt.separator ""
|
17
|
+
opt.on("-P", "--project PATH",
|
18
|
+
"(Mandatory) Path to the project to use."){ |v| o[:project]=v }
|
19
|
+
opt.on("-D", "--dataset PATH",
|
20
|
+
"(Mandatory) ID of the dataset to create."){ |v| o[:dataset]=v }
|
21
|
+
opt.on("-r", "--remove",
|
22
|
+
"Also remove all associated files.",
|
23
|
+
"By default, only unlinks from metadata."){ o[:remove]=true }
|
24
|
+
opt.on("-v", "--verbose",
|
25
|
+
"Print additional information to STDERR."){ o[:q]=false }
|
26
|
+
opt.on("-d", "--debug INT", "Print debugging information to STDERR.") do |v|
|
27
|
+
v.to_i>1 ? MiGA::MiGA.DEBUG_TRACE_ON : MiGA::MiGA.DEBUG_ON
|
28
|
+
end
|
29
|
+
opt.on("-h", "--help", "Display this screen.") do
|
30
|
+
puts opt
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
opt.separator ""
|
34
|
+
end.parse!
|
35
|
+
|
36
|
+
|
37
|
+
### MAIN
|
38
|
+
raise "-P is mandatory." if o[:project].nil?
|
39
|
+
raise "-D is mandatory." if o[:dataset].nil?
|
40
|
+
|
41
|
+
$stderr.puts "Loading project." unless o[:q]
|
42
|
+
p = MiGA::Project.load(o[:project])
|
43
|
+
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
44
|
+
|
45
|
+
$stderr.puts "Unlinking dataset." unless o[:q]
|
46
|
+
raise "Dataset doesn't exist, aborting." unless
|
47
|
+
MiGA::Dataset.exist?(p, o[:dataset])
|
48
|
+
d = p.unlink_dataset(o[:dataset])
|
49
|
+
d.remove! if o[:remove]
|
50
|
+
|
51
|
+
$stderr.puts "Done." unless o[:q]
|
52
|
+
|
data/bin/miga
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# @package MiGA
|
4
|
+
# @author Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>
|
5
|
+
# @license artistic license 2.0
|
6
|
+
# @update Oct-01-2015
|
7
|
+
#
|
8
|
+
|
9
|
+
$:.push File.expand_path("../lib", File.dirname(__FILE__))
|
10
|
+
|
11
|
+
require "optparse"
|
12
|
+
require "miga"
|
13
|
+
|
14
|
+
execs = Dir[File.expand_path("../actions/*",
|
15
|
+
File.dirname(__FILE__))].map{ |b| File.basename b }
|
16
|
+
|
17
|
+
if %w{-v --version}.include? ARGV[0]
|
18
|
+
puts MiGA::MiGA.VERSION
|
19
|
+
elsif %w{-V --long-version}.include? ARGV[0]
|
20
|
+
puts MiGA::MiGA.LONG_VERSION
|
21
|
+
elsif %w{-C --citation}.include? ARGV[0]
|
22
|
+
puts MiGA::MiGA.CITATION
|
23
|
+
elsif execs.include? ARGV[0]
|
24
|
+
task = ARGV.shift
|
25
|
+
ARGV << "-h" if ARGV.empty?
|
26
|
+
begin
|
27
|
+
load File.expand_path("../actions/" + task, File.dirname(__FILE__))
|
28
|
+
rescue => err
|
29
|
+
$stderr.puts "Exception: #{err}\n\n"
|
30
|
+
err.backtrace.each { |l| $stderr.puts l + "\n" }
|
31
|
+
err
|
32
|
+
end
|
33
|
+
else
|
34
|
+
print <<HELP.gsub /^ /,""
|
35
|
+
Microbial Genomes Atlas.
|
36
|
+
|
37
|
+
Usage: #{$0} {action} [options]
|
38
|
+
|
39
|
+
actions:#{ execs.map{ |e| "\n #{e}"}.join }
|
40
|
+
|
41
|
+
generic options:
|
42
|
+
-h, --help Display this screen.
|
43
|
+
-v, --version Show MiGA version.
|
44
|
+
-V, --long-version Show complete MiGA version.
|
45
|
+
-C, --citation How to cite MiGA.
|
46
|
+
HELP
|
47
|
+
end
|
48
|
+
|