Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #4781 from yhoogstrate/mothur_freq_fix
Browse files Browse the repository at this point in the history
Mothur.freq sniffer more stringent
  • Loading branch information
jmchilton committed Oct 12, 2017
2 parents d3345d9 + 03fe2a9 commit 5bf08cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/galaxy/datatypes/mothur.py
Expand Up @@ -605,25 +605,35 @@ def sniff(self, filename):
>>> 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
for line in headers:
if not line[0].startswith('@'):
# first line should be #<version string>
if count == 0:
# first line should be #<version string>
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 <int> <float>
if len(line) != 2:
return False
try:
int(line[0])
float(line[1])

if line[1].find('.') == -1:
return False
except Exception:
return False
count += 1

if count > 1:
return True

Expand Down
@@ -0,0 +1,7 @@
GeneID Mut1
11287 1463
11298 1345
11302 5
11303 1574
11304 361
11305 1762

0 comments on commit 5bf08cf

Please sign in to comment.