deps/kb_meme/meme-5.0.1/src/momo-input.c
/**
 * Given a list of sequences, set the background sequences for all modifications. For example,
 * if a mod is associated with amino acids S,T,Y, then find all the kmers centralized around
 * these letters and add these to the background sequences.
 */
Given a list of sequences, set the background sequences for all modifications. For example,
if a mod is associated with amino acids S,T,Y, then find all the kmers centralized around
these letters and add these to the background sequences.
Given a list of sequences set the background sequences for all modifications . For example if a mod is associated with amino acids S T Y then find all the kmers centralized around these letters and add these to the background sequences .
void add_background_sequences_to_table(MOMO_OPTIONS_T* options, SUMMARY_T* summary, SEQ_T** protein_database_sequences, int num_sequences) {
  if (options->algorithm == Motifx || options->algorithm == Modl) {
    int i;
    int j;
    int k;
    ARRAYLST_T* mod_table_keys = summary->mod_table_keys;
    const char* alph_letters = summary->alph_letters;
    for (i = 0; i < arraylst_size(mod_table_keys); ++i) {
      MOD_INFO_T* modinfo = (MOD_INFO_T*) hash_get_entry_value(arraylst_get(i, mod_table_keys));
      ARRAYLST_T* bg_seq_list = arraylst_create();
      HASH_TABLE bg_seq_table = (options->eliminate_repeat_width) ? hash_create(DATA_HASH_SIZE, NULL) : NULL;
      modinfo->bg_seq_list = bg_seq_list;
      modinfo->bg_seq_table = bg_seq_table;
      bool* amino_acids = modinfo->amino_acids;
      for (j = 0; j < num_sequences; ++j) {
        char* protein = get_raw_sequence(protein_database_sequences[j]);
        for (k = 0; k < strlen(protein); ++k) {
          if (options->bg_filetype == Fasta || (options->bg_filetype == Prealigned && k == options->width/2)) {
            char* alph_letters_substring = strchr(alph_letters, protein[k]);
            if (alph_letters_substring) {
              int aa_idx = alph_letters_substring - alph_letters;
              if (amino_acids[aa_idx]) {
                add_kmer_to_sequence_list(&bg_seq_table, &bg_seq_list, protein, k, options);
              }
            }
          }
        }
      }
    }
  }
}
void add_background_sequences_to_table ( MOMO_OPTIONS_T * options , SUMMARY_T * summary , SEQ_T * * protein_database_sequences , int num_sequences ) { if ( options -> algorithm == Motifx || options -> algorithm == Modl ) { int i ; int j ; int k ; ARRAYLST_T * mod_table_keys = summary -> mod_table_keys ; const char * alph_letters = summary -> alph_letters ; for ( i = 0 ; i < arraylst_size ( mod_table_keys ) ; ++ i ) { MOD_INFO_T * modinfo = ( MOD_INFO_T * ) hash_get_entry_value ( arraylst_get ( i , mod_table_keys ) ) ; ARRAYLST_T * bg_seq_list = arraylst_create ( ) ; HASH_TABLE bg_seq_table = ( options -> eliminate_repeat_width ) ? hash_create ( DATA_HASH_SIZE , NULL ) : NULL ; modinfo -> bg_seq_list = bg_seq_list ; modinfo -> bg_seq_table = bg_seq_table ; bool * amino_acids = modinfo -> amino_acids ; for ( j = 0 ; j < num_sequences ; ++ j ) { char * protein = get_raw_sequence ( protein_database_sequences [ j ] ) ; for ( k = 0 ; k < strlen ( protein ) ; ++ k ) { if ( options -> bg_filetype == Fasta || ( options -> bg_filetype == Prealigned && k == options -> width / 2 ) ) { char * alph_letters_substring = strchr ( alph_letters , protein [ k ] ) ; if ( alph_letters_substring ) { int aa_idx = alph_letters_substring - alph_letters ; if ( amino_acids [ aa_idx ] ) { add_kmer_to_sequence_list ( & bg_seq_table , & bg_seq_list , protein , k , options ) ; } } } } } } } }
Given a list of sequences, set the background sequences for all modifications.
Given a list of sequences set the background sequences for all modifications .
// for each mod // initialize the background table and list // amino acids for this mod // for each sequence // if FASTA, we need to search the entire protein