Skip to content

Commit

Permalink
Merge b15c95d into ab37a2f
Browse files Browse the repository at this point in the history
  • Loading branch information
josenavas committed Oct 8, 2015
2 parents ab37a2f + b15c95d commit ad1b63d
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 24 deletions.
21 changes: 21 additions & 0 deletions qiita_db/metadata_template/prep_template.py
Expand Up @@ -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):
"""Inquires 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
6 changes: 6 additions & 0 deletions qiita_db/metadata_template/test/test_prep_template.py
Expand Up @@ -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'
Expand Down
Expand Up @@ -61,6 +61,13 @@ <h4 class="modal-title" id="myModalLabel">Choose preprocessing parameters</h4>
{% end %}
</td>
</tr>
{% if ebi_link %}
<tr>
<td>
<b>EBI accession:</b> {% raw ebi_link %}
</td>
</tr>
{% end %}
<tr>
<td style="padding: 5px;">
<a class="btn btn-primary" href="/metadata_summary/?study_id={{study_id}}&prep_template={{pt_id}}">
Expand Down
Expand Up @@ -4,9 +4,10 @@
<!-- Nav tab: adding prep template -->
<li class="active"><a href="#add_prep_template_tab" role="tab" data-toggle="tab">Add prep template</a></li>
<!-- Nav tabs: one for each prep template available -->
{% 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 %}
<li><a href="#prep_template_info_{{pt_id}}" role="tab" data-toggle="tab">
{{pt_data_type}} (ID: {{pt_id}})&nbsp;
{{pt_data_type}} (ID: {{pt_id}})&nbsp;&nbsp;
{% if ebi %} EBI {% end %}
<div class="{{class_icon1}}" style="color: {{color}};"></div>
<div class="{{class_icon2}}" style="color: {{color}};"></div>
<button class="close" title="Remove this prep template" type="button" onclick="delete_prep_template('{{pt_data_type}}', {{pt_id}})">&nbsp; ×</button>
Expand Down Expand Up @@ -72,7 +73,7 @@
</div>

<!-- Show Prep template info tabs -->
{% for _, _, pt, _ in available_prep_templates %}
{% for _, _, pt, _, _ in available_prep_templates %}
{% module PrepTemplateInfoTab(study, pt, full_access, ena_terms, user_defined_terms) %}
{% end %}

Expand Down
Expand Up @@ -79,9 +79,9 @@ <h4 class="modal-title" id="myModalLabel">Choose processing parameters</h4>

<div class="tab-pane" id="preprocessed_data_info_{{ppd_id}}" style="padding: 10px;">
<a href="#" onclick="display_tab('prep_template_tab', {{prep_template_id}});">Prep template</a><br/>
<b>EBI status:</b> {{ebi_status}}<br/>
<b>EBI study accession:</b> {{ebi_study_accession}}<br/>
<b>EBI submission accession:</b> {{ebi_submission_accession}}<br/>
{% if ebi_link %}
<b>EBI accession:</b> {% raw ebi_link %}<br/>
{% end %}
<b>VAMPS status:</b> {{vamps_status}}<br/>
{% module EditInvestigationType(ena_terms, user_defined_terms, prep_template_id, inv_type, ppd_id) %}
{% if show_ebi_btn %}
Expand Down
Expand Up @@ -5,12 +5,14 @@
<!-- Adding a preprocessed data -->
<li class="active"><a href="#add_preprocessed_data_tab" role="tab" data-toggle="tab">Add preprocessed data</a></li>
<!-- Create the tabs for each preprocessed data -->
{% for ppd_id, ppd, (class_icon1, class_icon2, color) in available_preprocessed_data %}
<li><a href="#preprocessed_data_info_{{ppd_id}}" role="tab" data-toggle="tab">ID: {{ppd_id}}&nbsp;
{% for ppd_id, ppd, (class_icon1, class_icon2, color), ebi in available_preprocessed_data %}
<li><a href="#preprocessed_data_info_{{ppd_id}}" role="tab" data-toggle="tab">ID: {{ppd_id}}&nbsp;&nbsp;
{% if ebi %} EBI {% end %}
<div class="{{class_icon1}}" style="color: {{color}};"></div>
<div class="{{class_icon2}}" style="color: {{color}};"></div>
<button class="close" title="Remove this preprocessed data" type="button" onclick="delete_preprocessed_data({{ppd_id}})">&nbsp; ×</button>
</a></li>
</a>
</li>
{% end %}
</ul>
<!-- Create the tab panes -->
Expand All @@ -20,7 +22,7 @@
<b>Not implemented! Coming soon...</b>
</div>
<!-- Create one tab pane for each preprocessed data -->
{% for ppd_id, ppd, _ in available_preprocessed_data %}
{% for ppd_id, ppd, _, _ in available_preprocessed_data %}
{% module PreprocessedDataInfoTab(study_id, ppd) %}
{% end %}
</div>
Expand Down
Expand Up @@ -8,6 +8,8 @@
<b>Principal investigator:</b> {% raw principal_investigator %} <br/>
<b>Samples:</b> {{number_samples_promised}}/{{number_samples_collected}}<br/>
<b>Metadata:</b> {{metadata_complete}} <br/>
<b>EBI status:</b> {{ebi_status}} <br/>
<b>EBI accession:</b> {% raw ebi_accession %} <br/>

<hr>

Expand Down
12 changes: 9 additions & 3 deletions qiita_pet/uimodules/prep_template_tab.py
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -225,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,
Expand All @@ -249,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):
Expand Down
20 changes: 11 additions & 9 deletions qiita_pet/uimodules/preprocessed_data_tab.py
Expand Up @@ -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
Expand All @@ -15,15 +16,16 @@
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):
@execute_as_transaction
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(
Expand All @@ -37,9 +39,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'])
Expand Down Expand Up @@ -76,13 +75,15 @@ 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,
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,
Expand All @@ -95,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)
12 changes: 10 additions & 2 deletions qiita_pet/uimodules/study_information_tab.py
Expand Up @@ -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


Expand Down Expand Up @@ -62,6 +62,12 @@ 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
if ebi_accession:
ebi_accession = (EBI_LINKIFIER.format(ebi_accession))

return self.render_string(
"study_description_templates/study_information_tab.html",
abstract=abstract,
Expand All @@ -77,4 +83,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)
3 changes: 3 additions & 0 deletions qiita_pet/util.py
Expand Up @@ -39,6 +39,9 @@
'public':
('glyphicon glyphicon-eye-open', 'glyphicon glyphicon-globe', 'green')}

EBI_LINKIFIER = ('<a href="http://www.ebi.ac.uk/ena/data/view/{0}" '
'target="_blank">{0}</a>')


def linkify(link_template, item):
"""Formats a strings into a URL using string replacement
Expand Down

0 comments on commit ad1b63d

Please sign in to comment.