deps/kb_meme/meme-5.0.1/src/dreme-sax.c
/*****************************************************************************
 * dreme > model > background
 *
 *  type            is the alphabet DNA or RNA (optional when custom alphabet specified)
 *  <symbol>        frequency of <symbol> from core alphabet
 *  from            from the negative dataset or a background file
 *  file            the background file (optional)
 *  last_mod_date   the last modified date of the background file (optional)
 ****************************************************************************/
dreme > model > background
type            is the alphabet DNA or RNA (optional when custom alphabet specified)
        frequency of  from core alphabet
from            from the negative dataset or a background file
file            the background file (optional)
last_mod_date   the last modified date of the background file (optional)
dreme > model > background type is the alphabet DNA or RNA ( optional when custom alphabet specified ) frequency of from core alphabet from from the negative dataset or a background file file the background file ( optional ) last_mod_date the last modified date of the background file ( optional )
static void start_ele_background(PS_T *ps, const xmlChar **attrs) {
  int type, from;
  char *file, *lastmod;
  type = DREME_BG_FROM_DATASET;
  from = DREME_ALPH_DNA;
  file = NULL;
  lastmod = NULL;
  char* type_options[2] = {"dna", "rna"};
  int type_values[2] = {DREME_ALPH_DNA, DREME_ALPH_RNA};
  MULTI_T type_multi = {.count = 2, .options = type_options, 
    .outputs = type_values, .target = &(type)};
  char* from_options[2] = {"dataset", "file"};
  int from_values[2] = {DREME_BG_FROM_DATASET, DREME_BG_FROM_FILE};
  MULTI_T from_multi = {.count = 2, .options = from_options, 
    .outputs = from_values, .target = &(from)};
  char* names[4] = {"file", "from", "last_mod_date", "type"};
  int (*parsers[4])(char*, void*) = {ld_str, ld_multi, ld_str, ld_multi};
  void *data[4] = {&file, &from_multi, &lastmod, &type_multi};
  bool required[4] = {false, true, false, false};
  bool done[4];
  required[3] = !ps->seen_alphabet;
  parse_attributes(dreme_attr_parse_error, ps, "background", attrs, 4, names, parsers, data, required, done);
  if (from == DREME_BG_FROM_FILE) {
    if (!done[0]) dreme_attr_parse_error(ps, PARSE_ATTR_MISSING, "background", "file", NULL);
    if (!done[2]) dreme_attr_parse_error(ps, PARSE_ATTR_MISSING, "background", "last_mod_date", NULL);
  }
  if (!ps->seen_alphabet) {
    int idx = 0;
    rbtree_make(ps->alph_ids, "A", &idx); idx++;
    rbtree_make(ps->alph_ids, "C", &idx); idx++;
    rbtree_make(ps->alph_ids, "G", &idx); idx++;
    rbtree_make(ps->alph_ids, (type == DREME_ALPH_DNA ? "T" : "U"), &idx);
  }
  parse_freq_attrs(ps, "background", attrs);
  if (ps->callbacks->handle_background && ps->state != PS_ERROR) {
    ps->callbacks->handle_background(ps->user_data, rbtree_size(ps->alph_ids), ps->freqs, from, file, lastmod);
  }
}
static void start_ele_background ( PS_T * ps , const xmlChar * * attrs ) { int type , from ; char * file , * lastmod ; type = DREME_BG_FROM_DATASET ; from = DREME_ALPH_DNA ; file = NULL ; lastmod = NULL ; char * type_options [ 2 ] = { " " , " " } ; int type_values [ 2 ] = { DREME_ALPH_DNA , DREME_ALPH_RNA } ; MULTI_T type_multi = { . count = 2 , . options = type_options , . outputs = type_values , . target = & ( type ) } ; char * from_options [ 2 ] = { " " , " " } ; int from_values [ 2 ] = { DREME_BG_FROM_DATASET , DREME_BG_FROM_FILE } ; MULTI_T from_multi = { . count = 2 , . options = from_options , . outputs = from_values , . target = & ( from ) } ; char * names [ 4 ] = { " " , " " , " " , " " } ; int ( * parsers [ 4 ] ) ( char * , void * ) = { ld_str , ld_multi , ld_str , ld_multi } ; void * data [ 4 ] = { & file , & from_multi , & lastmod , & type_multi } ; bool required [ 4 ] = { false , true , false , false } ; bool done [ 4 ] ; required [ 3 ] = ! ps -> seen_alphabet ; parse_attributes ( dreme_attr_parse_error , ps , " " , attrs , 4 , names , parsers , data , required , done ) ; if ( from == DREME_BG_FROM_FILE ) { if ( ! done [ 0 ] ) dreme_attr_parse_error ( ps , PARSE_ATTR_MISSING , " " , " " , NULL ) ; if ( ! done [ 2 ] ) dreme_attr_parse_error ( ps , PARSE_ATTR_MISSING , " " , " " , NULL ) ; } if ( ! ps -> seen_alphabet ) { int idx = 0 ; rbtree_make ( ps -> alph_ids , " " , & idx ) ; idx ++ ; rbtree_make ( ps -> alph_ids , " " , & idx ) ; idx ++ ; rbtree_make ( ps -> alph_ids , " " , & idx ) ; idx ++ ; rbtree_make ( ps -> alph_ids , ( type == DREME_ALPH_DNA ? " " : " " ) , & idx ) ; } parse_freq_attrs ( ps , " " , attrs ) ; if ( ps -> callbacks -> handle_background && ps -> state != PS_ERROR ) { ps -> callbacks -> handle_background ( ps -> user_data , rbtree_size ( ps -> alph_ids ) , ps -> freqs , from , file , lastmod ) ; } }
dreme > model > background
  type            is the alphabet DNA or RNA (optional when custom alphabet specified)
  <symbol>        frequency of <symbol> from core alphabet
  from            from the negative dataset or a background file
  file            the background file (optional)
  last_mod_date   the last modified date of the background file (optional)
dreme > model > background type is the alphabet DNA or RNA ( optional when custom alphabet specified ) <symbol > frequency of <symbol > from core alphabet from from the negative dataset or a background file file the background file ( optional ) last_mod_date the last modified date of the background file ( optional )
// set reasonable defaults // if we haven't seen the alphabet then we must define it from the type