miga-base 0.7.11.0 → 0.7.13.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b4a168130d732c670246cd4a874272e77e5f7d88fdef00e10d81ab8e5f9979a
4
- data.tar.gz: '069e2dd280b4afecb67478612f1dee35bf2cada3ae57cbc61c6e70d0ef3bd233'
3
+ metadata.gz: 3065d52418e9cc788496eddd1ae050c91645bfe1c1cf55c18950cf764046d8fc
4
+ data.tar.gz: c4b5b51569ab2b213dcdc4e956f36adf455074aeae372eab90115d1c0fa1d3f7
5
5
  SHA512:
6
- metadata.gz: a37fd7d69339c7a63d5ac38e0c232fed96d479c3f2f2bc67b2ee956bb908d8690a55f21a6fa0185c05f209139e16b6b2ddcd6b0f36fac471f9e0b4fd2c4a5f04
7
- data.tar.gz: cb156656c79f1a765281f163691650e32f90056dc767827d4b3fe958b4042e6359b810f5a3249c6902bce042f6a457507a027836797c39328889d9cbbbc5c5d0
6
+ metadata.gz: 25fa750649f05083834a71d84efa8fd036cd3590f0f311cb158da748f6d78ad387eba6351af24a7c2f485f7d97f4af9cc7fc2eca615ae483f8ee052c8a001806
7
+ data.tar.gz: bbe8c5e2bc8630e44fb195704a91b7d7a95401e2fee7933982a775d1c6e1a28868f773a60369c4ca087fe427349ffcc780515f528bff522fbb0cbf008c51f4ae
@@ -0,0 +1,241 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'miga/cli/action'
4
+
5
+ # Action: miga browse
6
+ class MiGA::Cli::Action::Browse < MiGA::Cli::Action
7
+ def parse_cli
8
+ cli.parse do |opt|
9
+ cli.defaults = { open: true }
10
+ cli.opt_object(opt, [:project])
11
+ end
12
+ end
13
+
14
+ def perform
15
+ p = cli.load_project
16
+ create_empty_page(p)
17
+ generate_project_page(p)
18
+ say 'Creating dataset pages'
19
+ cli.load_project.each_dataset do |d|
20
+ generate_dataset_page(p, d)
21
+ end
22
+ generate_datasets_index(p)
23
+ say "Open in your browser: #{File.join(p.path, 'index.html')}"
24
+ end
25
+
26
+ private
27
+
28
+ ##
29
+ # Create an empty page with necessary assets for project +p+
30
+ def create_empty_page(p)
31
+ say 'Creating project page'
32
+ FileUtils.mkdir_p(browse_file(p, '.'))
33
+ %w[favicon-32.png style.css].each do |i|
34
+ FileUtils.cp(template_file(i), browse_file(p, i))
35
+ end
36
+ write_file(p, 'about.html') do
37
+ build_from_template('about.html', citation: MiGA::MiGA.CITATION)
38
+ end
39
+ end
40
+
41
+ ##
42
+ # Create landing page for project +p+
43
+ def generate_project_page(p)
44
+ # Redirect page
45
+ write_file(p, '../index.html') { build_from_template('redirect.html') }
46
+
47
+ # Summaries
48
+ summaries = Dir["#{p.path}/*.tsv"].map do |i|
49
+ b = File.basename(i, '.tsv')
50
+ generate_summary_page(i, p)
51
+ "<li><a href='s-#{b}.html'>#{format_name(b)}</a></li>"
52
+ end.join('')
53
+
54
+ # Project index page
55
+ data = {
56
+ project_active: 'active',
57
+ information: format_metadata(p),
58
+ summaries: summaries.empty? ? 'None' : "<ul>#{summaries}</ul>",
59
+ results: format_results(p)
60
+ }
61
+ write_file(p, 'index.html') { build_from_template('index.html', data) }
62
+ end
63
+
64
+ ##
65
+ # Create page for the summary +path+ in project +p+
66
+ def generate_summary_page(path, p)
67
+ b = File.basename(path, '.tsv')
68
+ table = '<table class="table table-hover table-responsive">'
69
+ File.open(path, 'r') do |fh|
70
+ fh.each do |ln|
71
+ r = ln.chomp.split("\t")
72
+ if $. == 1
73
+ table += '<thead><tr>' +
74
+ r.map { |i| "<th scope=col>#{format_name(i)}</th>" }.join(' ') +
75
+ '</tr></thead><tbody>'
76
+ else
77
+ table += "<tr><th scope=row>#{r.shift}</th>" +
78
+ r.map { |i| "<td>#{i}</td>" }.join(' ') + "</tr>"
79
+ end
80
+ end
81
+ end
82
+ table += '</tbody></table>'
83
+ write_file(p, "s-#{b}.html") do
84
+ build_from_template(
85
+ 'summary.html', file: "#{b}.tsv", name: format_name(b), table: table
86
+ )
87
+ end
88
+ end
89
+
90
+ ##
91
+ # Create page for dataset +d+ within project +p+
92
+ def generate_dataset_page(p, d)
93
+ data = {
94
+ unmiga_name: d.name.unmiga_name,
95
+ information: format_metadata(d),
96
+ results: format_results(d)
97
+ }
98
+ write_file(p, "d_#{d.name}.html") do
99
+ build_from_template('dataset.html', data)
100
+ end
101
+ end
102
+
103
+ ##
104
+ # Create pages for reference and query dataset indexes
105
+ def generate_datasets_index(p)
106
+ say 'Creating index pages'
107
+ data = format_dataset_index(p)
108
+ data.each do |k, v|
109
+ write_file(p, "#{k}_datasets.html") do
110
+ v[:list] = 'None' if v[:list] == ''
111
+ build_from_template(
112
+ 'datasets.html',
113
+ v.merge(:"#{k}_datasets_active" => 'active')
114
+ )
115
+ end
116
+ end
117
+ end
118
+
119
+ def format_dataset_index(p)
120
+ data = {
121
+ ref: { type_name: 'Reference', list: '' },
122
+ qry: { type_name: 'Query', list: '' }
123
+ }
124
+ p.each_dataset do |d|
125
+ data[d.ref? ? :ref : :qry][:list] +=
126
+ "<li><a href='d_#{d.name}.html'>#{d.name.unmiga_name}</a></li>"
127
+ end
128
+ data
129
+ end
130
+
131
+ ##
132
+ # Format +obj+ metadata as a table
133
+ def format_metadata(obj)
134
+ '<table class="table table-sm table-responsive">' +
135
+ obj.metadata.data.map do |k, v|
136
+ case k
137
+ when /^run_/, :plugins, :user
138
+ next
139
+ when :web_assembly_gz
140
+ v = "<a href='#{v}'>#{v[0..50]}...</a>"
141
+ when :datasets
142
+ v = v.size
143
+ end
144
+ "<tr><td class='text-right pr-4'><b>#{format_name(k)}</b></td>" \
145
+ "<td>#{v}</td></tr>"
146
+ end.compact.join('') +
147
+ '</table>'
148
+ end
149
+
150
+ ##
151
+ # Format +obj+ results as cards
152
+ def format_results(obj)
153
+ o = ''
154
+ obj.each_result do |key, res|
155
+ links = format_result_links(res)
156
+ stats = format_result_stats(res)
157
+ next unless links || stats
158
+ name = format_name(key)
159
+ url_doc =
160
+ 'http://manual.microbial-genomes.org/part5/workflow#' +
161
+ key.to_s.tr('_', '-')
162
+ o += <<~CARD
163
+ <div class="col-md-6 mb-4">
164
+ <h3>#{name}</h3>
165
+ <div class='border-left p-3'>
166
+ #{stats}
167
+ #{links}
168
+ </div>
169
+ <div class='border-top p-2 bg-light'>
170
+ <a target=_blank href="#{url_doc}" class='p-2'>Learn more</a>
171
+ </div>
172
+ </div>
173
+ CARD
174
+ end
175
+ "<div class='row'>#{o}</div>"
176
+ end
177
+
178
+ def format_name(str)
179
+ str
180
+ .to_s.unmiga_name
181
+ .sub(/^./, &:upcase)
182
+ .gsub(/(Aai|Ani|Ogs|Cds|Ssu| db$| ssu )/, &:upcase)
183
+ .sub(/Haai/, 'hAAI')
184
+ .sub(/Mytaxa/, 'MyTaxa')
185
+ .sub(/ pvalue$/, ' p-value')
186
+ .sub(/contigs$/, 'Contigs')
187
+ end
188
+
189
+ def format_result_links(res)
190
+ links = []
191
+ res.each_file do |key, _|
192
+ name = format_name(key)
193
+ links << "<a href='../#{res.file_path(key, true)}'>#{name}</a><br/>"
194
+ end
195
+ links.empty? ? nil : links.join('')
196
+ end
197
+
198
+ def format_result_stats(res)
199
+ res.stats.map do |k, v|
200
+ v = [v, ''] unless v.is_a? Array
201
+ v[0] = ('%.3g' % v[0]) if v[0].is_a? Float
202
+ "<b>#{format_name(k)}:</b> #{v[0]}#{v[1]}<br/>"
203
+ end.join('') + '<br/>' unless res.stats.empty?
204
+ end
205
+
206
+ ##
207
+ # Write +file+ within the browse folder of project +p+ using the passed
208
+ # block output as content
209
+ def write_file(p, file)
210
+ File.open(browse_file(p, file), 'w') { |fh| fh.print yield }
211
+ end
212
+
213
+ ##
214
+ # Use a +template+ file to generate content with a hash of +data+ over the
215
+ # layout page if +layout+ is true
216
+ def build_from_template(template, data = {}, layout = true)
217
+ cont = File.read(template_file(template)).miga_variables(data)
218
+ return cont unless layout
219
+
220
+ build_from_template(
221
+ 'layout.html',
222
+ data.merge(content: cont, project_name: cli.load_project.name),
223
+ false
224
+ )
225
+ end
226
+
227
+ ##
228
+ # Path to the template browse file
229
+ def template_file(file)
230
+ File.join(
231
+ MiGA::MiGA.root_path,
232
+ 'lib', 'miga', 'cli', 'action', 'browse', file
233
+ )
234
+ end
235
+
236
+ ##
237
+ # Path to the browse file in the project
238
+ def browse_file(p, file)
239
+ File.join(p.path, 'browse', file)
240
+ end
241
+ end
@@ -0,0 +1,31 @@
1
+ <h1 class="h2 border-bottom pt-3 pb-2 mb-3">About MiGA</h1>
2
+ <p>
3
+ MiGA is developed and maintained by
4
+ <a href='https://rodriguez-r.com/'>Luis M. Rodriguez-R</a>.
5
+
6
+ The MiGA codebase is
7
+ <a href='http://code.microbial-genomes.org/miga'>freely available</a> under the
8
+ terms of the terms of the
9
+ <a href='http://code.microbial-genomes.org/miga/blob/master/LICENSE'>Artistic License 2.0</a>.
10
+ </p>
11
+
12
+ <p>
13
+ MiGA is the result of a collaboration between the
14
+ <a href='http://enve-omics.gatech.edu/'>Kostas Lab</a>
15
+ (<a href='http://www.gatech.edu/'>Georgia Institute of Technology</a>) and the
16
+ <a href='http://rdp.cme.msu.edu/'>RDP team</a>
17
+ (<a href='http://cme.msu.edu/'>Center for Microbial Ecology</a>,
18
+ <a href='https://msu.edu/'>Michigan State University</a>).
19
+ The MiGA project is funded by the
20
+ <a href='http://nsf.gov/'>US National Science Foundation</a>
21
+ (Awards <a href='http://nsf.gov/awardsearch/showAward?AWD_ID=1356288'>#1356288</a> &amp;
22
+ <a href='https://xras.xsede.org/public/requests/31162-XSEDE-MCB190042-1190572'>#MCB190042</a>).
23
+ </p>
24
+
25
+ <h1 class="h2 border-bottom pt-3 pb-2 mb-3">Citation</h1>
26
+ If you use MiGA in your work, consider citing:
27
+ <blockquote class='border-left p-3'>
28
+ {{citation}}
29
+ </blockquote>
30
+
31
+
@@ -0,0 +1,5 @@
1
+ <h1 class="h2 border-bottom pt-3 pb-2 mb-3">{{unmiga_name}}</h1>
2
+ {{information}}
3
+
4
+ <h1 class="h2 border-bottom pt-3 pb-2 mb-3">Results</h1>
5
+ {{results}}
@@ -0,0 +1,3 @@
1
+ <li class="nav-item">
2
+ <a class="nav-link" href="ds_{{name}}.html">{{unmiga_name}}</a>
3
+ </li>
@@ -0,0 +1,4 @@
1
+ <h1 class="h2 border-bottom pt-3 pb-2 mb-3">{{type_name}} Datasets</h1>
2
+ <ul>
3
+ {{list}}
4
+ </ul>
@@ -0,0 +1,8 @@
1
+ <h1 class="h2 border-bottom pt-3 pb-2 mb-3">Project Information</h1>
2
+ {{information}}
3
+
4
+ <h1 class="h2 border-bottom pt-3 pb-2 mb-3">Summaries</h1>
5
+ {{summaries}}
6
+
7
+ <h1 class="h2 border-bottom pt-3 pb-2 mb-3">Project Results</h1>
8
+ {{results}}
@@ -0,0 +1,57 @@
1
+ <!doctype html>
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <title>MiGA | {{project_name}}</title>
5
+
6
+ <!-- Remote assets -->
7
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
8
+ <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
10
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
11
+
12
+ <!-- Local assets -->
13
+ <link href="style.css" rel="stylesheet">
14
+ <link rel="icon" href="favicon-32.png" sizes="32x32" type="image/png">
15
+ </head>
16
+ <body>
17
+ <nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
18
+ <a class="navbar-brand col-md-12 col-lg-12 mr-0 px-3"
19
+ href="index.html">MiGA | {{project_name}}</a>
20
+ <button class="navbar-toggler position-absolute d-md-none collapsed"
21
+ type="button" data-toggle="collapse" data-target="#sidebarMenu"
22
+ aria-controls="sidebarMenu" aria-expanded="false"
23
+ aria-label="Toggle navigation">
24
+ <span class="navbar-toggler-icon"></span>
25
+ </button>
26
+ </nav>
27
+ <div class="container-fluid">
28
+ <div class="row">
29
+ <nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
30
+ <div class="sidebar-sticky pt-3">
31
+ <ul class="nav flex-column">
32
+ <li class="nav-item">
33
+ <a class="nav-link {{project_active}}" href="index.html">Project</a>
34
+ </li>
35
+ <li class="nav-item">
36
+ <a class="nav-link {{ref_datasets_active}}"
37
+ href="ref_datasets.html">Reference datasets</a>
38
+ </li>
39
+ <li class="nav-item">
40
+ <a class="nav-link {{qry_datasets_active}}"
41
+ href="qry_datasets.html">Query datasets</a>
42
+ </li>
43
+ <li class="nav-item border-top mt-4">
44
+ <a class="nav-link {{about_miga_active}}"
45
+ href="about.html">About MiGA</a>
46
+ </li>
47
+ </ul>
48
+ </div>
49
+ </nav>
50
+
51
+ <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
52
+ {{content}}
53
+ </main>
54
+ </div>
55
+ </div>
56
+ </body>
57
+
@@ -0,0 +1,11 @@
1
+ <!doctype html>
2
+ <head>
3
+ <title>MiGA Project</title>
4
+ <meta http-equiv = "refresh" content = "1; url = browse/index.html" />
5
+ </head>
6
+ <body>
7
+ <div style='font-size:200%; margin-top: 5em; text-align: center;'>
8
+ Redirecting to <a href='browse/index.html'>Project page</a>...
9
+ </div>
10
+ </body>
11
+
@@ -0,0 +1,97 @@
1
+ body {
2
+ font-size: .875rem;
3
+ }
4
+
5
+ /*
6
+ * Sidebar
7
+ */
8
+
9
+ .sidebar {
10
+ position: fixed;
11
+ top: 0;
12
+ bottom: 0;
13
+ left: 0;
14
+ z-index: 100; /* Behind the navbar */
15
+ padding: 48px 0 0; /* Height of navbar */
16
+ box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
17
+ }
18
+
19
+ @media (max-width: 767.98px) {
20
+ .sidebar {
21
+ top: 3rem;
22
+ }
23
+ }
24
+
25
+ .sidebar-sticky {
26
+ position: relative;
27
+ top: 0;
28
+ height: calc(100vh - 48px);
29
+ padding-top: .5rem;
30
+ overflow-x: hidden;
31
+ overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
32
+ }
33
+
34
+ @supports ((position: -webkit-sticky) or (position: sticky)) {
35
+ .sidebar-sticky {
36
+ position: -webkit-sticky;
37
+ position: sticky;
38
+ }
39
+ }
40
+
41
+ .sidebar .nav-link {
42
+ font-weight: 500;
43
+ color: #333;
44
+ }
45
+
46
+ .sidebar .nav-link .feather {
47
+ margin-right: 4px;
48
+ color: #999;
49
+ }
50
+
51
+ .sidebar .nav-link.active {
52
+ color: #007bff;
53
+ }
54
+
55
+ .sidebar .nav-link:hover .feather,
56
+ .sidebar .nav-link.active .feather {
57
+ color: inherit;
58
+ }
59
+
60
+ .sidebar-heading {
61
+ font-size: .75rem;
62
+ text-transform: uppercase;
63
+ }
64
+
65
+ /*
66
+ * Navbar
67
+ */
68
+
69
+ .navbar-brand {
70
+ padding-top: .75rem;
71
+ padding-bottom: .75rem;
72
+ font-size: 1rem;
73
+ background-color: rgba(0, 0, 0, .25);
74
+ box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
75
+ }
76
+
77
+ .navbar .navbar-toggler {
78
+ top: .25rem;
79
+ right: 1rem;
80
+ }
81
+
82
+ .navbar .form-control {
83
+ padding: .75rem 1rem;
84
+ border-width: 0;
85
+ border-radius: 0;
86
+ }
87
+
88
+ .form-control-dark {
89
+ color: #fff;
90
+ background-color: rgba(255, 255, 255, .1);
91
+ border-color: rgba(255, 255, 255, .1);
92
+ }
93
+
94
+ .form-control-dark:focus {
95
+ border-color: transparent;
96
+ box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
97
+ }
@@ -0,0 +1,5 @@
1
+ <h1 class="h2 border-bottom pt-3 pb-2 mb-3">Summary: {{name}}</h1>
2
+ <p class='m-2 mb-3'>
3
+ Based on <a href='../{{file}}'>{{file}}</a>
4
+ </p>
5
+ {{table}}
@@ -27,10 +27,13 @@ class MiGA::Cli::Action::DerepWf < MiGA::Cli::Action
27
27
  '--threshold FLOAT', Float,
28
28
  "Metric threshold (%) to dereplicate. By default: #{cli[:threshold]}"
29
29
  ) { |v| cli[:threshold] = v }
