Skip to content

Search cRAP contaminants with the database, flag them and hide them from protein results - #45

Open
t0mdavid-m wants to merge 1 commit into
mainfrom
claude/parity-contaminants
Open

t0mdavid-m wants to merge 1 commit into
mainfrom
claude/parity-contaminants

Conversation

@t0mdavid-m

Copy link
Copy Markdown
Member

Before: the search database is exactly the user's FASTA. Keratins, trypsin, BSA and other common lab contaminants either go unidentified (and their spectra can be misassigned to real proteins), or turn up as ordinary proteins in the abundance table and the statistics.

After:

  • The Identification step on Configure (LFQ and TMT) has an "Add common contaminants (cRAP)" option, on by default. It appends the 116 cRAP proteins to the search database with CON__ before their accessions, the same convention as MaxQuant and ProSE.
  • Contaminants get decoys like every other entry. With generated decoys, DecoyDatabase reads the FASTA and the contaminants in one call. If the FASTA already has its own decoys, the contaminants get decoys in the same prefix style.
  • The PSM tables (Database Search, Rescoring, Filtered PSMs) get a Contaminant column.
  • The Abundance page flags contaminant proteins and hides them by default. It shows "n contaminant protein(s) hidden" and has a Show contaminants toggle.
  • get_abundance_data() leaves contaminants out unless asked, so Filtering, Imputation, Normalization, Statistics, PCA, heatmaps, volcano and pathway analysis never see them. A protein group counts as a contaminant when any of its members is one.

This is ProSE parity item S3 (timosachsenberg/prose-web).

How:

  • src/common/contaminants.py writes the prefixed cRAP FASTA and appends FASTAs with pyOpenMS FASTAFile. It also provides is_contaminant and drop_contaminants.
  • The cRAP FASTA is bundled at example-data/db/contaminants/crap.fasta. That is a subfolder, so it never shows up as a selectable example database.
  • The database step of execution() moved into WorkflowTest.prepare_search_database(). It writes the derived databases under results/database/ instead of next to the user's FASTA. With contaminants off, it behaves exactly as before.
  • The contaminant-only DecoyDatabase call uses its own instance name, so stored DecoyDatabase settings don't repeat its options on the command line.

Not in this PR: hiding contaminants by default inside the PSM tables. Those tables are built once at run time, so here the column flags them and the column filter hides them. The Proteins and Identification QC pages from #43 and #42 will pick up the same helper once those land.

Validation:

  • tests/test_contaminants.py adds 7 tests. They cover the prefixed cRAP entries, both decoy paths (with a stand-in for DecoyDatabase, since TOPP is not installed here), switching the option off, and abundance data with and without contaminants. pytest test_gui.py tests/ passes 126 tests.
  • pylint --errors-only reports only E0611 on from pyopenms import .... These notices also appear locally on the existing results_helpers.py import, and CI resolves them.
  • I rendered the Abundance page in Chromium on a synthetic result with 40 proteins plus 4 contaminants, one of them a mixed group. 40 rows show by default, and the toggle brings back the 4 flagged rows. The Configure page shows the new checkbox.


Generated by Claude Code

…esults

A new "Add common contaminants (cRAP)" option (on by default) appends the
116 cRAP proteins to the search database with CON__ accessions. With
generated decoys, DecoyDatabase reads the FASTA and the contaminants
together, so contaminants get decoys too. A FASTA with its own decoys gets
contaminant decoys in its decoy style. The database step is now its own
method, prepare_search_database().

PSM tables gain a Contaminant column. get_abundance_data() leaves
contaminant proteins out by default, so downstream analysis never sees
them. The Abundance page flags them and has a "Show contaminants" toggle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D5Wo2FHPpi5a8X6GppNxEk
@t0mdavid-m t0mdavid-m self-assigned this Oct 23, 2026
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c823eead-6f0e-4789-a3bc-0139d703b6ac
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants