def read_cluster_file(clusters):
    """
    Read a cluster output file.  This file should have the form: 

    cluster_integer SEQUENCE1
    cluster_integer SEQUENCE2
    ...

    Returns two dictionaries. One maps sequence to cluster, the other maps 
    cluster number to sequence.
    """

    # Read file
    f = open(clusters,'r')
    lines = f.readlines()
    f.close()

    # Parse file
    seq_to_cluster = {}
    cluster_to_seq = {}
    for l in lines:

        if l.strip() == "" or l[0] == "#": 
            continue
   
        col = l.split() 
        cluster = int(col[0])
        seq = col[1]

        try:
            cluster_to_seq[cluster].append(seq)
        except KeyError:
            cluster_to_seq[cluster] = [seq]

        seq_to_cluster[seq] = cluster

    return seq_to_cluster, cluster_to_seq