MCPcopy Create free account
hub / github.com/OpenGene/fastp / init

Method init

src/fastqreader.cpp:169–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169void FastqReader::init(){
170 if (ends_with(mFilename, ".gz")){
171 mFile = fopen(mFilename.c_str(), "rb");
172 if(mFile == NULL) {
173 error_exit("Failed to open file: " + mFilename);
174 }
175
176 // Check for BGZF format — use parallel decompression if detected
177 if (isBgzf(mFile)) {
178 fseek(mFile, 0, SEEK_SET);
179 mBgzfReader = new BgzfMtReader(mFile, mBgzfThreadBudget);
180 mZipped = true;
181 readToBuf();
182 return;
183 }
184
185 isal_gzip_header_init(&mGzipHeader);
186 isal_inflate_init(&mGzipState);
187 mGzipState.crc_flag = ISAL_GZIP_NO_HDR_VER;
188 mGzipState.next_in = mGzipInputBuffer;
189 mGzipState.avail_in = fread(mGzipState.next_in, 1, mGzipInputBufferSize, mFile);
190 mGzipInputUsedBytes += mGzipState.avail_in;
191 int ret = isal_read_gzip_header(&mGzipState, &mGzipHeader);
192 if (ret != ISAL_DECOMP_OK) {
193 error_exit("igzip: Error invalid gzip header found: " + mFilename);
194 }
195 mZipped = true;
196 }
197 else {
198 if(mFilename == "/dev/stdin") {
199 mFile = stdin;
200 }
201 else
202 mFile = fopen(mFilename.c_str(), "rb");
203 if(mFile == NULL) {
204 error_exit("Failed to open file: " + mFilename);
205 }
206 mZipped = false;
207 }
208 readToBuf();
209}
210
211void FastqReader::getBytes(size_t& bytesRead, size_t& bytesTotal) {
212 if(mZipped) {

Callers

nothing calls this directly

Calls 3

ends_withFunction · 0.85
error_exitFunction · 0.85
isBgzfFunction · 0.85

Tested by

no test coverage detected