deps/kb_meme/meme-5.0.1/src/tomtom.c
/*****************************************************************************
 * outputs the xml for a motif.
 *
 * Rather than using the motif id embeded in the motif object a passed string is
 * printed. This is because the motif may have been reverse complemented and the
 * strand printed on the front of the id (and the caller may not want that in 
 * the file). As query and target motifs may have conflicting ids a prefix
 * is appended to ensure uniqueness.
 *
 * The indent and tab strings specifiy respectivly, the text string appended to the
 * front of each line, and the text string appended in front of nested tags.
 * 
 * the buffer must be expandable using realloc and the buffer_len must be set
 * to reflect the currently allocated size or zero if the buffer is unallocated
 * and set to null.
 *****************************************************************************/
outputs the xml for a motif.
Rather than using the motif id embeded in the motif object a passed string is
printed. This is because the motif may have been reverse complemented and the
strand printed on the front of the id (and the caller may not want that in
the file). As query and target motifs may have conflicting ids a prefix
is appended to ensure uniqueness.

The indent and tab strings specifiy respectivly, the text string appended to the
front of each line, and the text string appended in front of nested tags.

the buffer must be expandable using realloc and the buffer_len must be set
to reflect the currently allocated size or zero if the buffer is unallocated
and set to null.
outputs the xml for a motif . Rather than using the motif id embeded in the motif object a passed string is printed . This is because the motif may have been reverse complemented and the strand printed on the front of the id ( and the caller may not want that in the file ) . As query and target motifs may have conflicting ids a prefix is appended to ensure uniqueness . The indent and tab strings specifiy respectivly the text string appended to the front of each line and the text string appended in front of nested tags . the buffer must be expandable using realloc and the buffer_len must be set to reflect the currently allocated size or zero if the buffer is unallocated and set to null .
static void print_xml_motif(FILE *file, int db, MOTIF_T *motif, char *indent, char *tab) {
  int i, j, len;
  char *id, *alt, *url;
  STR_T *b;
  ALPH_T *alph;
  MATRIX_T *freqs;
  double A, C, G, T, log_ev;
  b = str_create(10);
  id = get_motif_id(motif);
  alph = get_motif_alph(motif);
  alt = get_motif_id2(motif);
  len = get_motif_length(motif);
  url = get_motif_url(motif);
  freqs = get_motif_freqs(motif);
  log_ev = get_motif_log_evalue(motif);
  fprintf(file, "%s<motif ", indent);
  fprintf(file, "db=\"%d\" id=\"%s\" ", db, xmlify(id, b, true));
  if (alt && alt[0] != '\0') fprintf(file, "alt=\"%s\" ", xmlify(alt, b, true));
  fprintf(file, "length=\"%d\"", len);
  if (get_motif_nsites(motif) > 0)
    fprintf(file, " nsites=\"%g\"", get_motif_nsites(motif));
  if (log_ev > -HUGE_VAL && log_ev < HUGE_VAL)
    fprintf(file, " evalue=\"%s\"", str_evalue(b, log_ev, 1));
  if (url && url[0] != '\0') {
    fprintf(file, "\n%s%s%surl=\"%s\"", indent, tab, tab, xmlify(url, b, true));
  }
  fprintf(file, ">\n");
  for (i = 0; i < len; ++i) {
    fprintf(file, "%s%s<pos", indent, tab);
    for (j = 0; j < alph_size_core(alph); j++) {
      fprintf(file, " %s=\"%g\"", alph_xml_id(alph, j, b),
          get_matrix_cell(i, j, freqs));
    }
    fprintf(file, "/>\n");
  }
  fprintf(file, "%s</motif>\n", indent);
  str_destroy(b, false);
}
static void print_xml_motif ( FILE * file , int db , MOTIF_T * motif , char * indent , char * tab ) { int i , j , len ; char * id , * alt , * url ; STR_T * b ; ALPH_T * alph ; MATRIX_T * freqs ; double A , C , G , T , log_ev ; b = str_create ( 10 ) ; id = get_motif_id ( motif ) ; alph = get_motif_alph ( motif ) ; alt = get_motif_id2 ( motif ) ; len = get_motif_length ( motif ) ; url = get_motif_url ( motif ) ; freqs = get_motif_freqs ( motif ) ; log_ev = get_motif_log_evalue ( motif ) ; fprintf ( file , " " , indent ) ; fprintf ( file , " \" \" \" \" " , db , xmlify ( id , b , true ) ) ; if ( alt && alt [ 0 ] != ' \0 ' ) fprintf ( file , " \" \" " , xmlify ( alt , b , true ) ) ; fprintf ( file , " \" \" " , len ) ; if ( get_motif_nsites ( motif ) > 0 ) fprintf ( file , " \" \" " , get_motif_nsites ( motif ) ) ; if ( log_ev > - HUGE_VAL && log_ev < HUGE_VAL ) fprintf ( file , " \" \" " , str_evalue ( b , log_ev , 1 ) ) ; if ( url && url [ 0 ] != ' \0 ' ) { fprintf ( file , " \n \" \" " , indent , tab , tab , xmlify ( url , b , true ) ) ; } fprintf ( file , " \n " ) ; for ( i = 0 ; i < len ; ++ i ) { fprintf ( file , " " , indent , tab ) ; for ( j = 0 ; j < alph_size_core ( alph ) ; j ++ ) { fprintf ( file , " \" \" " , alph_xml_id ( alph , j , b ) , get_matrix_cell ( i , j , freqs ) ) ; } fprintf ( file , " \n " ) ; } fprintf ( file , " \n " , indent ) ; str_destroy ( b , false ) ; }
outputs the xml for a motif.
outputs the xml for a motif .