30
+ opt.on(
31
+ '--quality',
32
+ 'Use genome with highest quality as clade representatives (default)'
33
+ ) { |v| cli[:criterion] = :quality }
30
34
  opt.on(
31
35
  '--medoids',
32
- 'Use medoids as clade representatives',
33
- 'By default: Use genome with the highest quality'
36
+ 'Use medoids as clade representatives'
34
37
  ) { |v| cli[:criterion] = :medoids }
35
38
  opt.on(
36
39
  '--no-collection',
@@ -47,12 +50,18 @@ class MiGA::Cli::Action::DerepWf < MiGA::Cli::Action
47
50
 
48
51
  def perform
49
52
  # Input data
50
- p = create_project(:assembly,
51
- { run_project_stats: false, run_clades: false,
52
- gsp_metric: cli[:metric], :"gsp_#{cli[:metric]}" => cli[:threshold] },
53
- { run_mytaxa_scan: false, run_ssu: false })
53
+ p = create_project(
54
+ :assembly,
55
+ {
56
+ run_project_stats: false,
57
+ run_clades: false,
58
+ gsp_metric: cli[:metric],
59
+ :"gsp_#{cli[:metric]}" => cli[:threshold]
60
+ },
61
+ { run_mytaxa_scan: false, run_ssu: false }
62
+ )
54
63
  unless cli[:threshold] >= 0.0 && cli[:threshold] <= 100.0
55
- raise "The threshold of identity must be in the range [0,100]"
64
+ raise 'The threshold of identity must be in the range [0,100]'
56
65
  end
57
66
 
58
67
  # Run
@@ -65,8 +74,8 @@ class MiGA::Cli::Action::DerepWf < MiGA::Cli::Action
65
74
  private
66
75
 
67
76
  def dereplicate(p)
68
- cli.say "Extracting genomospecies clades"
69
- r = p.result(:clade_finding) or raise "Result unavailable: run failed"
77
+ cli.say 'Extracting genomospecies clades'
78
+ r = p.result(:clade_finding) or raise 'Result unavailable: run failed'
70
79
  c_f = r.file_path(:clades_gsp) or raise 'Result incomplete: run failed'
71
80
  clades = File.readlines(c_f).map { |i| i.chomp.split("\t") }
72
81
  rep = representatives(p)
@@ -87,7 +96,7 @@ class MiGA::Cli::Action::DerepWf < MiGA::Cli::Action
87
96
  end
88
97
 
89
98
  def representatives(p)
90
- cli.say "Identifying representatives"
99
+ cli.say 'Identifying representatives'
91
100
  f = File.expand_path('representatives.txt', cli[:outdir])
92
101
  if cli[:criterion] == :medoids
93
102
  FileUtils.cp(p.result(:clade_finding).file_path(:medoids_gsp), f)
@@ -169,6 +169,7 @@ module MiGA::Cli::Action::Wf
169
169
  '--tab', '--ref', '--active'
170
170
  ])
