Skip to content

Commit

Permalink
support stdin for FastqReader
Browse files Browse the repository at this point in the history
  • Loading branch information
sfchen committed Aug 1, 2018
1 parent fc84cbd commit e230b4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/fastqreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ FastqReader::FastqReader(string filename, bool hasQuality, bool phred64){
mZipFile = NULL;
mZipped = false;
mFile = NULL;
mStdinMode = false;
mPhred64 = phred64;
mHasQuality = hasQuality;
mBuf = new char[FQ_BUF_SIZE];
Expand All @@ -29,8 +30,6 @@ void FastqReader::readToBuf() {
cerr << "Error to read gzip file" << endl;
}
} else {
//mFile.read(mBuf, FQ_BUF_SIZE);
//mBufDataLen = mFile.gcount();
mBufDataLen = fread(mBuf, 1, FQ_BUF_SIZE, mFile);
}
mBufUsedLen = 0;
Expand All @@ -42,9 +41,15 @@ void FastqReader::init(){
mZipped = true;
gzrewind(mZipFile);
}
else if (isFastq(mFilename)){
//mFile.open(mFilename.c_str(), ifstream::in);
mFile = fopen(mFilename.c_str(), "r");
else {
if(mFilename == "/dev/stdin") {
mFile = stdin;
}
else
mFile = fopen(mFilename.c_str(), "rb");
if(mFile == NULL) {
error_exit("Failed to open file: " + mFilename);
}
mZipped = false;
}
readToBuf();
Expand Down
1 change: 1 addition & 0 deletions src/fastqreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class FastqReader{
char* mBuf;
int mBufDataLen;
int mBufUsedLen;
bool mStdinMode;

};

Expand Down

0 comments on commit e230b4f

Please sign in to comment.