Repository navigation
refine: pair each Pass-2 decoy with its anchor peptide - #100
Conversation
…mini) Pass 2 searches each confident peptide as its own mini-protein and decoyed it by reversing the whole sequence. That moves the C-terminal K/R to the front: PEPKTIDEK becomes KEDITKPEP, whose full-length form needs one more missed cleavage than its target and is never generated under the default limit. Reversal also moves an N-terminal Q/E to the C-terminus, so pyro-Glu candidates existed only on the target side. The decoy pieces that were generated sit at the wrong masses and rarely compete with a modified target. Decoys now keep the anchor's first and last residue and reverse (or shuffle) only the interior. On Astral the Pass-2 PSM rows go from 571,662 targets / 222,368 decoys to 391,319 / 382,581. The [REFINE] log line now reports the Pass-2 target/decoy candidate counts.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughPeptide-anchored decoys now preserve target endpoints while applying the selected strategy to sequence interiors. A test checks full-length target and decoy candidate parity. Refinement summaries report target and decoy candidate counts separately. ChangesPeptide-anchored decoy refinement
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No blocking issue was identified with anchored decoy generation or the Pass-2 count reporting. The change is mergeable after normal checks. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Full results: 3 Percolator seeds + a no-
|
| arm | total | Pass-2 (modified) |
|---|---|---|
no --refine |
41,437 / 41,323 / 41,360 | — |
--refine, main |
61,096 / 61,679 / 61,460 | 22,842 / 23,210 / 23,039 |
--refine, this PR |
50,013 / 49,913 / 49,978 | 9,879 / 9,835 / 9,854 |
The seed spread is about 1%, so the drop is not noise. With paired decoys, --refine adds about +8,600 PSMs over the no-refine control (+21%), down from +20,000 (+48%) on main.
Most of the remaining gain is still suspect. On the fixed arm, Percolator seed 1 accepts 8,042 deamidated PSMs. Their precursor mass residual after removing whole isotope steps splits like this:
- 1,147 (14%) sit near 0, as a real deamidation would.
- 4,869 (61%) sit at +12 to +26 mDa, where an unmodified peptide picked one isotope too high would sit.
Paired decoys cannot model that artefact. Until the follow-up guard exists, the honest --refine gain on this data is well below +21%.
Also: the fixed arm's Pass-1 count (40,134, seed 1) is about 1,300 below the no-refine control, so Pass-2 rows still displace some correct unmodified PSMs.
CI is green.
Problem
--refinePass 2 searches each confident peptide as its own mini-protein. Its decoy was the whole sequence reversed, which breaks the target/decoy pairing for single peptides:PEPKTIDEK→KEDITKPEP: the full-length decoy needs one more missed cleavage than its target, so under the default limit of one it is never generated.EDITKPEP,PEPK…) sit at other masses and rarely compete with a modified target for the same spectrum.Fix
Each Pass-2 decoy keeps its anchor's first and last residue and reverses (or shuffles, under
--decoy-strategy shuffle) only the interior:PEPKTIDEK→PEDITKPEK. Cleavage pattern and N-terminal modification eligibility now match the target. The[REFINE]log line also reports Pass-2 target/decoy candidate counts so an imbalance is visible.New test
anchored_decoys_keep_termini_and_pair_full_length_with_targetsasserts equal full-length target/decoy forms per anchor (missed cleavage, N-terminal Q/E, internal K); it fails on the old code.Measured (Astral HYE,
--refine, Percolator 3.7.1)On main, Pass-2 targets outnumbered decoys 2.6 : 1 at the PSM level, so Percolator accepted modified PSMs against too few decoys. With paired decoys, accepted Pass-2 PSMs fall 57%; Pass-1 rises because fewer spurious modified PSMs displace correct unmodified ones. Earlier
--refinegains measured on main were inflated by this (entrapment cannot see Pass-2, so it never caught it).Seeds 2–3 and a no-
--refinecontrol are running; I'll add them here.Known remaining issue (not fixed here)
On main, of 16,610 accepted deamidated PSMs only 18% have a precursor residual near 0 after removing whole isotope steps; 54% sit at +12 to +26 mDa, where an unmodified peptide picked one isotope high lands (1.0034 − 0.9840 = 19 mDa). Balanced decoys cannot model that artefact, so it needs its own guard (an isotope-residual check or fragment-ion localization for deamidation). Follow-up.
Summary by CodeRabbit