171
171
  end
172
+ call_cli(['browse', '-P', cli[:outdir]])
172
173
  end
173
174
 
174
175
  def cleanup
@@ -11,39 +11,40 @@ module MiGA::Cli::Base
11
11
  preproc_wf: 'Preprocess input genomes or metagenomes',
12
12
  index_wf: 'Generate distance indexing of input genomes',
13
13
  # Projects
14
- new: 'Creates an empty MiGA project',
15
- about: 'Displays information about a MiGA project',
16
- doctor: 'Performs consistency checks on a MiGA project',
17
- get_db: 'Downloads a pre-indexed database',
14
+ new: 'Create an empty MiGA project',
15
+ about: 'Display information about a MiGA project',
16
+ doctor: 'Perform consistency checks on a MiGA project',
17
+ get_db: 'Download a pre-indexed database',
18
+ browse: 'Explore a project locally using a web browser',
18
19
  # Datasets
19
- add: 'Creates a dataset in a MiGA project',
20
- get: 'Downloads a dataset from public databases into a MiGA project',
21
- ncbi_get: 'Downloads all genomes in a taxon from NCBI into a MiGA project',
22
- rm: 'Removes a dataset from an MiGA project',
23
- find: 'Finds unregistered datasets based on result files',
20
+ add: 'Create a dataset in a MiGA project',
21
+ get: 'Download a dataset from public databases into a MiGA project',
22
+ ncbi_get: 'Download all genomes in a taxon from NCBI into a MiGA project',
23
+ rm: 'Remove a dataset from an MiGA project',
24
+ find: 'Find unregistered datasets based on result files',
24
25
  ln: 'Link datasets (including results) from one project to another',
