deps/kb_meme/meme-5.0.1/src/momo-input.c
/**
 * If a protein database is provided, parse the sequences
 */
If a protein database is provided, parse the sequences
If a protein database is provided parse the sequences
void read_protein_database_sequences(MOMO_OPTIONS_T* options,
                                     SUMMARY_T* summary,
                                     SEQ_T*** all_sequences,
                                     int* num_sequences) {
  char* protein_database_filename = options->protein_database_filename;
  ALPH_T* alph = summary->alph;
  if (protein_database_filename) {
    FILE *fp = fopen(protein_database_filename, "r");
    if (fp == NULL) {
      fprintf(stderr, "Cannot open the protein database file `%s'.\n", protein_database_filename);
      exit(1);
    }
    int c;
    int previous_c = '\n';
    bool is_fasta = false;
    while ((c = getc(fp)) != EOF) {
      if (! (c == ' ' || c == '\t' || c == '\n')) {	
        if (c == '>' && previous_c == '\n') {		
          is_fasta = true;
        } else if (c == '>') {
	  die("Unknown file type: the '>' of FASTA ID lines must be the first character in a line.\n");
        }
        ungetc(c, fp);					
        break;
      }
      previous_c = c;
    }
    if (is_fasta) {
      read_many_fastas(alph, fp, MAX_SEQ, num_sequences, all_sequences);
    } else { 
      read_many_line_delimited_sequences(alph, fp, MAX_SEQ, num_sequences, options->width, all_sequences);
    }
    fclose(fp);
    options->bg_filetype = is_fasta ? Fasta : Prealigned;
    if (! is_fasta) options->hash_fasta = false;
  }
}
void read_protein_database_sequences ( MOMO_OPTIONS_T * options , SUMMARY_T * summary , SEQ_T * * * all_sequences , int * num_sequences ) { char * protein_database_filename = options -> protein_database_filename ; ALPH_T * alph = summary -> alph ; if ( protein_database_filename ) { FILE * fp = fopen ( protein_database_filename , " " ) ; if ( fp == NULL ) { fprintf ( stderr , " \n " , protein_database_filename ) ; exit ( 1 ) ; } int c ; int previous_c = ' \n ' ; bool is_fasta = false ; while ( ( c = getc ( fp ) ) != EOF ) { if ( ! ( c == ' ' || c == ' \t ' || c == ' \n ' ) ) { if ( c == ' ' && previous_c == ' \n ' ) { is_fasta = true ; } else if ( c == ' ' ) { die ( " \n " ) ; } ungetc ( c , fp ) ; break ; } previous_c = c ; } if ( is_fasta ) { read_many_fastas ( alph , fp , MAX_SEQ , num_sequences , all_sequences ) ; } else { read_many_line_delimited_sequences ( alph , fp , MAX_SEQ , num_sequences , options -> width , all_sequences ) ; } fclose ( fp ) ; options -> bg_filetype = is_fasta ? Fasta : Prealigned ; if ( ! is_fasta ) options -> hash_fasta = false ; } }
If a protein database is provided, parse the sequences
If a protein database is provided parse the sequences
// Determine if file is FASTA format or not. // non-whitespace found // FASTA ID line found // push back first non-whitespace // else Prealigned