def matrix2dictionary(matrix):
    """
    convert matrix to dictionary of comparisons
    """
    pw = {}
    for line in matrix:
        line = line.strip().split('\t')
        if line[0].startswith('#'):
            names = line[1:]
            continue
        a = line[0]
        for i, pident in enumerate(line[1:]):
            b = names[i]
            if a not in pw:
                pw[a] = {}
            if b not in pw:
                pw[b] = {}
            if pident != '-':
                pident = float(pident)
            pw[a][b] = pident
            pw[b][a] = pident
    return pw
convert matrix to dictionary of comparisons