25
- ls: 'Lists all registered datasets in an MiGA project',
26
- archive: 'Generates a tar-ball with all files from select datasets',
26
+ ls: 'List all registered datasets in an MiGA project',
27
+ archive: 'Generate a tar-ball with all files from select datasets',
27
28
  # Results
28
- add_result: 'Registers a result',
29
- stats: 'Extracts statistics for the given result',
30
- files: 'Lists registered files from the results of a dataset or project',
31
- run: 'Executes locally one step analysis producing the given result',
32
- summary: 'Generates a summary table for the statistics of all datasets',
33
- next_step: 'Returns the next task to run in a dataset or project',
29
+ add_result: 'Register a result',
30
+ stats: 'Extract statistics for the given result',
31
+ files: 'List registered files from the results of a dataset or project',
32
+ run: 'Execute locally one step analysis producing the given result',
33
+ summary: 'Generate a summary table for the statistics of all datasets',
34
+ next_step: 'Return the next task to run in a dataset or project',
34
35
  # Objects (Datasets or Projects)
35
- edit: 'Edits the metadata of a dataset or project',
36
+ edit: 'Edit the metadata of a dataset or project',
36
37
  # System
37
38
  init: 'Initialize MiGA to process new projects',
38
- daemon: 'Controls the daemon of a MiGA project',
39
- lair: 'Controls groups of daemons for several MiGA projects',
40
- date: 'Returns the current date in standard MiGA format',
41
- console: 'Opens an IRB console with MiGA',
39
+ daemon: 'Control the daemon of a MiGA project',
40
+ lair: 'Control groups of daemons for several MiGA projects',
41
+ date: 'Return the current date in standard MiGA format',
42
+ console: 'Open an IRB console with MiGA',
42
43
  # Taxonomy
