Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions qiita_db/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,15 @@ def can_be_submitted_to_ebi(self):
True if the artifact can be submitted to EBI. False otherwise.
"""
with qdb.sql_connection.TRN:
# we should always return False if this artifact is not directly
# attached to the prep_template or is the second after. In other
# words has more that one processing step behind it
fine_to_send = []
fine_to_send.extend([pt.artifact for pt in self.prep_templates])
fine_to_send.extend([c for a in fine_to_send for c in a.children])
if self not in fine_to_send:
return False

sql = """SELECT can_be_submitted_to_ebi
FROM qiita.artifact_type
JOIN qiita.artifact USING (artifact_type_id)
Expand Down
15 changes: 15 additions & 0 deletions qiita_db/test/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from datetime import datetime
from os import close, remove
from os.path import exists, join, basename
from shutil import copyfile
from functools import partial
from json import dumps

Expand Down Expand Up @@ -811,6 +812,11 @@ def test_create_root_analysis(self):
qdb.artifact.Artifact.delete(obs.id)

def test_create_processed(self):
# make a copy of files for the can_be_submitted_to_ebi tests
lcopy = self.fp3 + '.fna'
self._clean_up_files.append(lcopy)
copyfile(self.fp3, lcopy)

exp_params = qdb.software.Parameters.from_default_params(
qdb.software.DefaultParameters(1), {'input_data': 1})
before = datetime.now()
Expand Down Expand Up @@ -842,6 +848,15 @@ def test_create_processed(self):
self.assertFalse(exists(self.filepaths_processed[0][0]))
self.assertIsNone(obs.analysis)

# let's create another demultiplexed on top of the previous one to
# test can_be_submitted_to_ebi
exp_params = qdb.software.Parameters.from_default_params(
qdb.software.DefaultParameters(1), {'input_data': obs.id})
new = qdb.artifact.Artifact.create(
[(lcopy, 4)], "Demultiplexed", parents=[obs],
processing_parameters=exp_params)
self.assertFalse(new.can_be_submitted_to_ebi)

def test_create_copy_files(self):
exp_params = qdb.software.Parameters.from_default_params(
qdb.software.DefaultParameters(1), {'input_data': 1})
Expand Down