From d47f8f577e358b4e7a71b15a905040e5d3b079d4 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 27 Apr 2016 09:14:54 -0400 Subject: [PATCH 1/2] Fixup exception handling in mothur datatypes. --- lib/galaxy/datatypes/mothur.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/datatypes/mothur.py b/lib/galaxy/datatypes/mothur.py index 05312449a91..a17a5f07cba 100644 --- a/lib/galaxy/datatypes/mothur.py +++ b/lib/galaxy/datatypes/mothur.py @@ -300,7 +300,7 @@ class DistanceMatrix(Text): try: dataset.metadata.sequence_count = int(''.join(line)) # seq count sometimes preceded by tab break - except Exception, e: + except Exception as e: log.warn("DistanceMatrix set_meta %s" % e) @@ -608,7 +608,7 @@ class Frequency(Tabular): try: int(line[0]) float(line[1]) - except: + except Exception: return False count += 1 if count > 1: @@ -658,7 +658,7 @@ class Quantile(Tabular): float(line[4]) float(line[5]) float(line[6]) - except: + except Exception: return False count += 1 if count > 0: @@ -780,7 +780,7 @@ class RefTaxonomy(Tabular): if len(line) == 3: try: int(line[2]) - except: + except Exception: return False count += 1 @@ -901,7 +901,7 @@ class SffFlow(Tabular): try: flow_values = int(headers[0][0]) dataset.metadata.flow_values = flow_values - except Exception, e: + except Exception as e: log.warn("SffFlow set_meta %s" % e) def make_html_table(self, dataset, skipchars=[]): @@ -919,7 +919,7 @@ class SffFlow(Tabular): out += '' out += self.make_html_peek_rows(dataset, skipchars=skipchars) out += '' - except Exception, exc: + except Exception as exc: out = "Can't create peek %s" % str(exc) return out From d73a86d3658ed2ff7815ba5bd57ae63e527d4381 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 27 Apr 2016 09:15:05 -0400 Subject: [PATCH 2/2] Add a sample sniff test for new Mothur datatype. The existing sniffer tests with the mothur stuff tests the sniffers in isolation - this is more of an integration test that tests the sample datatype configuration for the newly added mothur stuff. --- lib/galaxy/datatypes/sniff.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/galaxy/datatypes/sniff.py b/lib/galaxy/datatypes/sniff.py index ff9584d8b47..3e8b8e04c02 100644 --- a/lib/galaxy/datatypes/sniff.py +++ b/lib/galaxy/datatypes/sniff.py @@ -343,6 +343,9 @@ def guess_ext( fname, sniff_order, is_multi_byte=False ): >>> fname = get_test_fname('5e5z.pdb') >>> guess_ext(fname, sniff_order) 'pdb' + >>> fname = get_test_fname('mothur_datatypetest_true.mothur.otu') + >>> guess_ext(fname, sniff_order) + 'mothur.otu' """ for datatype in sniff_order: """