Skip to content

rm artifacts from parameters listing #2374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2017
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
2 changes: 1 addition & 1 deletion qiita_db/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ def test_get_artifacts_information(self):
'data_type': '18S', 'prep_samples': 27,
'parameters': {
'reference': 1, 'similarity': 0.97, 'sortmerna_e_value': 1,
'sortmerna_max_pos': 10000, 'input_data': 2, 'threads': 1,
'sortmerna_max_pos': 10000, 'threads': 1,
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
{'files': [], 'target_subfragment': ['V4'], 'algorithm': '',
'artifact_id': 7, 'data_type': '16S', 'prep_samples': 27,
Expand Down
24 changes: 19 additions & 5 deletions qiita_db/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,8 +1513,14 @@ def get_artifacts_information(artifact_ids, only_biom=True):
"""

sql_params = """SELECT default_parameter_set_id, command_id,
parameter_set_name, parameter_set AS param_set
FROM qiita.default_parameter_set"""
parameter_set_name, parameter_set AS param_set,
array_agg(parameter_name)
FROM qiita.default_parameter_set
LEFT JOIN qiita.command_parameter
USING (command_id)
WHERE parameter_type = 'artifact'
GROUP BY default_parameter_set_id, command_id,
parameter_set_name"""

sql_ts = """SELECT DISTINCT target_subfragment FROM qiita.prep_%s"""

Expand All @@ -1526,8 +1532,9 @@ def get_artifacts_information(artifact_ids, only_biom=True):
# to have a huge growth in the near future
qdb.sql_connection.TRN.add(sql_params)
params = defaultdict(list)
for _, cid, n, p in qdb.sql_connection.TRN.execute_fetchindex():
params[cid].append((n, list(p.iteritems())))
for row in qdb.sql_connection.TRN.execute_fetchindex():
_, cid, n, param, aparam = row
params[cid].append((n, list(param.iteritems()), aparam))

# now let's get the actual artifacts
ts = {}
Expand All @@ -1549,14 +1556,21 @@ def get_artifacts_information(artifact_ids, only_biom=True):
# the name of the parameter set
pparams = sorted(
[(pn, len([vv for vv in v if vv in pparams]))
for pn, v in params[pcid]], key=lambda x: x[1])[-1]
for pn, v, a in params[pcid]], key=lambda x: x[1])[-1]
pparams = 'N/A' if pparams[1] == 0 else pparams[0]
else:
pparams = 'N/A'
# - [0] due to the array_agg
aparams = aparams[0]
if aparams is None:
aparams = {}
else:
# we are gonna remove any artifacts from the parameters
# [0] cause there is only one element and [2] cause
# there is where the artifact types are stored
to_ignore = params[cid][0][2]
for ti in to_ignore:
del aparams[ti]
# - ignoring empty filepaths
if filepaths == [None]:
filepaths = []
Expand Down
4 changes: 2 additions & 2 deletions qiita_pet/handlers/api_proxy/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def test_artifact_get_info(self):
'timestamp': '2012-10-02 17:30:00', 'prep_samples': 27,
'parameters': {
'reference': 2, 'similarity': 0.97, u'sortmerna_e_value': 1,
'sortmerna_max_pos': 10000, 'input_data': 2, 'threads': 1,
'sortmerna_max_pos': 10000, 'threads': 1,
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
{'files': ['1_study_1001_closed_reference_otu_table.biom'],
'target_subfragment': ['V4'],
Expand All @@ -240,7 +240,7 @@ def test_artifact_get_info(self):
'timestamp': '2012-10-02 17:30:00', 'prep_samples': 27,
'parameters': {
'reference': 1, 'similarity': 0.97, 'sortmerna_e_value': 1,
'sortmerna_max_pos': 10000, 'input_data': 2, 'threads': 1,
'sortmerna_max_pos': 10000, 'threads': 1,
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
{'files': [], 'target_subfragment': ['V4'], 'algorithm': '',
'artifact_id': 7, 'data_type': '16S',
Expand Down
2 changes: 1 addition & 1 deletion qiita_pet/handlers/study_handlers/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_get(self):
'algorithm': 'Pick closed-reference OTUs, QIIMEv1.9.1 | Defaults',
'parameters': {
'reference': 2, 'similarity': 0.97, 'sortmerna_e_value': 1,
'sortmerna_max_pos': 10000, 'input_data': 2, 'threads': 1,
'sortmerna_max_pos': 10000, 'threads': 1,
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
{'files': [], 'target_subfragment': ['V4'], 'artifact_id': 7,
'data_type': '16S', 'timestamp': '2012-10-02 17:30:00',
Expand Down