| 466 | } |
| 467 | |
| 468 | long getReadNumberFromPileup(std::string const& fileName) { |
| 469 | string line ; |
| 470 | long count = 0; |
| 471 | std::vector<std::string> strs; |
| 472 | // we will simply count "^" |
| 473 | #ifdef PROFILE_TRACE |
| 474 | time_t t0 = time(NULL); |
| 475 | #endif |
| 476 | if (fileName.substr(fileName.size()-3,3).compare(".gz")==0) { |
| 477 | FILE *stream; |
| 478 | char buffer[MAX_BUFFER]; |
| 479 | string command = "gzip -cd "+fileName; |
| 480 | stream = |
| 481 | #if defined(_WIN32) |
| 482 | _popen(command.c_str(), "r"); |
| 483 | #else |
| 484 | popen(command.c_str(), "r"); |
| 485 | #endif |
| 486 | while ( fgets(buffer, MAX_BUFFER, stream) != NULL ) { |
| 487 | line = buffer; |
| 488 | if (! line.length()) continue; |
| 489 | if (line[0] == '#') continue; |
| 490 | if ( line[0] == '@') continue; |
| 491 | |
| 492 | strs = split(line, '\t'); |
| 493 | if (strs.size() > 4) { |
| 494 | int toadd; |
| 495 | if (toadd=strccnt(strs[4].c_str(), '^')) { |
| 496 | count += toadd; |
| 497 | } |
| 498 | } |
| 499 | strs.clear(); |
| 500 | } |
| 501 | #if defined(_WIN32) |
| 502 | _pclose(stream); |
| 503 | #else |
| 504 | pclose(stream); |
| 505 | #endif |
| 506 | |
| 507 | } else { |
| 508 | ifstream fileMates(fileName.c_str()) ; |
| 509 | while (std::getline(fileMates,line)) { |
| 510 | |
| 511 | if (! line.length()) continue; |
| 512 | if (line[0] == '#') continue; |
| 513 | if ( line[0] == '@') continue; |
| 514 | |
| 515 | strs = split(line, '\t'); |
| 516 | if (strs.size() > 4) { |
| 517 | int toadd; |
| 518 | if (toadd=strccnt(strs[4].c_str(), '^')) { |
| 519 | count += toadd; |
| 520 | } |
| 521 | } |
| 522 | strs.clear(); |
| 523 | } |
| 524 | fileMates.close(); |
| 525 | } |
no test coverage detected