def parse_distmat_to_dict(table):
 (col_headers, row_headers, data) = parse_matrix(table)
 assert (col_headers == row_headers)
 result = defaultdict(dict)
 for (sample_id_x, row) in zip(col_headers, data):
  for (sample_id_y, value) in zip(row_headers, row):
   result[sample_id_x][sample_id_y] = value
 return result

def parse_distmat_to_dict ( table ) : ( col_headers , row_headers , data ) = parse_matrix ( table ) assert ( col_headers == row_headers ) result = defaultdict ( dict ) for ( sample_id_x , row ) in zip ( col_headers , data ) : for ( sample_id_y , value ) in zip ( row_headers , row ) : result [ sample_id_x ] [ sample_id_y ] = value return result
parse a dist matrix into an 2d dict indexed by sample ids .