Count reads dropped by --dedup as duplicates instead of "passed filter" (#638, #528) - #715
Open
cindykrafft wants to merge 1 commit into
Open
cindykrafft wants to merge 1 commit into
cindykrafft wants to merge 1 commit into
Conversation
…nGene#638, OpenGene#528) With --dedup, a read (or pair) removed as a duplicate was still recorded as PASS_FILTER, so "reads passed filter" on stderr and filtering_result.passed_filter_reads in the JSON/HTML counted reads that were never written, and disagreed with summary.after_filtering.total_reads and with the output files. In --merge mode the merged branch never looked at the deduplication flag at all, so --dedup removed nothing there. Add FAIL_DUPLICATE: a read or pair that would otherwise pass but is dropped by --dedup is now counted under it, reported as "reads failed due to duplication" on stderr, "duplicated_reads" in the JSON filtering_result and "reads duplicated" in the HTML summary (all only when --dedup is on), and merged pairs that are duplicates are no longer written. scripts/test_issue_638_dedup_filter_counts.sh reproduces both symptoms and fails on the unmodified code. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TaHntBDKuZJpMAAMenkC44
This was referenced Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #638. Also fixes #528.
Cause. With
--dedup, the decision to drop a duplicate (dedupOut) only gates the output; the filter category is recorded before it is consulted (config->addFilterResult(result, 1)inseprocessor.cpp,addFilterResult(max(result1, result2), 2)inpeprocessor.cpp) withresult == PASS_FILTER. So every read removed by--dedupis still counted as passed: "reads passed filter" on stderr andfiltering_result.passed_filter_readsin the JSON/HTML disagree withsummary.after_filtering.total_readsand with the output file by exactly the number of removed duplicates, and there is no category that reports those reads. The merged branch in--mergemode never checksdedupOutat all, so--merge --dedupremoves nothing.Fix. A new filter category
FAIL_DUPLICATE(followingFAIL_ADAPTER_DIMER): a read or pair that would pass but is dropped by--dedupis recorded under it in all four places a result is recorded (SE; PE merged,--include_unmerged, plain). Reads failing another filter keep that reason. It is reported asreads failed due to duplication:on stderr,"duplicated_reads"in the JSONfiltering_resultandreads duplicated:in the HTML summary, only when--dedupis on, so reports of runs without--dedupare unchanged. One output change: because the merged branch now recordsFAIL_DUPLICATEand writes only onPASS_FILTER,--merge --dedupdrops duplicate merged pairs as documented — happy to split that into a separate PR if you prefer.Test.
scripts/test_issue_638_dedup_filter_counts.sh, in the style oftest_issue_697_stdout_merge.sh: an SE run with every read twice assertspassed_filter_reads == after_filtering.total_reads == reads writtenandduplicated_reads == input − written; an interleaved--merge --deduprun asserts that no more than the distinct pairs are written and that the two counters sum to the input. It fails onmaster(FAIL: SE --dedup wrote 500 reads but reported passed_filter_reads=1000 duplicated_reads=-1 after_filtering.total_reads=500) and passes with this change.Run.
make -j8(no warnings),./fastp test(ALL PASSED),scripts/test_issue_697_stdout_merge.sh(PASS) and the new script (PASS), on Ubuntu with libisal 2.31.0, libdeflate 1.19, libhwy 1.0.7. Synthetic check: 4,000 SE reads (2,000 distinct) with--dedupnow reportpassed 2000 / duplicated 2000 / after_filtering 2000 / written 2000instead of4000 / – / 2000 / 2000.Found while working through open issues in Mytochondria, a volunteer project that verifies fixes for the software behind published results (methods and harnesses: https://github.com/cindykrafft/mytochondria/tree/main/audits/fastp)
Generated by Claude Code