def _reorder_unifrac_res_one_sample(unifrac_res, sample_names_in_desired_order):
 sample_names = sample_names_in_desired_order
 unifrac_dist_arry = unifrac_res[0]
 unifrac_sample_names = unifrac_res[1]
 unifrac_sample_names_idx = dict([(n, i) for (i, n) in enumerate(unifrac_sample_names)])
 if (list(unifrac_sample_names) == list(sample_names)):
  dist_arry = unifrac_dist_arry
 else:
  dist_arry = np.zeros(len(sample_names))
  for (i, sam_i) in enumerate(sample_names):
   if (sam_i not in unifrac_sample_names_idx):
    dist_arry[i] = 1.0
   else:
    unifrac_i = unifrac_sample_names_idx[sam_i]
    dist_arry[i] = unifrac_dist_arry[unifrac_i]
 return dist_arry

def _reorder_unifrac_res_one_sample ( unifrac_res , sample_names_in_desired_order ) : sample_names = sample_names_in_desired_order unifrac_dist_arry = unifrac_res [ 0 ] unifrac_sample_names = unifrac_res [ 1 ] unifrac_sample_names_idx = dict ( [ ( n , i ) for ( i , n ) in enumerate ( unifrac_sample_names ) ] ) if ( list ( unifrac_sample_names ) == list ( sample_names ) ) : dist_arry = unifrac_dist_arry else : dist_arry = np . zeros ( len ( sample_names ) ) for ( i , sam_i ) in enumerate ( sample_names ) : if ( sam_i not in unifrac_sample_names_idx ) : dist_arry [ i ] = 1.0 else : unifrac_i = unifrac_sample_names_idx [ sam_i ] dist_arry [ i ] = unifrac_dist_arry [ unifrac_i ] return dist_arry
reorder unifrac result unifrac res is distmtx .