import csv


def read_snp(handle):
    """ Reads a mummer snp file """

    dialect = csv.Sniffer().sniff(handle.read(1024))
    handle.seek(0)

    reader = csv.DictReader(
        handle,
        fieldnames=[
            "pos_ref",
            "allele_ref",
            "allele_query",
            "pos_query",
            "buff", # Distance from this SNP to the nearest mismatch
            "dist", # Distance from this SNP to the nearest sequence end.
            "len_ref",
            "len_query",
            "strand_ref",
            "strand_query",
            "id_ref",
            "id_query",
        ],
        dialect=dialect,
    )

    return reader