def _build_exp_freq_mat(exp_freq_table):
 exp_freq_mat = ExpectedFrequencyMatrix(alphabet=exp_freq_table.alphabet, build_later=1)
 for i in exp_freq_mat:
  if (i[0] == i[1]):
   exp_freq_mat[i] = (exp_freq_table[i[0]] ** 2)
  else:
   exp_freq_mat[i] = ((2.0 * exp_freq_table[i[0]]) * exp_freq_table[i[1]])
 return exp_freq_mat

def _build_exp_freq_mat ( exp_freq_table ) : exp_freq_mat = ExpectedFrequencyMatrix ( alphabet = exp_freq_table . alphabet , build_later = 1 ) for i in exp_freq_mat : if ( i [ 0 ] == i [ 1 ] ) : exp_freq_mat [ i ] = ( exp_freq_table [ i [ 0 ] ] ** 2 ) else : exp_freq_mat [ i ] = ( ( 2.0 * exp_freq_table [ i [ 0 ] ] ) * exp_freq_table [ i [ 1 ] ] ) return exp_freq_mat
build an expected frequency matrix exp_freq_table: should be a freqtable instance .