deps/kb_meme/meme-5.0.1/src/prior-reader-from-psp.c
/******************************************************************************
 * Read from the current position in the file to the first prior after the
 * start of the next sequence. Set the value of the current sequence.
 *
 * Returns true if it was able to advance to the next sequence, false if 
 * EOF reached before the next sequence was found. Dies if other errors
 * encountered.
 *****************************************************************************/
Read from the current position in the file to the first prior after the
start of the next sequence. Set the value of the current sequence.

Returns true if it was able to advance to the next sequence, false if
EOF reached before the next sequence was found. Dies if other errors
encountered.
Read from the current position in the file to the first prior after the start of the next sequence . Set the value of the current sequence . Returns true if it was able to advance to the next sequence false if EOF reached before the next sequence was found . Dies if other errors encountered .
bool go_to_next_sequence_in_psp(
  DATA_BLOCK_READER_T *reader
) {
  bool result = false;
  PSP_DATA_BLOCK_READER_T *psp_reader 
    = (PSP_DATA_BLOCK_READER_T *) get_data_block_reader_data(reader);
  psp_reader->current_position = 0;
  int c = 0;
  while((c = fgetc(psp_reader->psp_file)) != EOF) {
    if (psp_reader->at_start_of_line == true && c == '>') {
      break;
    }
    else if (c == '\n') {
      psp_reader->at_start_of_line = true;
    }
    else {
      psp_reader->at_start_of_line = false;
    }
  }
  if (c == '>') {
    bool found_genomic_coordinates = false;
    result = read_seq_header_from_psp(psp_reader);
    if (result == true && psp_reader->parse_genomic_coord) {
      found_genomic_coordinates = parse_genomic_coordinates(psp_reader);
    }
    if (found_genomic_coordinates == false) {
      bool found_name = false;
      found_name = parse_seq_name(psp_reader);
      if (found_name == false) {
        die(
            "Unable to find sequence name in header %s.\n",
            psp_reader->sequence_header
        );
      }
    }
  }
  else {
    if (ferror(psp_reader->psp_file)) {
      die(
        "Error reading file:%s.\nError message: %s\n", 
        psp_reader->filename,
        strerror(ferror(psp_reader->psp_file))
      );
    }
    else if (feof(psp_reader->psp_file)) {
        result = false;
    }
  }
  return result;
}
bool go_to_next_sequence_in_psp ( DATA_BLOCK_READER_T * reader ) { bool result = false ; PSP_DATA_BLOCK_READER_T * psp_reader = ( PSP_DATA_BLOCK_READER_T * ) get_data_block_reader_data ( reader ) ; psp_reader -> current_position = 0 ; int c = 0 ; while ( ( c = fgetc ( psp_reader -> psp_file ) ) != EOF ) { if ( psp_reader -> at_start_of_line == true && c == ' ' ) { break ; } else if ( c == ' \n ' ) { psp_reader -> at_start_of_line = true ; } else { psp_reader -> at_start_of_line = false ; } } if ( c == ' ' ) { bool found_genomic_coordinates = false ; result = read_seq_header_from_psp ( psp_reader ) ; if ( result == true && psp_reader -> parse_genomic_coord ) { found_genomic_coordinates = parse_genomic_coordinates ( psp_reader ) ; } if ( found_genomic_coordinates == false ) { bool found_name = false ; found_name = parse_seq_name ( psp_reader ) ; if ( found_name == false ) { die ( " \n " , psp_reader -> sequence_header ) ; } } } else { if ( ferror ( psp_reader -> psp_file ) ) { die ( " \n \n " , psp_reader -> filename , strerror ( ferror ( psp_reader -> psp_file ) ) ) ; } else if ( feof ( psp_reader -> psp_file ) ) { result = false ; } } return result ; }
Read from the current position in the file to the first prior after the
 start of the next sequence.
Read from the current position in the file to the first prior after the start of the next sequence .
// At this point c is '>' or EOF // Look for genomic coordinates in header //  Look for whitespace in header //  The sequence name is the string before the white space. // Reached EOF before reaching the start of the sequence