From 500a7aee64708717a187ee87b4351d1295c48a6a Mon Sep 17 00:00:00 2001 From: yhoogstrate Date: Tue, 10 Oct 2017 11:16:09 +0200 Subject: [PATCH 1/4] test case to fix mothur.freq sniffer --- lib/galaxy/datatypes/mothur.py | 5 +++++ .../datatypes/test/mothur_datatypetest_false_2.mothur.freq | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 lib/galaxy/datatypes/test/mothur_datatypetest_false_2.mothur.freq diff --git a/lib/galaxy/datatypes/mothur.py b/lib/galaxy/datatypes/mothur.py index d1e016a729c..fdd462c5669 100644 --- a/lib/galaxy/datatypes/mothur.py +++ b/lib/galaxy/datatypes/mothur.py @@ -605,6 +605,11 @@ class Frequency(Tabular): >>> fname = get_test_fname( 'mothur_datatypetest_false.mothur.freq' ) >>> Frequency().sniff( fname ) False + + # Expression count matrix (EdgeR wrapper) + >>> fname = get_test_fname( 'mothur_datatypetest_false_2.mothur.freq' ) + >>> Frequency().sniff( fname ) + False """ headers = iter_headers(filename, sep='\t') count = 0 diff --git a/lib/galaxy/datatypes/test/mothur_datatypetest_false_2.mothur.freq b/lib/galaxy/datatypes/test/mothur_datatypetest_false_2.mothur.freq new file mode 100644 index 00000000000..74d16507e3a --- /dev/null +++ b/lib/galaxy/datatypes/test/mothur_datatypetest_false_2.mothur.freq @@ -0,0 +1,7 @@ +GeneID Mut1 +11287 1463 +11298 1345 +11302 5 +11303 1574 +11304 361 +11305 1762 From 787c3e575371b0969f57592a6f522d7d2634e2bc Mon Sep 17 00:00:00 2001 From: yhoogstrate Date: Tue, 10 Oct 2017 11:55:25 +0200 Subject: [PATCH 2/4] test case to fix mothur.freq sniffer --- lib/galaxy/datatypes/mothur.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/datatypes/mothur.py b/lib/galaxy/datatypes/mothur.py index fdd462c5669..237e857559f 100644 --- a/lib/galaxy/datatypes/mothur.py +++ b/lib/galaxy/datatypes/mothur.py @@ -582,6 +582,7 @@ class Oligos(Text): class Frequency(Tabular): file_ext = 'mothur.freq' + max_snif_lines = 25 def __init__(self, **kwd): """A list of names""" @@ -615,10 +616,11 @@ class Frequency(Tabular): count = 0 for line in headers: if not line[0].startswith('@'): + # first line should be # if count == 0: - # first line should be # - if not line[0].startswith('#') and len(line) == 1: + if not line[0].startswith('#') or len(line) != 1: return False + else: # all other lines should be if len(line) != 2: @@ -626,9 +628,16 @@ class Frequency(Tabular): try: int(line[0]) float(line[1]) + + if line[1].find('.') == -1: + return False except Exception: return False count += 1 + + if count > self.max_snif_lines: + return True + if count > 1: return True From 6dd59d9d2dcf6241506cf7720729145874e66121 Mon Sep 17 00:00:00 2001 From: yhoogstrate Date: Tue, 10 Oct 2017 13:02:10 +0200 Subject: [PATCH 3/4] flake --- lib/galaxy/datatypes/mothur.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/datatypes/mothur.py b/lib/galaxy/datatypes/mothur.py index 237e857559f..349aaec436d 100644 --- a/lib/galaxy/datatypes/mothur.py +++ b/lib/galaxy/datatypes/mothur.py @@ -606,7 +606,7 @@ class Frequency(Tabular): >>> fname = get_test_fname( 'mothur_datatypetest_false.mothur.freq' ) >>> Frequency().sniff( fname ) False - + # Expression count matrix (EdgeR wrapper) >>> fname = get_test_fname( 'mothur_datatypetest_false_2.mothur.freq' ) >>> Frequency().sniff( fname ) @@ -634,7 +634,7 @@ class Frequency(Tabular): except Exception: return False count += 1 - + if count > self.max_snif_lines: return True From 03fe2a9779dfe51659f021b6856a74cac6c44ba3 Mon Sep 17 00:00:00 2001 From: yhoogstrate Date: Wed, 11 Oct 2017 11:29:51 +0200 Subject: [PATCH 4/4] addresses comments --- lib/galaxy/datatypes/mothur.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/galaxy/datatypes/mothur.py b/lib/galaxy/datatypes/mothur.py index 349aaec436d..c13b7d2adc9 100644 --- a/lib/galaxy/datatypes/mothur.py +++ b/lib/galaxy/datatypes/mothur.py @@ -582,7 +582,6 @@ class Oligos(Text): class Frequency(Tabular): file_ext = 'mothur.freq' - max_snif_lines = 25 def __init__(self, **kwd): """A list of names""" @@ -635,9 +634,6 @@ class Frequency(Tabular): return False count += 1 - if count > self.max_snif_lines: - return True - if count > 1: return True