'Determines whether the file is in customtrack format.
CustomTrack files are built within Galaxy and are basically bed or interval files with the first line looking
something like this.
track name="User Track" description="User Supplied Track (from Galaxy)" color=0,0,0 visibility=1
>>> from galaxy.datatypes.sniff import get_test_fname
>>> fname = get_test_fname( \'complete.bed\' )
>>> CustomTrack().sniff( fname )
False
>>> fname = get_test_fname( \'ucsc.customtrack\' )
>>> CustomTrack().sniff( fname )
True'

def sniff(self, filename):

    headers = iter_headers(filename, None)
    first_line = True
    for hdr in headers:
        if first_line:
            first_line = False
            try:
                if hdr[0].startswith('track'):
                    color_found = False
                    visibility_found = False
                    for elem in hdr[1:]:
                        if elem.startswith('color'):
                            color_found = True
                        if elem.startswith('visibility'):
                            visibility_found = True
                        if (color_found and visibility_found):
                            break
                    if ((not color_found) or (not visibility_found)):
                        return False
                else:
                    return False
            except:
                return False
        else:
            try:
                if (hdr[0] and (not hdr[0].startswith('#'))):
                    if (len(hdr) < 3):
                        return False
                    try:
                        int(hdr[1])
                        int(hdr[2])
                    except:
                        return False
            except:
                return False
    return True
