diff --git a/src/libfastx/fastx.c b/src/libfastx/fastx.c index 8d653dd..4cbd288 100644 --- a/src/libfastx/fastx.c +++ b/src/libfastx/fastx.c @@ -321,7 +321,7 @@ int fastx_read_next_record(FASTX *pFASTX) errx(1,"Internal error: pFASTX==NULL (%s:%d)", __FILE__,__LINE__); pFASTX->input_line_number++; - if (fgets(pFASTX->input_sequence_id_prefix, MAX_SEQ_LINE_LENGTH, pFASTX->input) == NULL) + if (fgets(pFASTX->dummy_read_id_buffer, MAX_SEQ_LINE_LENGTH, pFASTX->input) == NULL) return 0; //assume end-of-file, if we couldn't read the first line of the foursome chomp(pFASTX->name); @@ -367,7 +367,7 @@ int fastx_read_next_record(FASTX *pFASTX) if (pFASTX->read_fastq) { pFASTX->input_line_number++; - if (fgets(pFASTX->input_name2_prefix, MAX_SEQ_LINE_LENGTH, pFASTX->input) == NULL) + if (fgets(pFASTX->dummy_read_id2_buffer, MAX_SEQ_LINE_LENGTH, pFASTX->input) == NULL) errx(1,"Failed to read complete record, missing 3rd line (name-2), on line %lld\n", pFASTX->input_line_number); diff --git a/src/libfastx/fastx.h b/src/libfastx/fastx.h index 47e192a..5a8639d 100644 --- a/src/libfastx/fastx.h +++ b/src/libfastx/fastx.h @@ -62,13 +62,23 @@ typedef enum { typedef struct { /* Record data - common for FASTA/FASTQ */ - char input_sequence_id_prefix[1]; //DON'T touch this - this hack will read the entire name into the variable 'name', + union { + struct { + char input_sequence_id_prefix[1]; //DON'T touch this - this hack will read the entire name into the variable 'name', //leaving the prefix ('>' or '@') in 'input_sequence_id_name'. - char name[MAX_SEQ_LINE_LENGTH+1]; + char name[MAX_SEQ_LINE_LENGTH+1]; + }; + char dummy_read_id_buffer[MAX_SEQ_LINE_LENGTH+2]; + }; char nucleotides[MAX_SEQ_LINE_LENGTH+1]; /* Record data - only for FASTQ */ - char input_name2_prefix[1]; //same hack as 'input_sequence_id_prefix' - char name2[MAX_SEQ_LINE_LENGTH+1]; + union { + struct { + char input_name2_prefix[1]; //same hack as 'input_sequence_id_prefix' + char name2[MAX_SEQ_LINE_LENGTH+1]; + }; + char dummy_read_id2_buffer[MAX_SEQ_LINE_LENGTH+2]; + }; int quality[MAX_SEQ_LINE_LENGTH+1]; //note: this is NOT ascii values, but numerical values // numeric quality scores and ASCII quality scores // are automatically converted to numbers (-15 to 93)