'Determines whether the file is in fasta format
A sequence in FASTA format consists of a single-line description, followed by lines of sequence data.
The first character of the description line is a greater-than (">") symbol in the first column.
All lines should be shorter than 80 characters
For complete details see http://www.ncbi.nlm.nih.gov/blast/fasta.shtml
Rules for sniffing as True:
We don\'t care about line length (other than empty lines).
The first non-empty line must start with \'>\' and the Very Next line.strip() must have sequence data and not be a header.
\'sequence data\' here is loosely defined as non-empty lines which do not start with \'>\'
This will cause Color Space FASTA (csfasta) to be detected as True (they are, after all, still FASTA files - they have a header line followed by sequence data)
Previously this method did some checking to determine if the sequence data had integers (presumably to differentiate between fasta and csfasta)
This should be done through sniff order, where csfasta (currently has a null sniff function) is detected for first (stricter definition) followed sometime after by fasta
We will only check that the first purported sequence is correctly formatted.
>>> from galaxy.datatypes.sniff import get_test_fname
>>> fname = get_test_fname( \'sequence.maf\' )
>>> Fasta().sniff( fname )
False
>>> fname = get_test_fname( \'sequence.fasta\' )
>>> Fasta().sniff( fname )
True'

def sniff(self, filename):

    try:
        fh = open(filename)
        while True:
            line = fh.readline()
            if (not line):
                break
            line = line.strip()
            if line:
                if line.startswith('>'):
                    line = fh.readline().strip()
                    if ((line == '') or line.startswith('>')):
                        break
                    line = fh.readline()
                    if ((not line.startswith('>')) and re.search('[\\(\\)\\[\\]\\.]', line)):
                        break
                    return True
                else:
                    break
        fh.close()
    except:
        pass
    return False
