Beispiel #1
0
static CTX_T* create_parser_data(int options, const char *optional_filename) {
    CTX_T *data;
    data = mm_malloc(sizeof(CTX_T));
    memset(data, 0, sizeof(CTX_T));
    data->options = options;
    data->motif_queue = linklst_create();
    data->errors = linklst_create();
    data->file_type_match = file_name_match("dreme", "xml", optional_filename);
    return data;
}
Beispiel #2
0
/*****************************************************************************
 * Creates the data to be passed to the SAX parser
 ****************************************************************************/
void* create_dreme_io_xml_sax_context(void *user_data, DREME_IO_XML_CALLBACKS_T *callbacks) {
  PS_T *ps;
  CHARBUF_T *buf;
  ps = (PS_T*)mm_malloc(sizeof(PS_T));
  memset(ps, 0, sizeof(PS_T));
  ps->state = PS_START;
  ps->udepth = 0; 
  ps->callbacks = callbacks;
  ps->user_data = user_data;
  ps->seen_alphabet = false;
  ps->seen_ambig = false;
  ps->alph_ids = rbtree_create(rbtree_strcmp, rbtree_strcpy, free, rbtree_intcpy, free);
  ps->freqs = NULL;
  ps->motif_id = NULL;
  ps->last_pos = 0;
  //set up character buffer
  buf = &(ps->characters);
  buf->buffer = mm_malloc(sizeof(char)*10);
  buf->buffer[0] = '\0';
  buf->size = 10;
  buf->pos = 0;
  attrbuf_init(&(ps->attrbuf));
  //set up expected queue
  ps->expected_stack = linklst_create();
  return ps;
}
Beispiel #3
0
/**************************************************************************
 * Create a group with a good secondary motif and a group
 * of redundant secondary motifs.
 **************************************************************************/
GROUPED_MOTIF_T* create_grouped_motif(SECONDARY_MOTIF_T* best) {
  GROUPED_MOTIF_T *group;
  group = (GROUPED_MOTIF_T*)mm_malloc(sizeof(GROUPED_MOTIF_T));
  group->best = best;
  group->others = linklst_create();
  return group;
}
/*****************************************************************************
 * Create the datastructure for storing motifs while their content is
 * still being parsed.
 ****************************************************************************/
static CTX_T* create_parser_data(int options, const char *optional_file_name) {
  CTX_T *data;
  data = (CTX_T*)mm_malloc(sizeof(CTX_T));
  memset(data, 0, sizeof(CTX_T));
  data->format_match = file_name_match("meme", "xml", optional_file_name);
  data->warnings = linklst_create();
  data->errors = linklst_create();
  data->motif_queue = linklst_create();
  data->options = options;
  data->letter_lookup = rbtree_create(rbtree_strcmp, rbtree_strcpy, free, rbtree_strcpy, free);
  data->alph = NULL;
  data->alph_rdr = NULL;
  data->nums = NULL;
  if (options & SCANNED_SITES) {
    data->sequence_lookup = rbtree_create(rbtree_strcmp, rbtree_strcpy, free, NULL, destroy_seqinfo);
    data->motif_lookup = rbtree_create(rbtree_strcmp, rbtree_strcpy, free, rbtree_intcpy, free);
  }  
  return data;
}
Beispiel #5
0
/*
 * jsonwr_open
 * Opens a JSON writer which aims to make human readable JSON
 * indented min_cols with each sub-section indented another tab_cols
 * aiming for a maximum line length of line_cols.
 */
JSONWR_T* jsonwr_open(FILE *dest, int min_cols, int tab_cols, int line_cols) {
  JSONWR_T *jsonwr;
  jsonwr = mm_malloc(sizeof(JSONWR_T));
  memset(jsonwr, 0, sizeof(JSONWR_T));
  jsonwr->file = dest;
  jsonwr->min_cols = min_cols;
  jsonwr->tab_cols = tab_cols;
  jsonwr->line_cols = line_cols;
  jsonwr->indent = min_cols + tab_cols;
  jsonwr->column = 0;
  jsonwr->value_buf = str_create(10);
  jsonwr->line_buf = str_create(line_cols);
  jsonwr->state = JSON_EMPTY_OBJECT;
  jsonwr->stack = linklst_create();
  push_state(jsonwr->stack, JSON_DONE);
  fputc('{', jsonwr->file);
  return jsonwr;
}
Beispiel #6
0
/*****************************************************************************
 * Creates the data to be passed to the SAX parser
 ****************************************************************************/
void* create_dreme_io_xml_sax_context(void *user_data, DREME_IO_XML_CALLBACKS_T *callbacks) {
  PS_T *ps;
  CHARBUF_T *buf;
  ps = (PS_T*)mm_malloc(sizeof(PS_T));
  memset(ps, 0, sizeof(PS_T));
  ps->state = PS_START;
  ps->udepth = 0; 
  ps->callbacks = callbacks;
  ps->user_data = user_data;
  ps->motif_id = NULL;
  ps->last_pos = 0;
  //set up character buffer
  buf = &(ps->characters);
  buf->buffer = mm_malloc(sizeof(char)*10);
  buf->buffer[0] = '\0';
  buf->size = 10;
  buf->pos = 0;
  //set up expected queue
  ps->expected_stack = linklst_create();
  return ps;
}