deps/kb_meme/meme-5.0.1/src/momo-input.c
/**
 * Adds a kmer to a sequence list (and table if eliminate repeats) can refer to either bg or fg sequences
 */
Adds a kmer to a sequence list (and table if eliminate repeats) can refer to either bg or fg sequences
Adds a kmer to a sequence list ( and table if eliminate repeats ) can refer to either bg or fg sequences
void add_kmer_to_sequence_list(HASH_TABLE* seq_table, ARRAYLST_T** seq_list, char* sequence, int idx, MOMO_OPTIONS_T* options
  ) {
  int motif_width = options->width;
  int eliminate_repeat_width = options->eliminate_repeat_width;
  char* eliminate_repeat_str = mm_malloc(eliminate_repeat_width + 1);
  set_kmer(&eliminate_repeat_str, sequence, idx - eliminate_repeat_width/2, eliminate_repeat_width);
  char* motif_str = mm_malloc(motif_width + 1);
  set_kmer(&motif_str, sequence, idx - motif_width/2, motif_width);
  bool contains_unknowns = strchr(motif_str, 'X');
  if (!(options->remove_unknowns && contains_unknowns)) {
    SEQ_T* newsequence = allocate_seq("tempname", "tempdescription", 0, motif_str);
    if (eliminate_repeat_width) {
      if (!hash_lookup_str(eliminate_repeat_str, *seq_table)) {
        hash_insert_str_value(eliminate_repeat_str, newsequence, *seq_table);
        HASH_TABLE_ENTRY* hash_entry = hash_lookup_str(eliminate_repeat_str, *seq_table);
        arraylst_add(hash_entry, *seq_list);
      } else {
        free_seq(newsequence);
      }
    } else {
      arraylst_add(newsequence, *seq_list);
    }
  }
  myfree(eliminate_repeat_str);
  myfree(motif_str);
}
void add_kmer_to_sequence_list ( HASH_TABLE * seq_table , ARRAYLST_T * * seq_list , char * sequence , int idx , MOMO_OPTIONS_T * options ) { int motif_width = options -> width ; int eliminate_repeat_width = options -> eliminate_repeat_width ; char * eliminate_repeat_str = mm_malloc ( eliminate_repeat_width + 1 ) ; set_kmer ( & eliminate_repeat_str , sequence , idx - eliminate_repeat_width / 2 , eliminate_repeat_width ) ; char * motif_str = mm_malloc ( motif_width + 1 ) ; set_kmer ( & motif_str , sequence , idx - motif_width / 2 , motif_width ) ; bool contains_unknowns = strchr ( motif_str , ' ' ) ; if ( ! ( options -> remove_unknowns && contains_unknowns ) ) { SEQ_T * newsequence = allocate_seq ( " " , " " , 0 , motif_str ) ; if ( eliminate_repeat_width ) { if ( ! hash_lookup_str ( eliminate_repeat_str , * seq_table ) ) { hash_insert_str_value ( eliminate_repeat_str , newsequence , * seq_table ) ; HASH_TABLE_ENTRY * hash_entry = hash_lookup_str ( eliminate_repeat_str , * seq_table ) ; arraylst_add ( hash_entry , * seq_list ) ; } else { free_seq ( newsequence ) ; } } else { arraylst_add ( newsequence , * seq_list ) ; } } myfree ( eliminate_repeat_str ) ; myfree ( motif_str ) ; }
Adds a kmer to a sequence list (and table if eliminate repeats) can refer to either bg or fg sequences
Adds a kmer to a sequence list ( and table if eliminate repeats ) can refer to either bg or fg sequences
// Set up variables // Create eliminate_repeat_str and motif_str. This is the mod // along with its flanking amino acids for the respective length. // Store the sequence. // Clean Up