import csv


def get_seq_to_pos(seq_table_file):
    """
    Parses the sequence table and returns a dict from name to pos
    """

    # seq_to_pos is a dict from sequence name to the position of interest (breakpoint or junction)

    # initialize dict
    seq_to_pos = {}

    with open(seq_table_file, "r") as csvfile:
        # Auto detect dialect of input file
        dialect = csv.Sniffer().sniff(csvfile.readline(), delimiters=";,\t")
        csvfile.seek(0)
        reader = csv.DictReader(csvfile, dialect=dialect)

        # Iterate over input file rows
        for row in reader:
            
            name = row["name"]
            pos = int(row["position"])
            
            seq_to_pos[name] = pos
            
    return seq_to_pos