deps/kb_meme/meme-5.0.1/src/motif-in.c
/*
 * create the reader passing an optional
 * filename to help determine the most
 * likely file type.
 */
create the reader passing an optional
filename to help determine the most
likely file type.
create the reader passing an optional filename to help determine the most likely file type .
MREAD_T* mread_create(
  const char *filename, 
  int options, 
  bool symmetrical	
) {
  MREAD_T * mread = mm_malloc(sizeof(MREAD_T));
  memset(mread, 0, sizeof(MREAD_T));
  if (filename) mread->filename = strdup(filename);
  if (options & OPEN_MFILE) {
    if (strcmp(filename, "-") == 0) {
      mread->fp = stdin;
    } else {
      mread->fp = fopen(filename, "r");
      if (!mread->fp) die("Failed to open motif file: %s\n", filename);
    }
  }
  mread->options = options;
  mread->valid = 0;
  mread->total = 0;
  mread->count = 0;
  mread->conv_alph = NULL;
  mread->pseudo_total = 0;
  mread->other_bg_src = strdup("--motif--");
  mread->symmetrical = symmetrical;
  add_format(mread, "MEME XML", mxml_create, mxml_destroy, mxml_update,
      mxml_has_format_match, mxml_has_warning, mxml_next_warning,
      mxml_has_error, mxml_next_error, 
      mxml_has_motif, mxml_next_motif, mxml_get_alphabet, mxml_get_strands, 
      mxml_get_bg, mxml_motif_optional, mxml_file_optional);
  add_format(mread, "MEME HTML", mhtml_create, mhtml_destroy, mhtml_update,
      mhtml_has_format_match, NULL, NULL, mhtml_has_error, mhtml_next_error, 
      mhtml_has_motif, mhtml_next_motif, mhtml_get_alphabet, mhtml_get_strands,
      mhtml_get_bg, mhtml_motif_optional, mhtml_file_optional);
  add_format(mread, "MEME HTML+JSON", mhtml2_create, mhtml2_destroy, mhtml2_update,
      mhtml2_has_format_match, mhtml2_has_warning, mhtml2_next_warning,
      mhtml2_has_error, mhtml2_next_error, 
      mhtml2_has_motif, mhtml2_next_motif, mhtml2_get_alphabet, mhtml2_get_strands,
      mhtml2_get_bg, mhtml2_motif_optional, mhtml2_file_optional);
  add_format(mread, "MEME text", mtext_create, mtext_destroy, mtext_update,
      mtext_has_format_match, mtext_has_warning, mtext_next_warning, mtext_has_error, mtext_next_error,
      mtext_has_motif, mtext_next_motif, mtext_get_alphabet, mtext_get_strands,
      mtext_get_bg, mtext_motif_optional, mtext_file_optional);
  add_format(mread, "DREME XML", dxml_create, dxml_destroy, dxml_update,
      dxml_has_format_match, dxml_has_warning, dxml_next_warning, dxml_has_error, dxml_next_error, 
      dxml_has_motif, dxml_next_motif, dxml_get_alphabet, dxml_get_strands,
      dxml_get_bg, dxml_motif_optional, dxml_file_optional);
  return mread;
}
MREAD_T * mread_create ( const char * filename , int options , bool symmetrical ) { MREAD_T * mread = mm_malloc ( sizeof ( MREAD_T ) ) ; memset ( mread , 0 , sizeof ( MREAD_T ) ) ; if ( filename ) mread -> filename = strdup ( filename ) ; if ( options & OPEN_MFILE ) { if ( strcmp ( filename , " " ) == 0 ) { mread -> fp = stdin ; } else { mread -> fp = fopen ( filename , " " ) ; if ( ! mread -> fp ) die ( " \n " , filename ) ; } } mread -> options = options ; mread -> valid = 0 ; mread -> total = 0 ; mread -> count = 0 ; mread -> conv_alph = NULL ; mread -> pseudo_total = 0 ; mread -> other_bg_src = strdup ( " " ) ; mread -> symmetrical = symmetrical ; add_format ( mread , " " , mxml_create , mxml_destroy , mxml_update , mxml_has_format_match , mxml_has_warning , mxml_next_warning , mxml_has_error , mxml_next_error , mxml_has_motif , mxml_next_motif , mxml_get_alphabet , mxml_get_strands , mxml_get_bg , mxml_motif_optional , mxml_file_optional ) ; add_format ( mread , " " , mhtml_create , mhtml_destroy , mhtml_update , mhtml_has_format_match , NULL , NULL , mhtml_has_error , mhtml_next_error , mhtml_has_motif , mhtml_next_motif , mhtml_get_alphabet , mhtml_get_strands , mhtml_get_bg , mhtml_motif_optional , mhtml_file_optional ) ; add_format ( mread , " " , mhtml2_create , mhtml2_destroy , mhtml2_update , mhtml2_has_format_match , mhtml2_has_warning , mhtml2_next_warning , mhtml2_has_error , mhtml2_next_error , mhtml2_has_motif , mhtml2_next_motif , mhtml2_get_alphabet , mhtml2_get_strands , mhtml2_get_bg , mhtml2_motif_optional , mhtml2_file_optional ) ; add_format ( mread , " " , mtext_create , mtext_destroy , mtext_update , mtext_has_format_match , mtext_has_warning , mtext_next_warning , mtext_has_error , mtext_next_error , mtext_has_motif , mtext_next_motif , mtext_get_alphabet , mtext_get_strands , mtext_get_bg , mtext_motif_optional , mtext_file_optional ) ; add_format ( mread , " " , dxml_create , dxml_destroy , dxml_update , dxml_has_format_match , dxml_has_warning , dxml_next_warning , dxml_has_error , dxml_next_error , dxml_has_motif , dxml_next_motif , dxml_get_alphabet , dxml_get_strands , dxml_get_bg , dxml_motif_optional , dxml_file_optional ) ; return mread ; }
create the reader passing an optional
 filename to help determine the most
 likely file type.
create the reader passing an optional filename to help determine the most likely file type .
// make background symmetrical if alphabet is complementable // create readers of each format