deps/kb_meme/meme-5.0.1/src/display.c
/**********************************************************************
  print_meme_model_xml

  Print XML elements for the model. See DTD embeded in
  print_meme_header_xml for the description of model XML syntax.
***********************************************************************/
print_meme_model_xml
Print XML elements for the model. See DTD embeded in
print_meme_header_xml for the description of model XML syntax.
print_meme_model_xml Print XML elements for the model . See DTD embeded in print_meme_header_xml for the description of model XML syntax .
static void print_meme_model_xml(
  MODEL *model,          
  DATASET *dataset,      
  char* stopping_reason, 
  FILE* outfile          
) {
  char evt_string[12];
  STR_T *b;
  b = str_create(10);
  if (dataset->evt == BIG) {
    strcpy(evt_string, "inf");
  } else {
    sprintf(evt_string, "%g", dataset->evt);
  }
  char *hostname;
  hostname = HOSTNAME;
  if (hostname[0] == '\0') {
    hostname = "unknown";
  }
  fprintf(
    outfile,
    "<model>\n"
    "<command_line>%s</command_line>\n",
    xmlify(dataset->command, b, false)
  );
  fprintf(
    outfile,
    "<host>%s</host>\n"
    "<type>%s</type>\n"
    "<nmotifs>%d</nmotifs>\n"
    "<evalue_threshold>%s</evalue_threshold>\n"
    "<object_function>%s%s</object_function>\n"
    "<spfun>%s</spfun>\n"
    "<min_width>%d</min_width>\n"
    "<max_width>%d</max_width>\n",
    xmlify(hostname, b, false),
    dataset->mod, dataset->nmotifs, evt_string,
    (dataset->objfun == Classic) ? "E-value of product of p-values"
      : (dataset->objfun == NC) ? "E-value of log likelihood ratio"
	: (dataset->objfun == DE) ? "Differential Enrichment"
	  : (dataset->objfun == SE) ? "Selective"
	    : (dataset->objfun == CE) ? "Central Enrichment"
	      : (dataset->objfun == CD) ? "Central Enrichment: p-value of mean distance"
		: (dataset->objfun == NZ) ? "Noise-injected"
		  : "Unknown objective function",
    (dataset->test == mHG) ? " mHG"
      : (dataset->test == mBN) ? " mBN"
        : (dataset->test == mRS) ? " mRS"
          : "", 
    (dataset->objfun == Classic && !dataset->use_llr) ? "E-value of product of p-values"
      : (dataset->objfun == CE) ? "Central Enrichment binomial test"
        : (dataset->objfun == CD) ? "Mean distance of best site from sequence center"
          : "log likelihood ratio (LLR)",
    model->min_w, model->max_w
  );
  if (dataset->ma_adj) {
    fprintf(
      outfile,
      "<wg>%g</wg>\n"
      "<ws>%g</ws>\n"
      "<endgaps>%s</endgaps>\n",
      dataset->wg, dataset->ws, yesno[dataset->endgaps]);
  }
  fprintf(
    outfile,
    "<substring>%s</substring>\n",
    (dataset->p_point->c > 0) ? "no" : "yes");
  fprintf(
    outfile,
    "<minsites>%g</minsites>\n"
    "<maxsites>%g</maxsites>\n"
    "<wnsites>%g</wnsites>\n"
    "<spmap>%s</spmap>\n",
    dataset->min_nsites, dataset->max_nsites, dataset->wnsites,
    xmlify(dataset->mapname, b, false)
  );
  fprintf(
    outfile,
    "<spfuzz>%g</spfuzz>\n"
    "<prior>%s</prior>\n"
    "<beta>%g</beta>\n"
    "<maxiter>%d</maxiter>\n"
    "<distance>%g</distance>\n"
    "<num_positions>%d</num_positions>\n"
    "<seed>%d</seed>\n"
    "<hsfrac>%g</hsfrac>\n"
    "<searchsize>%d</searchsize>\n"
    "<maxsize>%d</maxsize>\n"
    "<norand>%s</norand>\n",
    dataset->map_scale,
    xmlify(dataset->priorname, b, false),
    dataset->beta, dataset->maxiter, dataset->distance,
    dataset->total_res, dataset->seed, 
    dataset->hsfrac, dataset->search_size, dataset->max_size,
    dataset->no_rand ? "yes" : "no"
  );
  if (dataset->objfun == Classic) fprintf(outfile, "<csites>%d</csites>\n", dataset->classic_max_nsites);
  fprintf(outfile, "<strands>%s</strands>\n", 
      (alph_has_complement(dataset->alph) ? (model->invcomp ? "both" : "forward") : "none"));
  fprintf(outfile, "<brief>%d</brief>\n", dataset->brief);
  fprintf(outfile, "<psp_file>");
  if (dataset->pspfile) {
    fprintf(outfile, "%s", xmlify(dataset->pspfile, b, false));
  }
  fprintf(outfile, "</psp_file>\n");
  fprintf(outfile, "<priors_file>");
  if (dataset->plib_name) {
    fprintf(outfile, "%s", xmlify(dataset->plib_name, b, false));
  }
  fprintf(outfile, "</priors_file>\n");
  char *t = stopping_reason;
  while ((t = strchr(t, '\n')) != NULL) { *t = ' '; };
  fprintf(
    outfile,
    "<reason_for_stopping>%s</reason_for_stopping>\n",
    stopping_reason
  );
  char *bfile = dataset->bfile ? dataset->bfile : "--sequences--";
  fprintf(outfile, "<background_frequencies source=\"%s\" order=\"%d\">\n", 
      xmlify(bfile, b, true),
      dataset->back_order);
  fprintf(outfile, "<alphabet_array>\n");
  int i;
  for (i = 0; i < alph_size_core(dataset->alph); i++) {
    fprintf(
      outfile,
      "<value letter_id=\"%s\">%.3g</value>\n",
      alph_xml_id(dataset->alph, i, b),
      get_array_item(i, dataset->back)
    );
  }
  fprintf(outfile, "</alphabet_array>\n");
  fprintf(outfile, "</background_frequencies>\n");
  fprintf(outfile, "</model>\n");
  str_destroy(b, false);
}
static void print_meme_model_xml ( MODEL * model , DATASET * dataset , char * stopping_reason , FILE * outfile ) { char evt_string [ 12 ] ; STR_T * b ; b = str_create ( 10 ) ; if ( dataset -> evt == BIG ) { strcpy ( evt_string , " " ) ; } else { sprintf ( evt_string , " " , dataset -> evt ) ; } char * hostname ; hostname = HOSTNAME ; if ( hostname [ 0 ] == ' \0 ' ) { hostname = " " ; } fprintf ( outfile , " \n " " \n " , xmlify ( dataset -> command , b , false ) ) ; fprintf ( outfile , " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " , xmlify ( hostname , b , false ) , dataset -> mod , dataset -> nmotifs , evt_string , ( dataset -> objfun == Classic ) ? " " : ( dataset -> objfun == NC ) ? " " : ( dataset -> objfun == DE ) ? " " : ( dataset -> objfun == SE ) ? " " : ( dataset -> objfun == CE ) ? " " : ( dataset -> objfun == CD ) ? " " : ( dataset -> objfun == NZ ) ? " " : " " , ( dataset -> test == mHG ) ? " " : ( dataset -> test == mBN ) ? " " : ( dataset -> test == mRS ) ? " " : " " , ( dataset -> objfun == Classic && ! dataset -> use_llr ) ? " " : ( dataset -> objfun == CE ) ? " " : ( dataset -> objfun == CD ) ? " " : " " , model -> min_w , model -> max_w ) ; if ( dataset -> ma_adj ) { fprintf ( outfile , " \n " " \n " " \n " , dataset -> wg , dataset -> ws , yesno [ dataset -> endgaps ] ) ; } fprintf ( outfile , " \n " , ( dataset -> p_point -> c > 0 ) ? " " : " " ) ; fprintf ( outfile , " \n " " \n " " \n " " \n " , dataset -> min_nsites , dataset -> max_nsites , dataset -> wnsites , xmlify ( dataset -> mapname , b , false ) ) ; fprintf ( outfile , " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " , dataset -> map_scale , xmlify ( dataset -> priorname , b , false ) , dataset -> beta , dataset -> maxiter , dataset -> distance , dataset -> total_res , dataset -> seed , dataset -> hsfrac , dataset -> search_size , dataset -> max_size , dataset -> no_rand ? " " : " " ) ; if ( dataset -> objfun == Classic ) fprintf ( outfile , " \n " , dataset -> classic_max_nsites ) ; fprintf ( outfile , " \n " , ( alph_has_complement ( dataset -> alph ) ? ( model -> invcomp ? " " : " " ) : " " ) ) ; fprintf ( outfile , " \n " , dataset -> brief ) ; fprintf ( outfile , " " ) ; if ( dataset -> pspfile ) { fprintf ( outfile , " " , xmlify ( dataset -> pspfile , b , false ) ) ; } fprintf ( outfile , " \n " ) ; fprintf ( outfile , " " ) ; if ( dataset -> plib_name ) { fprintf ( outfile , " " , xmlify ( dataset -> plib_name , b , false ) ) ; } fprintf ( outfile , " \n " ) ; char * t = stopping_reason ; while ( ( t = strchr ( t , ' \n ' ) ) != NULL ) { * t = ' ' ; } ; fprintf ( outfile , " \n " , stopping_reason ) ; char * bfile = dataset -> bfile ? dataset -> bfile : " " ; fprintf ( outfile , " \" \" \" \" \n " , xmlify ( bfile , b , true ) , dataset -> back_order ) ; fprintf ( outfile , " \n " ) ; int i ; for ( i = 0 ; i < alph_size_core ( dataset -> alph ) ; i ++ ) { fprintf ( outfile , " \" \" \n " , alph_xml_id ( dataset -> alph , i , b ) , get_array_item ( i , dataset -> back ) ) ; } fprintf ( outfile , " \n " ) ; fprintf ( outfile , " \n " ) ; fprintf ( outfile , " \n " ) ; str_destroy ( b , false ) ; }
print_meme_model_xml
Print XML elements for the model.
print_meme_model_xml Print XML elements for the model .
// the model IN  // the dataset IN  // reason for stopping IN  // output file IN  // The position-specific priors file. // The model priors file. // Replace any newlines in stopping_reason with spaces.