'Determines whether the file is a square distance matrix (Column-formatted distance matrix) format
The first line has the number of sequences in the matrix.
The following lines have the sequence name in the first column plus a column for the distance to each sequence
in the row order in which they appear in the matrix.
3
U68589  0.0000  0.3371  0.3610
U68590  0.3371  0.0000  0.3783
U68590  0.3371  0.0000  0.3783
>>> from galaxy.datatypes.sniff import get_test_fname
>>> fname = get_test_fname( \'mothur_datatypetest_true.mothur.square.dist\' )
>>> SquareDistanceMatrix().sniff( fname )
True
>>> fname = get_test_fname( \'mothur_datatypetest_false.mothur.square.dist\' )
>>> SquareDistanceMatrix().sniff( fname )
False'

def sniff(self, filename):

    numlines = 300
    headers = iter_headers(filename, sep=' DCTB ', count=numlines)
    line_num = 0
    for line in headers:
        if (not line[0].startswith('@')):
            if (line_num == 0):
                if (len(line) > 2):
                    return False
                else:
                    try:
                        sequence_count = int(''.join(line))
                    except ValueError:
                        return False
            else:
                if (len(line) != (sequence_count + 1)):
                    return False
                try:
                    for column in line[2:]:
                        float(column)
                except ValueError:
                    return False
            line_num += 1
    if ((line_num == (sequence_count + 1)) or (line_num == (numlines + 1))):
        return True
    return False
