diff --git a/lib/galaxy/datatypes/mothur.py b/lib/galaxy/datatypes/mothur.py index 83dd8150f86..073d4f64499 100644 --- a/lib/galaxy/datatypes/mothur.py +++ b/lib/galaxy/datatypes/mothur.py @@ -494,21 +494,33 @@ class PairwiseDistanceMatrix(DistanceMatrix, Tabular): """ headers = iter_headers(file_prefix, sep='\t') count = 0 + names = [False, False] for line in headers: - if not line[0].startswith('@'): - if len(line) != 3: - return False + if line[0].startswith('@'): + continue + if len(line) != 3: + return False + # check if col3 contains distances (floats) + try: + float(line[2]) try: - float(line[2]) - try: - # See if it's also an integer - int(line[2]) - except ValueError: - # At least one value is not an integer - all_ints = False + # See if it's also an integer + int(line[2]) except ValueError: - return False - count += 1 + # At least one value is not an integer + all_ints = False + except ValueError: + return False + count += 1 + # check if col1 and col2 likely contain names + for c in [0, 1]: + try: + float(line[c]) + except ValueError: + names[c] = True + + if not names[0] or not names[1]: + return False if count > 2: return not all_ints diff --git a/lib/galaxy/datatypes/sniff.py b/lib/galaxy/datatypes/sniff.py index e67725ce893..c00a6ca9286 100644 --- a/lib/galaxy/datatypes/sniff.py +++ b/lib/galaxy/datatypes/sniff.py @@ -270,7 +270,7 @@ def guess_ext(fname, sniff_order, is_binary=False): >>> fname = get_test_fname('2.txt') >>> guess_ext(fname, sniff_order) 'txt' - >>> fname = get_test_fname('2.tabular') + >>> fname = get_test_fname('test_tab2.tabular') >>> guess_ext(fname, sniff_order) 'tabular' >>> fname = get_test_fname('3.txt') diff --git a/lib/galaxy/datatypes/tabular.py b/lib/galaxy/datatypes/tabular.py index c8348557ab1..328a76c48f0 100644 --- a/lib/galaxy/datatypes/tabular.py +++ b/lib/galaxy/datatypes/tabular.py @@ -719,7 +719,7 @@ class Pileup(Tabular): >>> fname = get_test_fname( '2.txt' ) >>> Pileup().sniff( fname ) # 2.txt False - >>> fname = get_test_fname( '2.tabular' ) + >>> fname = get_test_fname( 'test_tab2.tabular' ) >>> Pileup().sniff( fname ) False """ diff --git a/lib/galaxy/datatypes/test/2.tabular b/lib/galaxy/datatypes/test/2.tabular deleted file mode 100644 index d56c0bee10d..00000000000 --- a/lib/galaxy/datatypes/test/2.tabular +++ /dev/null @@ -1,3 +0,0 @@ -a 2 -c 1 -d 0 diff --git a/lib/galaxy/datatypes/test/2.tabular b/lib/galaxy/datatypes/test/2.tabular new file mode 120000 index 00000000000..2cae3b48c67 --- /dev/null +++ b/lib/galaxy/datatypes/test/2.tabular @@ -0,0 +1 @@ +../../../../test-data/2.tabular \ No newline at end of file diff --git a/lib/galaxy/datatypes/test/test_tab2.tabular b/lib/galaxy/datatypes/test/test_tab2.tabular new file mode 100644 index 00000000000..d56c0bee10d --- /dev/null +++ b/lib/galaxy/datatypes/test/test_tab2.tabular @@ -0,0 +1,3 @@ +a 2 +c 1 +d 0