Skip to content

Commit 8a9817d

Browse files
committed
Disabling EBI submission if there are missing columns
1 parent 0658af2 commit 8a9817d

File tree

3 files changed

+42
-12
lines changed

3 files changed

+42
-12
lines changed

qiita_db/metadata_template/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
from .sample_template import SampleTemplate
1010
from .prep_template import PrepTemplate
1111
from .util import load_template_to_dataframe
12-
from .constants import TARGET_GENE_DATA_TYPES, SAMPLE_TEMPLATE_COLUMNS
12+
from .constants import (TARGET_GENE_DATA_TYPES, SAMPLE_TEMPLATE_COLUMNS,
13+
PREP_TEMPLATE_COLUMNS)
1314

1415

1516
__all__ = ['SampleTemplate', 'PrepTemplate', 'load_template_to_dataframe',
16-
'TARGET_GENE_DATA_TYPES', 'SAMPLE_TEMPLATE_COLUMNS']
17+
'TARGET_GENE_DATA_TYPES', 'SAMPLE_TEMPLATE_COLUMNS',
18+
'PREP_TEMPLATE_COLUMNS']

qiita_pet/handlers/study_handlers/ebi_handlers.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
from qiita_ware.demux import stats as demux_stats
1414
from qiita_ware.dispatchable import submit_to_ebi
1515
from qiita_db.data import PreprocessedData
16-
from qiita_db.metadata_template import PrepTemplate, SampleTemplate
16+
from qiita_db.metadata_template import (PrepTemplate, SampleTemplate,
17+
SAMPLE_TEMPLATE_COLUMNS,
18+
PREP_TEMPLATE_COLUMNS)
1719
from qiita_db.study import Study
1820
from qiita_db.exceptions import QiitaDBUnknownIDError
1921
from qiita_pet.handlers.base_handlers import BaseHandler
@@ -58,11 +60,33 @@ def display_template(self, preprocessed_data_id, msg, msg_level):
5860
stats.append(('Number of sequences', demux_file_stats.n))
5961
msg_level = 'success'
6062

63+
# Check if the templates have all the required columns for EBI
64+
pt_missing_cols = prep_template.check_restrictions(
65+
[PREP_TEMPLATE_COLUMNS['EBI']])
66+
st_missing_cols = sample_template.check_restrictions(
67+
[SAMPLE_TEMPLATE_COLUMNS['EBI']])
68+
allow_submission = (len(pt_missing_cols) == 0 and
69+
len(st_missing_cols) == 0)
70+
71+
if not allow_submission:
72+
msg_list = ["Submission to EBI disabled due to missing columns:"]
73+
if len(pt_missing_cols) > 0:
74+
msg_list.append("Columns missing in prep template: %s"
75+
% ', '.join(pt_missing_cols))
76+
if len(st_missing_cols) > 0:
77+
msg_list.append("Columns missing in sample template: %s"
78+
% ', '.join(st_missing_cols))
79+
ebi_disabled_msg = "<br/>".join(msg_list)
80+
else:
81+
ebi_disabled_msg = None
82+
6183
self.render('ebi_submission.html',
6284
study_title=study.title, stats=stats, message=msg,
6385
study_id=study.id, level=msg_level,
6486
preprocessed_data_id=preprocessed_data_id,
65-
investigation_type=prep_template.investigation_type)
87+
investigation_type=prep_template.investigation_type,
88+
allow_submission=allow_submission,
89+
ebi_disabled_msg=ebi_disabled_msg)
6690

6791
@authenticated
6892
def get(self, preprocessed_data_id):

qiita_pet/templates/ebi_submission.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ <h1>Submission summary for study: <b>{{study_title}}</b></h1>
2828
<br/><br/>
2929
{% if investigation_type %}
3030
{% if level != 'danger' and maintenance is None %}
31-
<br/>
32-
What kind of submission do you want to do?
33-
<select name="submission_type">
34-
<option value="ADD">ADD</option>
35-
<option value="MODIFY">MODIFY</option>
36-
</select>
37-
<br/><br/>
38-
<input type="submit" class="btn btn-primary" value="Submit to EBI">
31+
{% if allow_submission %}
32+
<br/>
33+
What kind of submission do you want to do?
34+
<select name="submission_type">
35+
<option value="ADD">ADD</option>
36+
<option value="MODIFY">MODIFY</option>
37+
</select>
38+
<br/><br/>
39+
<input type="submit" class="btn btn-primary" value="Submit to EBI">
40+
{% else %}
41+
<b>{% raw ebi_disabled_msg %}
42+
{% end %}
3943
{% end %}
4044
{% else %}
4145
<b>You need to set an investigation type to continue!</b>

0 commit comments

Comments
 (0)