deps/kb_meme/meme-5.0.1/src/seq-reader-from-fasta.c
/******************************************************************************
 * This function creates an instance of a data block reader UDT for reading
 * sequence segments from a FASTA file.
 *****************************************************************************/
This function creates an instance of a data block reader UDT for reading
sequence segments from a FASTA file.
This function creates an instance of a data block reader UDT for reading sequence segments from a FASTA file .
DATA_BLOCK_READER_T *new_seq_reader_from_fasta(
  bool parse_genomic_coord, 
  ALPH_T *alph, 
  const char *filename
) {
  SEQ_READER_FROM_FASTA_T *fasta_reader = mm_malloc(sizeof(SEQ_READER_FROM_FASTA_T) * 1);
  fasta_reader->at_end_of_file = false;
  fasta_reader->at_start_of_line = true;
  fasta_reader->at_end_of_seq = false;
  fasta_reader->parse_genomic_coord = parse_genomic_coord;
  int filename_len = strlen(filename) + 1;
  fasta_reader->filename = mm_malloc(sizeof(char)* filename_len);
  fasta_reader->filename_len = filename_len;
  strncpy(fasta_reader->filename, filename, filename_len);
  fasta_reader->prev_block_position = 0;
  fasta_reader->current_position = 0;
  fasta_reader->seq_header = NULL;
  fasta_reader->seq_header_len = 0;
  fasta_reader->seq_name = NULL;
  fasta_reader->seq_name_len = 0;
  fasta_reader->alphabet = alph_hold(alph);
  fasta_reader->seq_buffer = mm_calloc(sizeof(char), BUFFER_SIZE);
  fasta_reader->seq_buffer_index = 0;
  fasta_reader->seq_buffer_last = 0;
  if (
    open_file(
      filename, 
      "r", 
      true, 
      "FASTA", 
      "sequences", 
      &(fasta_reader->fasta_file
    )) == false) {
    die("Couldn't open the file %s.\n", filename);
  }
  DATA_BLOCK_READER_T *reader = new_data_block_reader(
    (void *) fasta_reader,
    free_seq_reader_from_fasta,
    close_seq_reader_from_fasta,
    reset_seq_reader_from_fasta,
    seq_reader_from_fasta_is_eof,
    get_next_data_block_from_seq_reader_from_fasta,
    unget_data_block_from_seq_reader_from_fasta,
    go_to_next_sequence_in_seq_reader_from_fasta,
    get_seq_name_from_seq_reader_from_fasta
  );
  return reader;
}
DATA_BLOCK_READER_T * new_seq_reader_from_fasta ( bool parse_genomic_coord , ALPH_T * alph , const char * filename ) { SEQ_READER_FROM_FASTA_T * fasta_reader = mm_malloc ( sizeof ( SEQ_READER_FROM_FASTA_T ) * 1 ) ; fasta_reader -> at_end_of_file = false ; fasta_reader -> at_start_of_line = true ; fasta_reader -> at_end_of_seq = false ; fasta_reader -> parse_genomic_coord = parse_genomic_coord ; int filename_len = strlen ( filename ) + 1 ; fasta_reader -> filename = mm_malloc ( sizeof ( char ) * filename_len ) ; fasta_reader -> filename_len = filename_len ; strncpy ( fasta_reader -> filename , filename , filename_len ) ; fasta_reader -> prev_block_position = 0 ; fasta_reader -> current_position = 0 ; fasta_reader -> seq_header = NULL ; fasta_reader -> seq_header_len = 0 ; fasta_reader -> seq_name = NULL ; fasta_reader -> seq_name_len = 0 ; fasta_reader -> alphabet = alph_hold ( alph ) ; fasta_reader -> seq_buffer = mm_calloc ( sizeof ( char ) , BUFFER_SIZE ) ; fasta_reader -> seq_buffer_index = 0 ; fasta_reader -> seq_buffer_last = 0 ; if ( open_file ( filename , " " , true , " " , " " , & ( fasta_reader -> fasta_file ) ) == false ) { die ( " \n " , filename ) ; } DATA_BLOCK_READER_T * reader = new_data_block_reader ( ( void * ) fasta_reader , free_seq_reader_from_fasta , close_seq_reader_from_fasta , reset_seq_reader_from_fasta , seq_reader_from_fasta_is_eof , get_next_data_block_from_seq_reader_from_fasta , unget_data_block_from_seq_reader_from_fasta , go_to_next_sequence_in_seq_reader_from_fasta , get_seq_name_from_seq_reader_from_fasta ) ; return reader ; }
This function creates an instance of a data block reader UDT for reading
 sequence segments from a FASTA file.
This function creates an instance of a data block reader UDT for reading sequence segments from a FASTA file .