|
13 | 13 | from qiita_ware.demux import stats as demux_stats |
14 | 14 | from qiita_ware.dispatchable import submit_to_ebi |
15 | 15 | 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) |
17 | 19 | from qiita_db.study import Study |
18 | 20 | from qiita_db.exceptions import QiitaDBUnknownIDError |
19 | 21 | from qiita_pet.handlers.base_handlers import BaseHandler |
@@ -58,11 +60,33 @@ def display_template(self, preprocessed_data_id, msg, msg_level): |
58 | 60 | stats.append(('Number of sequences', demux_file_stats.n)) |
59 | 61 | msg_level = 'success' |
60 | 62 |
|
| 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 | + |
61 | 83 | self.render('ebi_submission.html', |
62 | 84 | study_title=study.title, stats=stats, message=msg, |
63 | 85 | study_id=study.id, level=msg_level, |
64 | 86 | 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) |
66 | 90 |
|
67 | 91 | @authenticated |
68 | 92 | def get(self, preprocessed_data_id): |
|
0 commit comments