Output the runtine stats. Used both for normal and premature exit.
| 1418 | |
| 1419 | // Output the runtine stats. Used both for normal and premature exit. |
| 1420 | void printRunStats(state_t * state) |
| 1421 | { |
| 1422 | // This check should be redundant. |
| 1423 | if (idCount == 0) |
| 1424 | { |
| 1425 | fprintf(stderr, "samblaster: No reads processed.\n"); |
| 1426 | return; |
| 1427 | } |
| 1428 | // Output stats on auxiliary files. |
| 1429 | if (!state->quiet) |
| 1430 | { |
| 1431 | if (state->discordantFile != NULL) |
| 1432 | fprintf(stderr, "samblaster: Output %10" PRIu64 " discordant read pairs to %s\n", discCount/2, state->discordantFileName); |
| 1433 | if (state->splitterFile != NULL) |
| 1434 | fprintf(stderr, "samblaster: Output %10" PRIu64 " split reads to %s\n", splitCount, state->splitterFileName); |
| 1435 | if (state->unmappedClippedFile != NULL) |
| 1436 | fprintf(stderr, "samblaster: Output %10" PRIu64 " unmapped/clipped reads to %s\n", unmapClipCount, state->unmappedClippedFileName); |
| 1437 | } |
| 1438 | |
| 1439 | // Now the stats that might indicate a problem that therefore deserve reporting even if quiet set. |
| 1440 | if (readTooLongCount > 0) |
| 1441 | { |
| 1442 | fprintf(stderr, "samblaster: Found %10" PRIu64 " of %10" PRIu64 " (%5.3f) total read ids longer than the --maxReadLength(%d)\n." |
| 1443 | "samblaster: The longest of which is %d bases long.\n", |
| 1444 | readTooLongCount, idCount, ((double)100)*readTooLongCount/idCount, state->maxReadLength, readTooLongMax); |
| 1445 | fprintf(stderr, "samblaster: Consider rerunning samblaster with a larger --maxReadLength.\n"); |
| 1446 | } |
| 1447 | if (state->ignoreUnmated) |
| 1448 | { |
| 1449 | fprintf(stderr, "samblaster: Found %10" PRIu64 " of %10" PRIu64 " (%5.3f%%) total read ids are marked paired yet are unmated.\n", |
| 1450 | unmatedCount, idCount, ((double)100)*unmatedCount/idCount); |
| 1451 | if (unmatedCount > 0) fprintf(stderr, "samblaster: Please double check that input file is read-id (QNAME) grouped.\n"); |
| 1452 | } |
| 1453 | if (noPrimaryIdCount > 0) |
| 1454 | { |
| 1455 | fprintf(stderr, "samblaster: Found %10" PRIu64 " of %10" PRIu64 " (%5.3f%%) total read ids with no primary alignment.\n", |
| 1456 | noPrimaryIdCount, idCount, ((double)100)*noPrimaryIdCount/idCount); |
| 1457 | if (unmatedCount > 0) fprintf(stderr, "samblaster: Please double check that input file is read-id (QNAME) grouped.\n"); |
| 1458 | } |
| 1459 | |
| 1460 | // Now the main output stats. |
| 1461 | // We need no unmated reads in order to ensure that the various id types form a partition of all read ids. |
| 1462 | // This is because unmated reads could indicate an incorrectly sorted file which could cause double counting of ids. |
| 1463 | // Therefore, to be conservative, we should only output the table with both-unmapped, orphan and both-mapped stats in that case. |
| 1464 | // NOTE: the correct test is the unmated reads instead of --ignoreUnmated, as the latter doesn't mean we actually FIND any unmated. |
| 1465 | // However, I have decided to output them even if there are unmated reads because we do warn above in that case. |
| 1466 | |
| 1467 | // We need to have at least two id types to make sense to output the table. |
| 1468 | int idCountTypes = 0; |
| 1469 | if (bothUnmappedIdCount > 0) idCountTypes += 1; |
| 1470 | if (unmappedOrphanIdCount > 0) idCountTypes += 1; |
| 1471 | if (mappedOrphanIdCount > 0) idCountTypes += 1; |
| 1472 | if (bothMappedIdCount > 0) idCountTypes += 1; |
| 1473 | // We need dups for the denominators to avoid div by zero. |
| 1474 | if (!state->quiet && dupCount > 0 && idCountTypes > 1) |
| 1475 | { |
| 1476 | // We vary the names and spacing of the type names depending on whether or not there are any unmapped orphans. |
| 1477 | // Use shorter strings with less blank space if there are none, as should be common for properly grouped paired-end data. |
no test coverage detected