Skip to content
Merged

Fix 947 #1144

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions qiita_pet/handlers/analysis_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
check_access_to_analysis_result,
filepath_ids_to_rel_paths)
from qiita_db.exceptions import QiitaDBUnknownIDError
from qiita_db.study import Study

SELECT_SAMPLES = 2
SELECT_COMMANDS = 3
Expand Down Expand Up @@ -141,14 +142,17 @@ def get(self, analysis_id):
jobres[jobject.datatype].append((jobject.command[0],
jobject.results))

dropped = {}
dropped_samples = analysis.dropped_samples
dropped = defaultdict(list)
if dropped_samples:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamrp I think you suggested that this if statement can be removed. However, analysis.dropped_samples returns None if there are no dropped samples, instead of an empty list. This will make the call to viewitems to fail because of an AttributeError.

I think this should not block this PR and we should open a new issue for modifying analysis.dropped_samples so it returns consistent types (list). Do you agree?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed -- thanks for pointing that out, I didn't look carefully at analysis.dropped_samples before commenting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! New issue created: #1152

for proc_data_id, samples in viewitems(dropped_samples):
if not samples:
continue
proc_data = ProcessedData(proc_data_id)
key = "Data type %s, Study: %s" % (proc_data.data_type(),
proc_data.study)
dropped[key] = samples
data_type = proc_data.data_type()
study = proc_data.study
dropped[data_type].append((Study(study).title, len(samples),
', '.join(samples)))

self.render("analysis_results.html",
jobres=jobres, aname=analysis.name, dropped=dropped,
Expand Down
60 changes: 38 additions & 22 deletions qiita_pet/templates/analysis_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,60 @@


<div class="row">
<h1>Analysis {{aname}}</h1>

{% if dropped %}
<h3>Dropped Samples</h3>
These samples were dropped during processing due to rarefaction:
<table width="100%">
{% for study, samples in viewitems(dropped) %}
<tr>
<td width="5%">For {{study}}:</td>
<td width="80%"><small>{{', '.join(samples)}}</small></td>
</tr>
{% end %}
</table>
<br/>
{% end %}
<h1>&nbsp;Analysis: <u>{{aname}}</u></h1>
</div>


<div class="row" width='100%'>
<div class="col-md-12">
<div class="panel-group" id="accordion">
{% if dropped %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#dropped-samples">Dropped Samples</a></h3>
</div>
<div id="dropped-samples" class="panel-collapse collapse">
<div class="panel-body">
{% for data_type, studies in viewitems(dropped) %}
<b><u>{{data_type}}</u></b>
<br/><br/>
{% for title, num_samples, samples in studies %}
<b>{{title}}:</b>
<br/>
Total dropped: {{num_samples}}
<br/>
{{samples}}<br/>
{% end %}
<hr>
{% end %}
</div>
</div>
</div>
{% end %}
</div>
</div>
</div>

<div class="row" width='100%'>
<div class="col-md-2">
<div class="panel-group" id="accordion">
{% for data_type, jobs in jobres.items() %}
{% for data_type, jobs in jobres.items() %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#{{data_type}}">{{data_type}}</a></h3>
</div>
<div id="{{data_type}}" class="panel-collapse collapse">
{% for job, results in jobs%}
{% for job, results in jobs%}
<div class="panel-body">
{{job}}<br />
{% if len(results) == 0 %}
{% if len(results) == 0 %}
<h3 style="color:red">ERROR</h3>
{% end %}
{%for result in results%}
{% end %}
{%for result in results%}
<a href='{{"/results/%s" % result}}' target="resframe">{{basename(result)}}</a><br />
{% end %}
{% end %}
</div>
{% end %}
{% end %}
</div>
</div>
{% end %}
Expand Down