import fileinput


def import_loci(path):
    """Import a bed style loci file and return a dict of dicts of the loci"""
    genes = {}
    with fileinput.input(path) as gene_file:
        next(gene_file)
        for line in gene_file:
            line = line.strip().split()
            gene = {'chr':line[0], 'start':int(line[1]),
                    'stop':int(line[2]), 'name':line[4],
                    'strand':line[5]}

            gene['length'] = (gene['stop'] - gene['start']) / 3
            # Would need to correct for strand/base in some cases, but not with ensembl output

            genes[line[3]] = gene

    return genes