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

Method evaluateReadNum

src/evaluator.cpp:178–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178void Evaluator::evaluateReadNum(long& readNum) {
179 FastqReader reader(mOptions->in1);
180
181 const long READ_LIMIT = 512*1024;
182 const long BASE_LIMIT = 151 * 512*1024;
183 long records = 0;
184 long bases = 0;
185 size_t firstReadPos = 0;
186
187 size_t bytesRead;
188 size_t bytesTotal;
189
190 bool reachedEOF = false;
191 bool first = true;
192 while(records < READ_LIMIT && bases < BASE_LIMIT) {
193 Read* r = reader.read();
194 if(!r) {
195 reachedEOF = true;
196 break;
197 }
198 if(first) {
199 reader.getBytes(bytesRead, bytesTotal);
200 firstReadPos = bytesRead;
201 first = false;
202 }
203 records++;
204 bases += r->length();
205 delete r;
206 }
207
208 readNum = 0;
209 if(reachedEOF){
210 readNum = records;
211 } else if(records>0) {
212 // by the way, update readNum so we don't need to evaluate it if splitting output is enabled
213 reader.getBytes(bytesRead, bytesTotal);
214 double bytesPerRead = (double)(bytesRead - firstReadPos) / (double) records;
215 // increase it by 1% since the evaluation is usually a bit lower due to bad quality causes lower compression rate
216 readNum = (long) (bytesTotal*1.01 / bytesPerRead);
217 }
218}
219
220string Evaluator::checkKnownAdapters(Read** reads, long num) {
221 map<string, string> knownAdapters = getKnownAdapter();

Callers 1

mainFunction · 0.80

Calls 3

getBytesMethod · 0.80
readMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected