diff --git a/qiita_pet/handlers/qiita_redbiom.py b/qiita_pet/handlers/qiita_redbiom.py index 8ec56d769..12f3e0269 100644 --- a/qiita_pet/handlers/qiita_redbiom.py +++ b/qiita_pet/handlers/qiita_redbiom.py @@ -34,14 +34,15 @@ def _redbiom_metadata_search(self, query, contexts): query = query.lower() try: samples = redbiom.search.metadata_full(query, False) - except TypeError: - message = ( - 'Not a valid search: "%s", are you sure this is a ' - 'valid metadata value?' % query) except ValueError: message = ( 'Not a valid search: "%s", your query is too small ' '(too few letters), try a longer query' % query) + except: + message = ( + 'The query ("%s") did not work and may be malformed. Please ' + 'check the search help for more information on the queries.' + % query) if not message: study_samples = defaultdict(list) for s in samples: @@ -96,16 +97,16 @@ def _redbiom_search(self, query, search_on, callback): if search_on in search_f: message, study_artifacts = search_f[search_on](query, contexts) if not message: - keys = study_artifacts.keys() - if keys: + studies = study_artifacts.keys() + if studies: results = generate_study_list_without_artifacts( - study_artifacts.keys(), True) + studies, True) # inserting the artifact_biom_ids to the results for i in range(len(results)): results[i]['artifact_biom_ids'] = study_artifacts[ str(results[i]['study_id'])] else: - message = "No samples where found! Try again ..." + message = "No samples were found! Try again ..." else: message = ('Incorrect search by: you can use metadata, ' 'features or taxon and you passed: %s' % search_on) diff --git a/qiita_pet/templates/redbiom.html b/qiita_pet/templates/redbiom.html index 62869e1aa..f189ae40f 100644 --- a/qiita_pet/templates/redbiom.html +++ b/qiita_pet/templates/redbiom.html @@ -24,7 +24,7 @@ artifacts += 1; samples += value.length; }); - return [artifacts, samples]}, [0, 0]); + return [artifacts + a[0], samples + a[1]]}, [0, 0]); var artifacts = artifacts_samples[0]; var samples = artifacts_samples[1]; $('.footer').addClass("col-md-12 text-right"); @@ -48,7 +48,12 @@ {"render": function ( data, type, row, meta ) { if (data !== null && data !== undefined){ var artifacts = 0, samples = 0; - for (var d in data) { if (data.hasOwnProperty(d)) { artifacts++; } } + for (var d in data) { + if (data.hasOwnProperty(d)) { + artifacts++; + samples += data[d].length + } + } if (artifacts != 0) { return '
'+ '
' + @@ -57,7 +62,7 @@ {% end %} '
' + 'Artifacts: ' + artifacts + ' | ' + - 'Samples: ' + artifacts + + 'Samples: ' + samples + '
' + '
' + '
'; @@ -153,21 +158,89 @@ {%block content%} Redbiom only searches on public data and the data is updated nightly. Note that you will only be able to expand and add artifacts to analyses if you are signed into Qiita. +

+ +
+
+

We have 3 search options: - +
+

-
+
-
- +
-
diff --git a/qiita_pet/test/test_qiita_redbiom.py b/qiita_pet/test/test_qiita_redbiom.py index 6add3999c..32cc88f12 100644 --- a/qiita_pet/test/test_qiita_redbiom.py +++ b/qiita_pet/test/test_qiita_redbiom.py @@ -46,7 +46,7 @@ def test_post_metadata(self): response = self.post('/redbiom/', post_args) self.assertEqual(response.code, 200) exp = {'status': 'success', - 'message': 'No samples where found! Try again ...', 'data': []} + 'message': 'No samples were found! Try again ...', 'data': []} self.assertEqual(loads(response.body), exp) post_args = { @@ -56,8 +56,9 @@ def test_post_metadata(self): response = self.post('/redbiom/', post_args) self.assertEqual(response.code, 200) exp = {'status': 'success', - 'message': ('Not a valid search: "4353076", are you sure this ' - 'is a valid metadata value?'), 'data': []} + 'message': ('The query ("4353076") did not work and may be ' + 'malformed. Please check the search help for more ' + 'information on the queries.'), 'data': []} self.assertEqual(loads(response.body), exp) def test_post_features(self): @@ -79,7 +80,7 @@ def test_post_features(self): } response = self.post('/redbiom/', post_args) exp = {'status': 'success', - 'message': 'No samples where found! Try again ...', 'data': []} + 'message': 'No samples were found! Try again ...', 'data': []} self.assertEqual(response.code, 200) self.assertEqual(loads(response.body), exp) @@ -102,7 +103,7 @@ def test_post_taxon(self): } response = self.post('/redbiom/', post_args) exp = {'status': 'success', - 'message': 'No samples where found! Try again ...', 'data': []} + 'message': 'No samples were found! Try again ...', 'data': []} self.assertEqual(response.code, 200) self.assertEqual(loads(response.body), exp)