deps/kb_meme/meme-5.0.1/src/tomtom.c
/**************************************************************************
 * Computes Pearson scores for all columns of the query matrix against target
 * motif. 
 **************************************************************************/
Computes Pearson scores for all columns of the query matrix against target
motif.
Computes Pearson scores for all columns of the query matrix against target motif .
void pearson_scores(
    MOTIF_T* query_motif,
    MOTIF_T* target_motif,
    ARRAY_T* background,
    int offset,
    MATRIX_T** score
    ) {
  double x_bar = 1.0 / get_motif_alph_size(query_motif);
  double y_bar = 1.0 / get_motif_alph_size(target_motif);
  int index_query;
  int index_target;
  for (index_query = 0; index_query < get_motif_length(query_motif); index_query++) {
    for (index_target = 0; index_target < get_motif_length(target_motif); index_target++) {
      double SCORE_F = 0;
      double SCORE_NUMERATOR = 0;
      double SCORE_SQ_DENOMINATOR_1 = 0;
      double SCORE_SQ_DENOMINATOR_2 = 0;
      int index; 
      for (index = 0; index < get_motif_alph_size(query_motif); index++) {
        SCORE_NUMERATOR
          += (get_matrix_cell(index_query, index, get_motif_freqs(query_motif)) - x_bar)
          * (get_matrix_cell(index_target, index, get_motif_freqs(target_motif)) - y_bar);
        SCORE_SQ_DENOMINATOR_1
          += pow(
              (get_matrix_cell(index_query, index, get_motif_freqs(query_motif))
               - x_bar),
              2
              );
        SCORE_SQ_DENOMINATOR_2
          += pow(
              (get_matrix_cell(index_target, index, get_motif_freqs(target_motif))
               - y_bar),
              2
              );
      } 
      double SCORE_SQ_DENOMINATOR 
        = SCORE_SQ_DENOMINATOR_1 * SCORE_SQ_DENOMINATOR_2;
      double SCORE_DENOMINATOR = sqrt(SCORE_SQ_DENOMINATOR);
      SCORE_F = SCORE_DENOMINATOR != 0 ? (SCORE_NUMERATOR / SCORE_DENOMINATOR) : 0;
      set_matrix_cell(index_query, offset + index_target, SCORE_F, *score);
    } 
  } 
}
void pearson_scores ( MOTIF_T * query_motif , MOTIF_T * target_motif , ARRAY_T * background , int offset , MATRIX_T * * score ) { double x_bar = 1.0 / get_motif_alph_size ( query_motif ) ; double y_bar = 1.0 / get_motif_alph_size ( target_motif ) ; int index_query ; int index_target ; for ( index_query = 0 ; index_query < get_motif_length ( query_motif ) ; index_query ++ ) { for ( index_target = 0 ; index_target < get_motif_length ( target_motif ) ; index_target ++ ) { double SCORE_F = 0 ; double SCORE_NUMERATOR = 0 ; double SCORE_SQ_DENOMINATOR_1 = 0 ; double SCORE_SQ_DENOMINATOR_2 = 0 ; int index ; for ( index = 0 ; index < get_motif_alph_size ( query_motif ) ; index ++ ) { SCORE_NUMERATOR += ( get_matrix_cell ( index_query , index , get_motif_freqs ( query_motif ) ) - x_bar ) * ( get_matrix_cell ( index_target , index , get_motif_freqs ( target_motif ) ) - y_bar ) ; SCORE_SQ_DENOMINATOR_1 += pow ( ( get_matrix_cell ( index_query , index , get_motif_freqs ( query_motif ) ) - x_bar ) , 2 ) ; SCORE_SQ_DENOMINATOR_2 += pow ( ( get_matrix_cell ( index_target , index , get_motif_freqs ( target_motif ) ) - y_bar ) , 2 ) ; } double SCORE_SQ_DENOMINATOR = SCORE_SQ_DENOMINATOR_1 * SCORE_SQ_DENOMINATOR_2 ; double SCORE_DENOMINATOR = sqrt ( SCORE_SQ_DENOMINATOR ) ; SCORE_F = SCORE_DENOMINATOR != 0 ? ( SCORE_NUMERATOR / SCORE_DENOMINATOR ) : 0 ; set_matrix_cell ( index_query , offset + index_target , SCORE_F , * score ) ; } } }
Computes Pearson scores for all columns of the query matrix against target
 motif.
Computes Pearson scores for all columns of the query matrix against target motif .
/*   Define the average values */ /*   Recurse pairwise over the columns */ /* Index corresponds to the alphabets. */ /* The numerator of the Pearson */ /*  The denominoator of the Pearson */ /* Nr and Dr components summed over the entire alphabet. */ /*       Compute the Denominator */ /* Target motif */ /* Query motif */