43
- tax_set: 'Registers taxonomic information for datasets',
44
- tax_test: 'Returns test of taxonomic distributions for query datasets',
45
- tax_index: 'Creates a taxonomy-indexed list of the datasets',
46
- tax_dist: 'Estimates distributions of distance by taxonomy',
44
+ tax_set: 'Register taxonomic information for datasets',
45
+ tax_test: 'Return test of taxonomic distributions for query datasets',
46
+ tax_index: 'Create a taxonomy-indexed list of the datasets',
47
+ tax_dist: 'Estimate distributions of distance by taxonomy',
47
48
  }
48
49
 
49
50
  @@TASK_ALIAS = {
@@ -91,7 +91,8 @@ class MiGA::Daemon < MiGA::MiGA
91
91
  flush!
92
92
  if (loop_i % 12).zero?
93
93
  purge!
94
- recalculate_status!
94
+ # TEMPORARILY DISABLED:
95
+ # recalculate_status!
95
96
  end
96
97
  save_status
97
98
  sleep(latency)
@@ -66,7 +66,7 @@ module MiGA::Dataset::Base
66
66
  @@PREPROCESSING_TASKS = [
67
67
  :raw_reads, :trimmed_reads, :read_quality, :trimmed_fasta,
68
68
  :assembly, :cds, :essential_genes, :ssu, :mytaxa, :mytaxa_scan,
69
- :distances, :taxonomy, :stats
69
+ :taxonomy, :distances, :stats
70
70
  ]
71
71
 
72
72
  ##
@@ -77,7 +77,7 @@ module MiGA::Dataset::Base
77
77
  ##
78
78
  # Tasks to be executed only in datasets that are not multi-organism. These
79
79
  # tasks are ignored for multi-organism datasets or for unknown types.
80
- @@ONLY_NONMULTI_TASKS = [:mytaxa_scan, :distances, :taxonomy]
80
+ @@ONLY_NONMULTI_TASKS = [:mytaxa_scan, :taxonomy, :distances]
81
81
  @@_ONLY_NONMULTI_TASKS_H = Hash[@@ONLY_NONMULTI_TASKS.map { |i| [i, true] }]
82
82
 
83
83
  ##
@@ -81,20 +81,22 @@ class MiGA::Result < MiGA::MiGA
81
81
  end
82
82
 
83
83
  ##
84
- # Directory containing the result
85
- def dir
86
- File.dirname(path)
84
+ # Directory containing the result; by default an absolute path, if
85
+ # +relative+ is true returns the path relative to the parent project
86
+ def dir(relative = false)
87
+ relative ? relative_dir : File.dirname(path)
87
88
  end
88
89
 
89
90
  ##
90
- # Absolute path to the file(s) defined by symbol +k+
91
- def file_path(k)
91
+ # Absolute path to the file(s) defined by symbol +k+, or relative
92
+ # path if +relative+ is true
93
+ def file_path(k, relative = false)
92
94
  k = k.to_sym
93
95
  f = self[:files].nil? ? nil : self[:files][k]
94
96
  return nil if f.nil?
95
- return File.expand_path(f, dir) unless f.is_a? Array
97
+ return File.join(dir(relative), f) unless f.is_a? Array
96
98
 
97
- f.map { |fi| File.expand_path(fi, dir) }
99
+ f.map { |fi| File.join(dir(relative), fi) }
98
100
  end
99
101
 
100
102
  ##
@@ -17,6 +17,12 @@ module MiGA::Result::Stats
17
17
  self[:stats]
18
18
  end
19
19
 
20
+ ##
21
+ # Access the stats entry of results
22
+ def stats
23
+ self[:stats]
24
+ end
25
+
20
26
  private
21
27
 
22
28
  def compute_stats_raw_reads
@@ -145,7 +151,7 @@ module MiGA::Result::Stats
145
151
  source.save
146
152
 
147
153
  # Inactivate low-quality datasets
148
- min_qual = (project.metadata[:min_qual] || 50)
154
+ min_qual = (project.metadata[:min_qual] || 25)
149
155
  if min_qual != 'no' && stats[:quality] < min_qual
150
156
  source.inactivate! 'Low quality genome'
151
157
  end
@@ -8,7 +8,7 @@ module MiGA
8
8
  # - Float representing the major.minor version.
9
9
  # - Integer representing gem releases of the current version.
10
10
  # - Integer representing minor changes that require new version number.
11
- VERSION = [0.7, 11, 0]
11
+ VERSION = [0.7, 13, 1]
12
12
 
13
13
  ##
14
14
  # Nickname for the current major.minor version.
@@ -16,7 +16,7 @@ module MiGA
16
16
 
17
17
  ##
18
18
  # Date of the current gem release.
19
- VERSION_DATE = Date.new(2020, 7, 1)
19
+ VERSION_DATE = Date.new(2020, 7, 31)
20
20
 
21
21
  ##
22
22
  # Reference of MiGA.
@@ -13,17 +13,20 @@ echo -n "" > miga-project.log
13
13
  DS=$(miga ls -P "$PROJECT" --ref --no-multi --active)
14
14
 
15
15
  # Extract values
16
- echo "metric a b value sd n omega" | tr " " "\\t" >miga-project.txt
17
- for i in $DS ; do
18
- echo "SELECT CASE WHEN omega!=0 THEN 'AAI' ELSE 'hAAI_AAI' END," \
19
- " seq1, seq2, aai, sd, n, omega from aai;" \
20
- | sqlite3 "$i.db" | tr "\\|" "\\t" >>miga-project.txt
21
- echo "$i" >> miga-project.log
22
- done
16
+ rm -f miga-project.txt
17
+ (
18
+ echo "metric a b value sd n omega" | tr " " "\\t"
19
+ for i in $DS ; do
20
+ echo "SELECT CASE WHEN omega!=0 THEN 'AAI' ELSE 'hAAI_AAI' END," \
21
+ " seq1, seq2, aai, sd, n, omega from aai;" \
22
+ | sqlite3 "$i.db" | tr "\\|" "\\t"
23
+ echo "$i" >> miga-project.log
24
+ done
25
+ ) | gzip -9c > miga-project.txt.gz
23
26
 
24
27
  # R-ify
25
28
  echo "
26
- aai <- read.table('miga-project.txt', sep='\\t', h=T, as.is=TRUE);
29
+ aai <- read.table(gzfile('miga-project.txt.gz'), sep='\\t', h=T, as.is=TRUE);
27
30
  save(aai, file='miga-project.Rdata');
28
31
  if(sum(aai[,'a'] != aai[,'b']) > 0){
29
32
  h <- hist(aai[aai[,'a'] != aai[,'b'], 'value'], breaks=100, plot=FALSE);
@@ -35,9 +38,6 @@ if(sum(aai[,'a'] != aai[,'b']) > 0){
35
38
  }
36
39
  " | R --vanilla
37
40
 
38
- # Gzip
39
- gzip -9 -f miga-project.txt
40
-
41
41
  # Finalize
42
42
  miga date > "miga-project.done"
43
43
  miga add_result -P "$PROJECT" -r "$SCRIPT" -f
@@ -13,16 +13,19 @@ echo -n "" > miga-project.log
13
13
  DS=$(miga ls -P "$PROJECT" --ref --no-multi --active)
14
14
 
15
15
  # Extract values
16
- echo "metric a b value sd n omega" | tr " " "\\t" >miga-project.txt
17
- for i in $DS ; do
18
- echo "SELECT 'ANI', seq1, seq2, ani, sd, n, omega from ani ;" \
19
- | sqlite3 "$i.db" | tr "\\|" "\\t" >>miga-project.txt
20
- echo "$i" >> miga-project.log
21
- done
16
+ rm -f miga-project.txt
17
+ (
18
+ echo "metric a b value sd n omega" | tr " " "\\t"
19
+ for i in $DS ; do
20
+ echo "SELECT 'ANI', seq1, seq2, ani, sd, n, omega from ani ;" \
21
+ | sqlite3 "$i.db" | tr "\\|" "\\t"
22
+ echo "$i" >> miga-project.log
23
+ done
24
+ ) | gzip -9c > miga-project.txt.gz
22
25
 
23
26
  # R-ify
24
27
  echo "
25
- ani <- read.table('miga-project.txt', sep='\\t', h=T, as.is=TRUE);
28
+ ani <- read.table(gzfile('miga-project.txt.gz'), sep='\\t', h=T, as.is=TRUE);
26
29
  save(ani, file='miga-project.Rdata');
27
30
  if(sum(ani[,'a'] != ani[,'b']) > 0){
28
31
  h <- hist(ani[ani[,'a'] != ani[,'b'], 'value'], breaks=100, plot=FALSE);
@@ -34,9 +37,6 @@ if(sum(ani[,'a'] != ani[,'b']) > 0){
34
37
  }
35
38
  " | R --vanilla
36
39
 
37
- # Gzip
38
- gzip -9 -f miga-project.txt
39
-
40
40
  # Finalize
41
41
  miga date > "miga-project.done"
42
42
  miga add_result -P "$PROJECT" -r "$SCRIPT" -f
@@ -20,7 +20,6 @@ fi
20
20
  TYPE=$(miga ls -P "$PROJECT" -D "$DATASET" -m type | cut -f 2)
21
21
  case "$TYPE" in
22
22
  metagenome|virome)
23
- $CMD -p meta
24
23
  prodigal -a "${DATASET}.faa" -d "${DATASET}.fna" -o "${DATASET}.gff3" \
25
24
  -f gff -q -i "../05.assembly/${DATASET}.LargeContigs.fna" -p meta
26
25
  ;;
@@ -17,30 +17,30 @@ echo -n "" > miga-project.log
17
17
  DS=$(miga ls -P "$PROJECT" --ref --no-multi --active)
18
18
 
19
19
  # Extract values
20
- echo "metric a b value sd n omega" | tr " " "\\t" >miga-project.txt
21
- for i in $DS ; do
22
- echo "SELECT 'hAAI', seq1, seq2, aai, sd, n, omega from aai ;" \
23
- | sqlite3 "$i.db" | tr "\\|" "\\t" >>miga-project.txt
24
- echo "$i" >> miga-project.log
25
- done
20
+ rm -f miga-project.txt
21
+ (
22
+ echo "metric a b value sd n omega" | tr " " "\\t"
23
+ for i in $DS ; do
24
+ echo "SELECT 'hAAI', seq1, seq2, aai, sd, n, omega from aai ;" \
25
+ | sqlite3 "$i.db" | tr "\\|" "\\t"
26
+ echo "$i" >> miga-project.log
27
+ done
28
+ ) | gzip -9c > miga-project.txt.gz
26
29
 
27
30
  # R-ify
28
31
  echo "
29
- haai <- read.table('miga-project.txt', sep='\\t', h=T, as.is=TRUE);
32
+ haai <- read.table(gzfile('miga-project.txt.gz'), sep='\\t', h=T, as.is=TRUE);
30
33
  save(haai, file='miga-project.Rdata');
31
34
  if(sum(haai[,'a'] != haai[,'b']) > 0){
32
35
  h <- hist(haai[haai[,'a'] != haai[,'b'], 'value'], breaks=100, plot=FALSE);
33
36
  write.table(
34
37
  cbind(h[['breaks']][-length(h[['breaks']])],
35
- h[['breaks']][-1],h[['counts']]),
38
+ h[['breaks']][-1], h[['counts']]),
36
39
  file='miga-project.hist', quote=FALSE, sep='\\t',
37
40
  col.names=FALSE, row.names=FALSE);
38
41
  }
39
42
  " | R --vanilla
40
43
 
41
- # Gzip
42
- gzip -9 -f miga-project.txt
43
-
44
44
  # Finalize
45
45
  miga date > "miga-project.done"
46
46
  miga add_result -P "$PROJECT" -r "$SCRIPT" -f
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.7.11.0
4
+ version: 0.7.13.1
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: 2020-07-01 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons
@@ -118,6 +118,17 @@ files:
118
118
  - lib/miga/cli/action/add.rb
119
119
  - lib/miga/cli/action/add_result.rb
120
120
  - lib/miga/cli/action/archive.rb
121
+ - lib/miga/cli/action/browse.rb
122
+ - lib/miga/cli/action/browse/about.html
123
+ - lib/miga/cli/action/browse/dataset.html
124
+ - lib/miga/cli/action/browse/dataset_menu_item.html
125
+ - lib/miga/cli/action/browse/datasets.html
126
+ - lib/miga/cli/action/browse/favicon-32.png
127
+ - lib/miga/cli/action/browse/index.html
128
+ - lib/miga/cli/action/browse/layout.html
129
+ - lib/miga/cli/action/browse/redirect.html
130
+ - lib/miga/cli/action/browse/style.css
131
+ - lib/miga/cli/action/browse/summary.html
121
132
  - lib/miga/cli/action/classify_wf.rb
122
133
  - lib/miga/cli/action/console.rb
123
134
  - lib/miga/cli/action/daemon.rb