Skip to content

Commit 9e360d8

Browse files
committed
Disabling preprocessing if there are missing columns
1 parent 8a9817d commit 9e360d8

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

qiita_db/metadata_template/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
from .prep_template import PrepTemplate
1111
from .util import load_template_to_dataframe
1212
from .constants import (TARGET_GENE_DATA_TYPES, SAMPLE_TEMPLATE_COLUMNS,
13-
PREP_TEMPLATE_COLUMNS)
13+
PREP_TEMPLATE_COLUMNS,
14+
PREP_TEMPLATE_COLUMNS_TARGET_GENE)
1415

1516

1617
__all__ = ['SampleTemplate', 'PrepTemplate', 'load_template_to_dataframe',
1718
'TARGET_GENE_DATA_TYPES', 'SAMPLE_TEMPLATE_COLUMNS',
18-
'PREP_TEMPLATE_COLUMNS']
19+
'PREP_TEMPLATE_COLUMNS', 'PREP_TEMPLATE_COLUMNS_TARGET_GENE']

qiita_pet/templates/study_description_templates/prep_template_panel.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ <h4 class="panel-title">
8888
<br/>
8989
{% if not preprocessed_data or preprocessing_status.startswith('failed') %}
9090
{% if study_status == 'sandbox' %}
91-
<a class="btn btn-primary glyphicon glyphicon-play" data-toggle="modal" data-target="#preprocess-modal-view-{{prep_id}}" style="word-spacing: -10px;"> Preprocess</a>
91+
{% if show_preprocess_btn %}
92+
<a class="btn btn-primary glyphicon glyphicon-play" data-toggle="modal" data-target="#preprocess-modal-view-{{prep_id}}" style="word-spacing: -10px;"> Preprocess</a>
93+
{% else %}
94+
<b>{{ no_preprocess_msg }}</b>
95+
{% end %}
9296
{% end %}
9397
<br>
9498
<i>Status:</i> {{preprocessing_status}}

qiita_pet/templates/study_description_templates/raw_data_editor_tab.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h4>Add prep template to this raw data</h4>
7373
<h4>Prep templates uploaded</h4>
7474
<div class="panel-group" id="prep-accordion-{{raw_data_id}}">
7575
{% for prep in available_prep_templates %}
76-
{% module PrepTemplatePanel(prep, study_id, is_editable, ena_terms, study_status, user_defined_terms) %}
76+
{% module PrepTemplatePanel(prep, study_id, is_editable, ena_terms, study_status, user_defined_terms, raw_data_files) %}
7777
{% end %}
7878
</div>
7979
</td>

qiita_pet/uimodules/raw_data_tab.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
from qiita_db.study import Study
1717
from qiita_db.data import RawData
1818
from qiita_db.ontology import Ontology
19-
from qiita_db.metadata_template import PrepTemplate
19+
from qiita_db.metadata_template import (PrepTemplate, TARGET_GENE_DATA_TYPES,
20+
PREP_TEMPLATE_COLUMNS_TARGET_GENE)
2021
from qiita_db.parameters import (Preprocessed454Params,
2122
PreprocessedIlluminaParams)
2223
from qiita_pet.util import STATUS_STYLER
@@ -166,7 +167,7 @@ def render(self, study, raw_data, full_access):
166167

167168
class PrepTemplatePanel(BaseUIModule):
168169
def render(self, prep, study_id, is_editable, ena_terms,
169-
study_status, user_defined_terms):
170+
study_status, user_defined_terms, raw_data_files):
170171
# Check if the request came from a local source
171172
is_local_request = self._is_local()
172173

@@ -203,6 +204,23 @@ def render(self, prep, study_id, is_editable, ena_terms,
203204
if 'qiime' in basename(fp) else "Prep template")
204205
filepaths = [(id_, fp, _fp_type(fp)) for id_, fp in filepaths]
205206

207+
# Check if the template have all the required columns for preprocessing
208+
if prep.data_type() in TARGET_GENE_DATA_TYPES:
209+
key = ('demultiplex_multiple' if len(raw_data_files) > 2
210+
else 'demultiplex')
211+
missing_cols = prep.check_restrictions(
212+
[PREP_TEMPLATE_COLUMNS_TARGET_GENE[key]])
213+
show_preprocess_btn = len(missing_cols) == 0
214+
if not show_preprocess_btn:
215+
no_preprocess_msg = (
216+
"Preprocessing disabled due to missing columns in the "
217+
"prep template: %s" % ', '.join(missing_cols))
218+
else:
219+
no_preprocess_msg = None
220+
else:
221+
show_preprocess_btn = True
222+
no_preprocess_msg = None
223+
206224
return self.render_string(
207225
"study_description_templates/prep_template_panel.html",
208226
prep_id=prep_id,
@@ -220,7 +238,9 @@ def render(self, prep, study_id, is_editable, ena_terms,
220238
ena_terms=ena_terms,
221239
study_status=study_status,
222240
user_defined_terms=user_defined_terms,
223-
preprocess_options=preprocess_options)
241+
preprocess_options=preprocess_options,
242+
show_preprocess_btn=show_preprocess_btn,
243+
no_preprocess_msg=no_preprocess_msg)
224244

225245

226246
class EditInvestigationType(BaseUIModule):

0 commit comments

Comments
 (0)