Skip to content

NuXLDeisotoper: precursor mass uses PROTON_MASS (kg) and rejects unknown-charge precursors #10232

Closed

Description

@ManasBagul23

Description

NuXLDeisotoper::deisotopeAndSingleCharge is a copy of Deisotoper::deisotopeAndSingleCharge and still has the two precursor-mass bugs that were fixed in Deisotoper itself by #10073 and #10075.

Bug 1 — an unknown precursor charge enables the mass constraint with mass 0

has_precursor_data = true;
int precursor_charge = old_spectrum.getPrecursors()[0].getCharge();
precursor_mass = (old_spectrum.getPrecursors()[0].getMZ() * precursor_charge) - (Constants::PROTON_MASS * precursor_charge);

getCharge() == 0 means the precursor charge is unknown (see Precursor.h). With charge 0, precursor_mass stays 0 but has_precursor_data is still set to true, so the precursor mass constraint is enabled with a neutral mass of 0 and every fragment cluster is rejected as too heavy — the opposite of what an unknown charge should do (skip the constraint, as Deisotoper now does).

Bug 2 — Constants::PROTON_MASS is in kg, not Da

Every neutral-mass computation in the file (the precursor mass above, and the theoretical mass of each candidate isotope cluster, twice) subtracts Constants::PROTON_MASS, which is the proton mass in kg (Constants::PROTON_MASS_U is the one in Da/u — the unit every other mass in this function is in). So every computed mass is off by about 1 u per charge, and the mass constraint compares two values that are each wrong by a different, charge-dependent amount.

Impact

Both bugs affect OpenNuXL's deisotoping step for RNA-protein crosslink search, whenever a spectrum carries precursor charge/mass information — precursor clusters and candidate fragment clusters can be wrongly rejected or accepted.

Fix

PR incoming, mirroring the fix already applied to Deisotoper (#10073, #10075): only enable the precursor mass constraint when the charge is known, and use PROTON_MASS_U.

Activity

  1. jpfeuffer commented on Sep 22, 2026

    @jpfeuffer
    Contributor

    Why is it even duplicated? How about subclassing or something?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions