def getHits(fileName, evalueThresh):
    """Given a BLAST output file, returns a dictionary keyed by the genes
    in the query species, with the values being the top hit (if any)
    for those genes. Assumes the blast hits for each query are given
    from most to least significant. which appears to be the
    case. Thresholds for minimum similarity and maximum length
    difference are globally defined.
    """
    f = open(fileName, 'r')
    hitsD = {}
    queryGene = ''
    line = f.readline()
    while line != '':
        L = line.split('\t')
        if len(L) < 12:
            line = f.readline()
            continue
        queryGene = L[0].split('_')[0]
        hit = L[1].split('_')[0]
        evalue = float(L[10])
        if evalue < evalueThresh:
            hitsD[int(queryGene)] = int(hit)
        while line.split('_')[0] == queryGene:
            line = f.readline()
    f.close()
    return hitsD
