deps/kb_meme/meme-5.0.1/src/prior-reader-from-psp.c
/******************************************************************************
 * This function creates an instance of a data block reader UDT for reading
 * priors from a MEME PSP file.
 *****************************************************************************/
This function creates an instance of a data block reader UDT for reading
priors from a MEME PSP file.
This function creates an instance of a data block reader UDT for reading priors from a MEME PSP file .
DATA_BLOCK_READER_T *new_prior_reader_from_psp(bool parse_genomic_coord, const char *filename) {
  PSP_DATA_BLOCK_READER_T *psp_reader = mm_malloc(sizeof(PSP_DATA_BLOCK_READER_T) * 1);
  psp_reader->at_start_of_line = true;
  psp_reader->parse_genomic_coord = parse_genomic_coord;
  int filename_len = strlen(filename) + 1;
  psp_reader->filename = mm_malloc(sizeof(char)* filename_len);
  psp_reader->filename_len = filename_len;
  strncpy(psp_reader->filename, filename, filename_len);
  psp_reader->prev_block_position = 0;
  psp_reader->current_position = 0;
  psp_reader->sequence_header = NULL;
  psp_reader->sequence_header_len = 0;
  psp_reader->sequence_name = NULL;
  psp_reader->sequence_name_len = 0;
  psp_reader->psp_file = fopen(psp_reader->filename, "r");
  if (psp_reader->psp_file == NULL) {
    die(
      "Unable to open file: %s.\nError message: %s.\n", 
      psp_reader->filename, 
      strerror(errno)
    );
  }
  DATA_BLOCK_READER_T *reader = new_data_block_reader(
    (void *) psp_reader,
    free_prior_reader_from_psp,
    close_prior_reader_from_psp,
    reset_prior_reader_from_psp,
    prior_reader_from_psp_is_eof,
    get_next_data_block_from_psp,
    unget_data_block_from_psp,
    go_to_next_sequence_in_psp,
    get_seq_name_from_psp
  );
  return reader;
}
DATA_BLOCK_READER_T * new_prior_reader_from_psp ( bool parse_genomic_coord , const char * filename ) { PSP_DATA_BLOCK_READER_T * psp_reader = mm_malloc ( sizeof ( PSP_DATA_BLOCK_READER_T ) * 1 ) ; psp_reader -> at_start_of_line = true ; psp_reader -> parse_genomic_coord = parse_genomic_coord ; int filename_len = strlen ( filename ) + 1 ; psp_reader -> filename = mm_malloc ( sizeof ( char ) * filename_len ) ; psp_reader -> filename_len = filename_len ; strncpy ( psp_reader -> filename , filename , filename_len ) ; psp_reader -> prev_block_position = 0 ; psp_reader -> current_position = 0 ; psp_reader -> sequence_header = NULL ; psp_reader -> sequence_header_len = 0 ; psp_reader -> sequence_name = NULL ; psp_reader -> sequence_name_len = 0 ; psp_reader -> psp_file = fopen ( psp_reader -> filename , " " ) ; if ( psp_reader -> psp_file == NULL ) { die ( " \n \n " , psp_reader -> filename , strerror ( errno ) ) ; } DATA_BLOCK_READER_T * reader = new_data_block_reader ( ( void * ) psp_reader , free_prior_reader_from_psp , close_prior_reader_from_psp , reset_prior_reader_from_psp , prior_reader_from_psp_is_eof , get_next_data_block_from_psp , unget_data_block_from_psp , go_to_next_sequence_in_psp , get_seq_name_from_psp ) ; return reader ; }
This function creates an instance of a data block reader UDT for reading
 priors from a MEME PSP file.
This function creates an instance of a data block reader UDT for reading priors from a MEME PSP file .
// Setup "Virtual" function table