From ac61f74376da2755c478acb210914a60de03317d Mon Sep 17 00:00:00 2001 From: Jose Navas Date: Wed, 7 Oct 2015 12:14:02 -0700 Subject: [PATCH 1/8] Removing EBI info from preprocessed data tab, adding it to study description tab and all qiita pet tests passing again --- .../preprocessed_data_info_tab.html | 3 --- .../study_information_tab.html | 2 ++ qiita_pet/uimodules/preprocessed_data_tab.py | 6 ------ qiita_pet/uimodules/study_information_tab.py | 8 +++++++- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/qiita_pet/templates/study_description_templates/preprocessed_data_info_tab.html b/qiita_pet/templates/study_description_templates/preprocessed_data_info_tab.html index 17669f0f0..237f9ba27 100644 --- a/qiita_pet/templates/study_description_templates/preprocessed_data_info_tab.html +++ b/qiita_pet/templates/study_description_templates/preprocessed_data_info_tab.html @@ -79,9 +79,6 @@
Prep template
- EBI status: {{ebi_status}}
- EBI study accession: {{ebi_study_accession}}
- EBI submission accession: {{ebi_submission_accession}}
VAMPS status: {{vamps_status}}
{% module EditInvestigationType(ena_terms, user_defined_terms, prep_template_id, inv_type, ppd_id) %} {% if show_ebi_btn %} diff --git a/qiita_pet/templates/study_description_templates/study_information_tab.html b/qiita_pet/templates/study_description_templates/study_information_tab.html index 07c011f76..9ee048c3a 100644 --- a/qiita_pet/templates/study_description_templates/study_information_tab.html +++ b/qiita_pet/templates/study_description_templates/study_information_tab.html @@ -8,6 +8,8 @@ Principal investigator: {% raw principal_investigator %}
Samples: {{number_samples_promised}}/{{number_samples_collected}}
Metadata: {{metadata_complete}}
+ EBI status: {{ebi_status}}
+ EBI accession: {{ebi_accession}}

