Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/fastqreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void FastqReader::readToBufIgzip(){
if (mGzipState.avail_in == 0) {
mGzipState.next_in = mGzipInputBuffer;
mGzipState.avail_in = fread(mGzipState.next_in, 1, mGzipInputBufferSize, mFile);
check_error();
mGzipInputUsedBytes += mGzipState.avail_in;
}
mGzipState.next_out = mGzipOutputBuffer;
Expand All @@ -105,6 +106,7 @@ void FastqReader::readToBufIgzip(){
isal_inflate_reset(&mGzipState);
mGzipState.next_in = mGzipInputBuffer;
mGzipState.avail_in = fread(mGzipState.next_in, 1, mGzipInputBufferSize, mFile);
check_error();
mGzipInputUsedBytes += mGzipState.avail_in;
} else if (mGzipState.avail_in >= GZIP_HEADER_BYTES_REQ){
unsigned char* old_next_in = mGzipState.next_in;
Expand All @@ -118,6 +120,7 @@ void FastqReader::readToBufIgzip(){
size_t added = 0;
if(!eof()) {
added = fread(mGzipInputBuffer + mGzipState.avail_in, 1, mGzipInputBufferSize - mGzipState.avail_in, mFile);
check_error();
mGzipInputUsedBytes += added;
}
isal_inflate_reset(&mGzipState);
Expand Down Expand Up @@ -146,6 +149,7 @@ void FastqReader::readToBuf() {
} else {
if(!eof())
mBufDataLen = fread(mFastqBuf, 1, FQ_BUF_SIZE, mFile);
check_error();
}
mBufUsedLen = 0;

Expand All @@ -166,6 +170,7 @@ void FastqReader::init(){
mGzipState.crc_flag = ISAL_GZIP_NO_HDR_VER;
mGzipState.next_in = mGzipInputBuffer;
mGzipState.avail_in = fread(mGzipState.next_in, 1, mGzipInputBufferSize, mFile);
check_error();
mGzipInputUsedBytes += mGzipState.avail_in;
int ret = isal_read_gzip_header(&mGzipState, &mGzipHeader);
if (ret != ISAL_DECOMP_OK) {
Expand Down Expand Up @@ -216,6 +221,13 @@ bool FastqReader::eof() {
return feof(mFile);//mFile.eof();
}

void FastqReader::check_error() {
if(ferror(mFile)) {
std::perror("reading fastq failed");
error_exit("Failed reading: " + mFilename);
}
}

void FastqReader::getLine(string* line){
int copied = 0;

Expand Down
1 change: 1 addition & 0 deletions src/fastqreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class FastqReader{
//do not call read() of a same FastqReader object from different threads concurrently
Read* read();
bool eof();
void check_error();
bool hasNoLineBreakAtEnd();
void setReadPool(ReadPool* rp);

Expand Down