deps/kb_meme/meme-5.0.1/src/tomtom.c
/**************************************************************************
 * Computes ALLR scores for all columns of the query matrix against target
 * motif. This can then be used to by compute_allr.
 **************************************************************************/
Computes ALLR scores for all columns of the query matrix against target
motif. This can then be used to by compute_allr.
Computes ALLR scores for all columns of the query matrix against target motif . This can then be used to by compute_allr .
void allr_scores(
    MOTIF_T* query_motif,
    MOTIF_T* target_motif,
    ARRAY_T* background,
    int offset,
    MATRIX_T** score
    ) {
  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_DENOMINATOR = 0;
      int index; 
      for (index = 0; index < get_motif_alph_size(query_motif); index++) {
        double nr_part1, nr_part2;
        nr_part1
          = (
              get_motif_nsites(target_motif)
              * (
                get_matrix_cell(index_target, index, get_motif_freqs(target_motif))
                )
              * log(
                get_matrix_cell(index_query, index, get_motif_freqs(query_motif))
                / get_array_item(index, background)
                )
            ); 
        nr_part2 
          = (
              get_motif_nsites(query_motif)
              * (
                get_matrix_cell(index_query, index, get_motif_freqs(query_motif))
                )
              * log(
                get_matrix_cell(index_target, index, get_motif_freqs(target_motif))
                / get_array_item(index, background)
                )
            ); 
        SCORE_NUMERATOR += nr_part1 + nr_part2;
        SCORE_DENOMINATOR
          += (
              (
               get_motif_nsites(query_motif)
               *  get_matrix_cell(
                 index_query, 
                 index, 
                 get_motif_freqs(query_motif)
                 )
              )
              + (
                get_motif_nsites(target_motif)
                * get_matrix_cell(index_target, index, get_motif_freqs(target_motif))
                ) 
             ); 
      } 
      SCORE_F = SCORE_NUMERATOR / SCORE_DENOMINATOR;
      set_matrix_cell(index_query, offset + index_target, SCORE_F, *score);
    } 
  } 
}
void allr_scores ( MOTIF_T * query_motif , MOTIF_T * target_motif , ARRAY_T * background , int offset , MATRIX_T * * score ) { 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_DENOMINATOR = 0 ; int index ; for ( index = 0 ; index < get_motif_alph_size ( query_motif ) ; index ++ ) { double nr_part1 , nr_part2 ; nr_part1 = ( get_motif_nsites ( target_motif ) * ( get_matrix_cell ( index_target , index , get_motif_freqs ( target_motif ) ) ) * log ( get_matrix_cell ( index_query , index , get_motif_freqs ( query_motif ) ) / get_array_item ( index , background ) ) ) ; nr_part2 = ( get_motif_nsites ( query_motif ) * ( get_matrix_cell ( index_query , index , get_motif_freqs ( query_motif ) ) ) * log ( get_matrix_cell ( index_target , index , get_motif_freqs ( target_motif ) ) / get_array_item ( index , background ) ) ) ; SCORE_NUMERATOR += nr_part1 + nr_part2 ; SCORE_DENOMINATOR += ( ( get_motif_nsites ( query_motif ) * get_matrix_cell ( index_query , index , get_motif_freqs ( query_motif ) ) ) + ( get_motif_nsites ( target_motif ) * get_matrix_cell ( index_target , index , get_motif_freqs ( target_motif ) ) ) ) ; } SCORE_F = SCORE_NUMERATOR / SCORE_DENOMINATOR ; set_matrix_cell ( index_query , offset + index_target , SCORE_F , * score ) ; } } }
Computes ALLR scores for all columns of the query matrix against target
 motif.
Computes ALLR scores for all columns of the query matrix against target motif .
/*   Recurse pairwise over the columns */ /* Index corresponds to the alphabets. */ /* The numerator of the ALLR */ /*  Part 1 of the numerator  */ /* nb for target */ /* Likelihood for query */ /*  Part 2 of the numerator */ /* nb for query */ /* Likelihood for target */ /* Sum of the two parts. */ /*  The denominoator of the ALLR */ // nb for query // nb for target /* Sum of nb for query and nb for target */ /* Nr and Dr of the score summed over the entire alphabet. */ /* Target motif */ /* Query motif */