diff --git a/qiita_pet/uimodules/preprocessed_data_tab.py b/qiita_pet/uimodules/preprocessed_data_tab.py index 0bf951cea..6fe687ff8 100644 --- a/qiita_pet/uimodules/preprocessed_data_tab.py +++ b/qiita_pet/uimodules/preprocessed_data_tab.py @@ -37,9 +37,6 @@ class PreprocessedDataInfoTab(BaseUIModule): def render(self, study_id, preprocessed_data): user = self.current_user ppd_id = preprocessed_data.id - ebi_status = preprocessed_data.submitted_to_insdc_status() - ebi_study_accession = preprocessed_data.ebi_study_accession - ebi_submission_accession = preprocessed_data.ebi_submission_accession vamps_status = preprocessed_data.submitted_to_vamps_status() filepaths = preprocessed_data.get_filepaths() is_local_request = is_localhost(self.request.headers['host']) @@ -80,9 +77,6 @@ def render(self, study_id, preprocessed_data): "study_description_templates/preprocessed_data_info_tab.html", ppd_id=ppd_id, show_ebi_btn=show_ebi_btn, - ebi_status=ebi_status, - ebi_study_accession=ebi_study_accession, - ebi_submission_accession=ebi_submission_accession, filepaths=filepaths, is_local_request=is_local_request, prep_template_id=prep_template_id, diff --git a/qiita_pet/uimodules/study_information_tab.py b/qiita_pet/uimodules/study_information_tab.py index b0ba15288..2487e9cac 100644 --- a/qiita_pet/uimodules/study_information_tab.py +++ b/qiita_pet/uimodules/study_information_tab.py @@ -62,6 +62,10 @@ def render(self, study): show_select_sample = ( study.status == 'sandbox' or self.current_user.level == 'admin') + # Ebi information + ebi_status = study.ebi_submission_status + ebi_accession = study.ebi_study_accession + return self.render_string( "study_description_templates/study_information_tab.html", abstract=abstract, @@ -77,4 +81,6 @@ def render(self, study): study_id=study.id, sample_templates=sample_templates, is_local_request=is_local_request, - data_types=data_types) + data_types=data_types, + ebi_status=ebi_status, + ebi_accession=ebi_accession) From 464290058a48492ff156e3099e7505bb1a194c64 Mon Sep 17 00:00:00 2001 From: Jose Navas Date: Wed, 7 Oct 2015 13:38:00 -0700 Subject: [PATCH 2/8] Fixing the preprocessed data tab --- .../preprocessed_data_tab.html | 10 ++++++---- qiita_pet/uimodules/preprocessed_data_tab.py | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/qiita_pet/templates/study_description_templates/preprocessed_data_tab.html b/qiita_pet/templates/study_description_templates/preprocessed_data_tab.html index edf4fd091..5f98b13dd 100644 --- a/qiita_pet/templates/study_description_templates/preprocessed_data_tab.html +++ b/qiita_pet/templates/study_description_templates/preprocessed_data_tab.html @@ -5,12 +5,14 @@
  • Add preprocessed data
  • - {% for ppd_id, ppd, (class_icon1, class_icon2, color) in available_preprocessed_data %} -
  • ID: {{ppd_id}}  + {% for ppd_id, ppd, (class_icon1, class_icon2, color), ebi in available_preprocessed_data %} +
  • ID: {{ppd_id}}   + {% if ebi %} EBI {% end %}
    -
  • + + {% end %} @@ -20,7 +22,7 @@ Not implemented! Coming soon...
    - {% for ppd_id, ppd, _ in available_preprocessed_data %} + {% for ppd_id, ppd, _, _ in available_preprocessed_data %} {% module PreprocessedDataInfoTab(study_id, ppd) %} {% end %} diff --git a/qiita_pet/uimodules/preprocessed_data_tab.py b/qiita_pet/uimodules/preprocessed_data_tab.py index 6fe687ff8..c71cffd8f 100644 --- a/qiita_pet/uimodules/preprocessed_data_tab.py +++ b/qiita_pet/uimodules/preprocessed_data_tab.py @@ -23,7 +23,8 @@ class PreprocessedDataTab(BaseUIModule): def render(self, study, full_access): ppd_gen = (PreprocessedData(ppd_id) for ppd_id in study.preprocessed_data()) - avail_ppd = [(ppd.id, ppd, STATUS_STYLER[ppd.status]) + avail_ppd = [(ppd.id, ppd, STATUS_STYLER[ppd.status], + ppd.is_submitted_to_ebi) for ppd in ppd_gen if full_access or ppd.status == 'public'] return self.render_string( From 00d5fd5d0b4a393484462ed2fbcf2e5f6df2fd92 Mon Sep 17 00:00:00 2001 From: Jose Navas Date: Wed, 7 Oct 2015 13:43:32 -0700 Subject: [PATCH 3/8] Adding is_submitted_to_ebi property to prep template --- qiita_db/metadata_template/prep_template.py | 21 +++++++++++++++++++ .../test/test_prep_template.py | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/qiita_db/metadata_template/prep_template.py b/qiita_db/metadata_template/prep_template.py index 78a7a13d7..200db7056 100644 --- a/qiita_db/metadata_template/prep_template.py +++ b/qiita_db/metadata_template/prep_template.py @@ -700,3 +700,24 @@ def ebi_experiment_accessions(self, value): If a sample in `value` already has an accession number """ self._update_accession_numbers('ebi_experiment_accession', value) + + @property + def is_submitted_to_ebi(self): + """Gets if the prep template has been submitted to EBI or not + + Returns + ------- + bool + True if the prep template has been submitted to EBI, + false otherwise + """ + with TRN: + sql = """SELECT EXISTS( + SELECT sample_id, ebi_experiment_accession + FROM qiita.{0} + WHERE {1}=%s + AND ebi_experiment_accession IS NOT NULL) + """.format(self._table, self._id_column) + TRN.add(sql, [self.id]) + is_submitted = TRN.execute_fetchlast() + return is_submitted diff --git a/qiita_db/metadata_template/test/test_prep_template.py b/qiita_db/metadata_template/test/test_prep_template.py index 6cf8769c3..ebab9bc48 100644 --- a/qiita_db/metadata_template/test/test_prep_template.py +++ b/qiita_db/metadata_template/test/test_prep_template.py @@ -1414,6 +1414,12 @@ def f(): pt.ebi_experiment_accessions = exp_acc npt.assert_warns(QiitaDBWarning, f) + def test_is_submitted_to_ebi(self): + self.assertTrue(self.tester.is_submitted_to_ebi) + pt = PrepTemplate.create(self.metadata, self.test_study, + self.data_type) + self.assertFalse(pt.is_submitted_to_ebi) + EXP_PREP_TEMPLATE = ( 'sample_name\tbarcode\tcenter_name\tcenter_project_name\t' From cf66a53a8e60f0b048c404818d8e08a5d771a537 Mon Sep 17 00:00:00 2001 From: Jose Navas Date: Wed, 7 Oct 2015 14:02:43 -0700 Subject: [PATCH 4/8] Showing the EBI 'icon' in the prep template tab --- .../study_description_templates/prep_template_tab.html | 7 ++++--- qiita_pet/uimodules/prep_template_tab.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/qiita_pet/templates/study_description_templates/prep_template_tab.html b/qiita_pet/templates/study_description_templates/prep_template_tab.html index 15849b061..7efbb9683 100644 --- a/qiita_pet/templates/study_description_templates/prep_template_tab.html +++ b/qiita_pet/templates/study_description_templates/prep_template_tab.html @@ -4,9 +4,10 @@
  • Add prep template
  • - {% for pt_id, pt_data_type, _, (class_icon1, class_icon2, color) in available_prep_templates %} + {% for pt_id, pt_data_type, _, (class_icon1, class_icon2, color), ebi in available_prep_templates %}
  • - {{pt_data_type}} (ID: {{pt_id}})  + {{pt_data_type}} (ID: {{pt_id}})   + {% if ebi %} EBI {% end %}
    @@ -72,7 +73,7 @@ - {% for _, _, pt, _ in available_prep_templates %} + {% for _, _, pt, _, _ in available_prep_templates %} {% module PrepTemplateInfoTab(study, pt, full_access, ena_terms, user_defined_terms) %} {% end %} diff --git a/qiita_pet/uimodules/prep_template_tab.py b/qiita_pet/uimodules/prep_template_tab.py index b15070012..7b003edbd 100644 --- a/qiita_pet/uimodules/prep_template_tab.py +++ b/qiita_pet/uimodules/prep_template_tab.py @@ -75,7 +75,8 @@ def _template_generator(study, full_access): for pt_id in sorted(study.prep_templates()): pt = PrepTemplate(pt_id) if full_access or pt.status == 'public': - yield (pt.id, pt.data_type(), pt, STATUS_STYLER[pt.status]) + yield (pt.id, pt.data_type(), pt, STATUS_STYLER[pt.status], + pt.is_submitted_to_ebi) class PrepTemplateTab(BaseUIModule): From a4c1537954ed124ed7421b4014b3c3b43ae4d010 Mon Sep 17 00:00:00 2001 From: Jose Navas Date: Wed, 7 Oct 2015 15:03:59 -0700 Subject: [PATCH 5/8] Adding link to EBI --- .../prep_template_info_tab.html | 7 +++++++ .../preprocessed_data_info_tab.html | 3 +++ .../study_information_tab.html | 2 +- qiita_pet/uimodules/prep_template_tab.py | 9 +++++++-- qiita_pet/uimodules/preprocessed_data_tab.py | 11 +++++++++-- qiita_pet/uimodules/study_information_tab.py | 4 +++- qiita_pet/util.py | 2 ++ 7 files changed, 32 insertions(+), 6 deletions(-) diff --git a/qiita_pet/templates/study_description_templates/prep_template_info_tab.html b/qiita_pet/templates/study_description_templates/prep_template_info_tab.html index e3eabe6ca..f11614f21 100644 --- a/qiita_pet/templates/study_description_templates/prep_template_info_tab.html +++ b/qiita_pet/templates/study_description_templates/prep_template_info_tab.html @@ -61,6 +61,13 @@ {% end %} + {% if ebi_link %} + + + EBI accession: {% raw ebi_link %} + + + {% end %}
    diff --git a/qiita_pet/templates/study_description_templates/preprocessed_data_info_tab.html b/qiita_pet/templates/study_description_templates/preprocessed_data_info_tab.html index 237f9ba27..2c8eb74fe 100644 --- a/qiita_pet/templates/study_description_templates/preprocessed_data_info_tab.html +++ b/qiita_pet/templates/study_description_templates/preprocessed_data_info_tab.html @@ -79,6 +79,9 @@
    Prep template
    + {% if ebi_link %} + EBI accession: {% raw ebi_link %}
    + {% end %} VAMPS status: {{vamps_status}}
    {% module EditInvestigationType(ena_terms, user_defined_terms, prep_template_id, inv_type, ppd_id) %} {% if show_ebi_btn %} diff --git a/qiita_pet/templates/study_description_templates/study_information_tab.html b/qiita_pet/templates/study_description_templates/study_information_tab.html index 9ee048c3a..f5da97960 100644 --- a/qiita_pet/templates/study_description_templates/study_information_tab.html +++ b/qiita_pet/templates/study_description_templates/study_information_tab.html @@ -9,7 +9,7 @@ Samples: {{number_samples_promised}}/{{number_samples_collected}}
    Metadata: {{metadata_complete}}
    EBI status: {{ebi_status}}
    - EBI accession: {{ebi_accession}}
    + EBI accession: {% raw ebi_accession %}

    diff --git a/qiita_pet/uimodules/prep_template_tab.py b/qiita_pet/uimodules/prep_template_tab.py index 7b003edbd..a2a810919 100644 --- a/qiita_pet/uimodules/prep_template_tab.py +++ b/qiita_pet/uimodules/prep_template_tab.py @@ -22,7 +22,7 @@ PREP_TEMPLATE_COLUMNS_TARGET_GENE) from qiita_db.parameters import (Preprocessed454Params, PreprocessedIlluminaParams) -from qiita_pet.util import STATUS_STYLER, is_localhost +from qiita_pet.util import STATUS_STYLER, is_localhost, ebi_linkifier from qiita_pet.handlers.util import download_link_or_path from .base_uimodule import BaseUIModule from qiita_core.util import execute_as_transaction @@ -226,6 +226,10 @@ def render(self, study, prep_template, full_access, ena_terms, preprocessing_status = prep_template.preprocessing_status + ebi_link = None + if prep_template.is_submitted_to_ebi: + ebi_link = ebi_linkifier.format(study.ebi_study_accession) + return self.render_string( "study_description_templates/prep_template_info_tab.html", pt_id=prep_template.id, @@ -250,7 +254,8 @@ def render(self, study, prep_template, full_access, ena_terms, preprocessed_data=preprocessed_data, preprocessing_status=preprocessing_status, show_preprocess_btn=show_preprocess_btn, - no_preprocess_msg=no_preprocess_msg) + no_preprocess_msg=no_preprocess_msg, + ebi_link=ebi_link) class RawDataInfoDiv(BaseUIModule): diff --git a/qiita_pet/uimodules/preprocessed_data_tab.py b/qiita_pet/uimodules/preprocessed_data_tab.py index c71cffd8f..f1a53e4ba 100644 --- a/qiita_pet/uimodules/preprocessed_data_tab.py +++ b/qiita_pet/uimodules/preprocessed_data_tab.py @@ -7,6 +7,7 @@ # ----------------------------------------------------------------------------- from qiita_core.util import execute_as_transaction +from qiita_db.study import Study from qiita_db.data import PreprocessedData from qiita_db.metadata_template import PrepTemplate from qiita_db.ontology import Ontology @@ -15,7 +16,7 @@ from qiita_db.parameters import ProcessedSortmernaParams from .base_uimodule import BaseUIModule from qiita_pet.util import (generate_param_str, STATUS_STYLER, - is_localhost) + is_localhost, ebi_linkifier) class PreprocessedDataTab(BaseUIModule): @@ -74,6 +75,11 @@ def render(self, study_id, preprocessed_data): # so we can initialize the interface default_params = 1 + ebi_link = None + if preprocessed_data.is_submitted_to_ebi: + ebi_link = ebi_linkifier.format( + Study(study_id).ebi_study_accession) + return self.render_string( "study_description_templates/preprocessed_data_info_tab.html", ppd_id=ppd_id, @@ -90,4 +96,5 @@ def render(self, study_id, preprocessed_data): default_params=default_params, study_id=preprocessed_data.study, processing_status=processing_status, - processed_data=processed_data) + processed_data=processed_data, + ebi_link=ebi_link) diff --git a/qiita_pet/uimodules/study_information_tab.py b/qiita_pet/uimodules/study_information_tab.py index 2487e9cac..69a3a7055 100644 --- a/qiita_pet/uimodules/study_information_tab.py +++ b/qiita_pet/uimodules/study_information_tab.py @@ -15,7 +15,7 @@ from qiita_db.util import get_files_from_uploads_folders, get_data_types from qiita_db.study import StudyPerson from qiita_db.metadata_template import SampleTemplate -from qiita_pet.util import linkify, is_localhost +from qiita_pet.util import linkify, is_localhost, ebi_linkifier from .base_uimodule import BaseUIModule @@ -65,6 +65,8 @@ def render(self, study): # Ebi information ebi_status = study.ebi_submission_status ebi_accession = study.ebi_study_accession + if ebi_accession: + ebi_accession = (ebi_linkifier.format(ebi_accession)) return self.render_string( "study_description_templates/study_information_tab.html", diff --git a/qiita_pet/util.py b/qiita_pet/util.py index 1d2d2480d..b9b981722 100644 --- a/qiita_pet/util.py +++ b/qiita_pet/util.py @@ -39,6 +39,8 @@ 'public': ('glyphicon glyphicon-eye-open', 'glyphicon glyphicon-globe', 'green')} +ebi_linkifier = ('{0}') def linkify(link_template, item): """Formats a strings into a URL using string replacement From ae3ec1dc57c41685e5b53dd7eafa81b60e05d3be Mon Sep 17 00:00:00 2001 From: Jose Navas Date: Thu, 8 Oct 2015 09:32:47 -0700 Subject: [PATCH 6/8] As always, pep8ing... --- qiita_pet/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qiita_pet/util.py b/qiita_pet/util.py index b9b981722..cf35a2a81 100644 --- a/qiita_pet/util.py +++ b/qiita_pet/util.py @@ -42,6 +42,7 @@ ebi_linkifier = ('{0}') + def linkify(link_template, item): """Formats a strings into a URL using string replacement From 1b17f81a74a836601bb3748287f3439d2cef142c Mon Sep 17 00:00:00 2001 From: Jose Navas Date: Thu, 8 Oct 2015 09:45:20 -0700 Subject: [PATCH 7/8] Addressing comments --- qiita_db/metadata_template/prep_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiita_db/metadata_template/prep_template.py b/qiita_db/metadata_template/prep_template.py index 200db7056..081a5df74 100644 --- a/qiita_db/metadata_template/prep_template.py +++ b/qiita_db/metadata_template/prep_template.py @@ -703,7 +703,7 @@ def ebi_experiment_accessions(self, value): @property def is_submitted_to_ebi(self): - """Gets if the prep template has been submitted to EBI or not + """Inquires if the prep template has been submitted to EBI or not Returns ------- From b15c95de35d6a557baa7c5b397d3182985cdd8fc Mon Sep 17 00:00:00 2001 From: Jose Navas Date: Thu, 8 Oct 2015 11:11:12 -0700 Subject: [PATCH 8/8] Addressing comments --- qiita_pet/uimodules/prep_template_tab.py | 4 ++-- qiita_pet/uimodules/preprocessed_data_tab.py | 4 ++-- qiita_pet/uimodules/study_information_tab.py | 4 ++-- qiita_pet/util.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qiita_pet/uimodules/prep_template_tab.py b/qiita_pet/uimodules/prep_template_tab.py index a2a810919..ec691dfb7 100644 --- a/qiita_pet/uimodules/prep_template_tab.py +++ b/qiita_pet/uimodules/prep_template_tab.py @@ -22,7 +22,7 @@ PREP_TEMPLATE_COLUMNS_TARGET_GENE) from qiita_db.parameters import (Preprocessed454Params, PreprocessedIlluminaParams) -from qiita_pet.util import STATUS_STYLER, is_localhost, ebi_linkifier +from qiita_pet.util import STATUS_STYLER, is_localhost, EBI_LINKIFIER from qiita_pet.handlers.util import download_link_or_path from .base_uimodule import BaseUIModule from qiita_core.util import execute_as_transaction @@ -228,7 +228,7 @@ def render(self, study, prep_template, full_access, ena_terms, ebi_link = None if prep_template.is_submitted_to_ebi: - ebi_link = ebi_linkifier.format(study.ebi_study_accession) + ebi_link = EBI_LINKIFIER.format(study.ebi_study_accession) return self.render_string( "study_description_templates/prep_template_info_tab.html", diff --git a/qiita_pet/uimodules/preprocessed_data_tab.py b/qiita_pet/uimodules/preprocessed_data_tab.py index f1a53e4ba..c284e3272 100644 --- a/qiita_pet/uimodules/preprocessed_data_tab.py +++ b/qiita_pet/uimodules/preprocessed_data_tab.py @@ -16,7 +16,7 @@ from qiita_db.parameters import ProcessedSortmernaParams from .base_uimodule import BaseUIModule from qiita_pet.util import (generate_param_str, STATUS_STYLER, - is_localhost, ebi_linkifier) + is_localhost, EBI_LINKIFIER) class PreprocessedDataTab(BaseUIModule): @@ -77,7 +77,7 @@ def render(self, study_id, preprocessed_data): ebi_link = None if preprocessed_data.is_submitted_to_ebi: - ebi_link = ebi_linkifier.format( + ebi_link = EBI_LINKIFIER.format( Study(study_id).ebi_study_accession) return self.render_string( diff --git a/qiita_pet/uimodules/study_information_tab.py b/qiita_pet/uimodules/study_information_tab.py index 69a3a7055..902e4b237 100644 --- a/qiita_pet/uimodules/study_information_tab.py +++ b/qiita_pet/uimodules/study_information_tab.py @@ -15,7 +15,7 @@ from qiita_db.util import get_files_from_uploads_folders, get_data_types from qiita_db.study import StudyPerson from qiita_db.metadata_template import SampleTemplate -from qiita_pet.util import linkify, is_localhost, ebi_linkifier +from qiita_pet.util import linkify, is_localhost, EBI_LINKIFIER from .base_uimodule import BaseUIModule @@ -66,7 +66,7 @@ def render(self, study): ebi_status = study.ebi_submission_status ebi_accession = study.ebi_study_accession if ebi_accession: - ebi_accession = (ebi_linkifier.format(ebi_accession)) + ebi_accession = (EBI_LINKIFIER.format(ebi_accession)) return self.render_string( "study_description_templates/study_information_tab.html", diff --git a/qiita_pet/util.py b/qiita_pet/util.py index cf35a2a81..26550647a 100644 --- a/qiita_pet/util.py +++ b/qiita_pet/util.py @@ -39,7 +39,7 @@ 'public': ('glyphicon glyphicon-eye-open', 'glyphicon glyphicon-globe', 'green')} -ebi_linkifier = ('{0}')