Repository navigation
Conversation
… of similar mass DIA-NN decoys send 9 of 20 residues to L at positions 2 and n-1, so their fragments pile up on a few b2/y2 masses and fragment-sharing features tell them apart from targets. The new `near_mass_mutation` decoy replaces one random inner residue by a residue within (0.05, 25] Da, drawn from the targets' inner-residue composition; C and K stay, and I/L, N->D and Q->E are never drawn. The choice depends only on seed and sequence, so batches and processes agree. Generators get a `fit` hook, called with the target sequences before decoying. Decoys equal to a target up to I/L are now dropped for every decoy type, as fragments cannot tell them apart. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the mutation into near_mass_mutation.py, decoy each unique sequence once, compare unique sequences when removing targets, and skip the process pool for vectorised generators. Also exclude D->N and E->Q. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # alphabase/spectral_library/decoy.py # tests/unit/spectral_library/test_decoy.py
| """Drops decoys equal to a target up to I/L, which fragments cannot tell apart, and dropped sequences.""" | ||
| target_seqs = set( | ||
| _equate_isoleucine_leucine( | ||
| pd.unique(self.target_lib._precursor_df.sequence.to_numpy()) | ||
| ) | ||
| ) | ||
| decoy_index, decoy_seqs = pd.factorize(self._precursor_df.sequence.to_numpy()) | ||
| drop_unique = _equate_isoleucine_leucine(decoy_seqs).isin(target_seqs) | ( | ||
| decoy_seqs == DROPPED_SEQUENCE | ||
| ) |
There was a problem hiding this comment.
so if i get this right we apply this to all of our decoy schemes which in theory changes old behaviour of diann decoys and other ones - do we want it this way? maybe make it toggleable somehow?
There was a problem hiding this comment.
i agree it makes sense overall to have this ig - just it also changes (??) behaviour of other schemes
There was a problem hiding this comment.
agreed, we maybe want to restrict it to the new scheme
There was a problem hiding this comment.
Good catch, it is now restricted to the near-mass scheme via a drops_isoleucine_leucine_equivalents flag on the generator (off by default), so the DIA-NN and pseudo-reverse decoys behave as before.
Desperadus
left a comment
There was a problem hiding this comment.
nice - just look at the comment about how this also possibly effects other schemes
| """Drops decoys equal to a target up to I/L, which fragments cannot tell apart, and dropped sequences.""" | ||
| target_seqs = set( | ||
| _equate_isoleucine_leucine( | ||
| pd.unique(self.target_lib._precursor_df.sequence.to_numpy()) | ||
| ) | ||
| ) | ||
| decoy_index, decoy_seqs = pd.factorize(self._precursor_df.sequence.to_numpy()) | ||
| drop_unique = _equate_isoleucine_leucine(decoy_seqs).isin(target_seqs) | ( | ||
| decoy_seqs == DROPPED_SEQUENCE | ||
| ) |
There was a problem hiding this comment.
i agree it makes sense overall to have this ig - just it also changes (??) behaviour of other schemes
| FROZEN_AAS = "CK" | ||
| # A proline before the C-terminal residue suppresses cleavage there and shapes the fragment pattern, | ||
| # so the second-to-last position neither loses nor gains one |
There was a problem hiding this comment.
nice that we keep proline :]
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Older schemes keep their behaviour of dropping only decoys identical to a target. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds
NearMassMutationDecoyGenerator("near_mass_mutation"): each decoy replaces one inner residue of the target by a residue of similar mass.fit).Vectorised in numpy (
near_mass_mutation.py), one pass over unique sequences: 1M PSMs decoy in ~1.5 s.Known gaps: the DIA-NN fallback can still mutate a P at the second-to-last position, and mods are not moved or removed when a modified residue is mutated.
cc @Desperadus
🤖 Generated with Claude Code