From c884d4e5b75367a6ad8417e11f8ca189137ebd30 Mon Sep 17 00:00:00 2001 From: jke000 Date: Thu, 7 Nov 2024 16:21:15 -0800 Subject: [PATCH] PEFF modifications were being applied on wrong AA position on N-terminal peptides after start methionine removal with clip_nterm_methionine. Bug reporte by Z. Sun. --- CometSearch/CometSearch.cpp | 32 +++++++++++++++++++++----------- CometSearch/CometSearch.h | 3 +++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CometSearch/CometSearch.cpp b/CometSearch/CometSearch.cpp index 33ee926f..ce27e179 100644 --- a/CometSearch/CometSearch.cpp +++ b/CometSearch/CometSearch.cpp @@ -2217,7 +2217,10 @@ bool CometSearch::SearchForPeptides(struct sDBEntry dbe, } // VariableModSearch also includes looking at PEFF mods - VariableModSearch(szProteinSeq, piVarModCounts, iStartPos, iEndPos, pbDuplFragment, &dbe); + int iClipNtermMetOffset = 0; + if (iNtermPeptideOnly == 1) + iClipNtermMetOffset = 1; + VariableModSearch(szProteinSeq, piVarModCounts, iStartPos, iEndPos, iClipNtermMetOffset, pbDuplFragment, &dbe); } if (!g_staticParams.options.bCreateIndex && g_massRange.bNarrowMassRange) @@ -4487,6 +4490,7 @@ void CometSearch::VariableModSearch(char *szProteinSeq, int piVarModCounts[], int iStartPos, int iEndPos, + int iClipNtermMetOffset, // normal =0, n-term met clipped = 1; used to address PEFF mod position bool *pbDuplFragment, struct sDBEntry *dbe) { @@ -5259,8 +5263,7 @@ void CometSearch::VariableModSearch(char *szProteinSeq, _varModInfo.dCalcPepMass = dCalcPepMass; // iTmpEnd-iStartPos+3 = length of peptide +2 (for n/c-term) - PermuteMods(szProteinSeq, iWhichQuery, 1, pbDuplFragment, &bDoPeffAnalysis, &vPeffArray, dbe); - + PermuteMods(szProteinSeq, iWhichQuery, 1, iClipNtermMetOffset, pbDuplFragment, &bDoPeffAnalysis, &vPeffArray, dbe); } } @@ -5313,6 +5316,7 @@ double CometSearch::TotalVarModMass(int *pVarModCounts) bool CometSearch::PermuteMods(char *szProteinSeq, int iWhichQuery, int iWhichMod, + int iClipNtermMetOffset, bool *pbDuplFragment, bool *bDoPeffAnalysis, vector * vPeffArray, @@ -5402,12 +5406,12 @@ bool CometSearch::PermuteMods(char *szProteinSeq, if (iWhichMod == VMODS) { - if (!MergeVarMods(szProteinSeq, iWhichQuery, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) + if (!MergeVarMods(szProteinSeq, iWhichQuery, iClipNtermMetOffset, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) return false; } else { - if (!PermuteMods(szProteinSeq, iWhichQuery, iWhichMod+1, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) + if (!PermuteMods(szProteinSeq, iWhichQuery, iWhichMod+1, iClipNtermMetOffset, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) return false; } @@ -5421,12 +5425,12 @@ bool CometSearch::PermuteMods(char *szProteinSeq, if (iWhichMod == VMODS) { - if (!MergeVarMods(szProteinSeq, iWhichQuery, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) + if (!MergeVarMods(szProteinSeq, iWhichQuery, iClipNtermMetOffset, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) return false; } else { - if (!PermuteMods(szProteinSeq, iWhichQuery, iWhichMod+1, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) + if (!PermuteMods(szProteinSeq, iWhichQuery, iWhichMod+1, iClipNtermMetOffset, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) return false; } } @@ -5435,12 +5439,12 @@ bool CometSearch::PermuteMods(char *szProteinSeq, { if (iWhichMod == VMODS) { - if (!MergeVarMods(szProteinSeq, iWhichQuery, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) + if (!MergeVarMods(szProteinSeq, iWhichQuery, iClipNtermMetOffset, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) return false; } else { - if (!PermuteMods(szProteinSeq, iWhichQuery, iWhichMod+1, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) + if (!PermuteMods(szProteinSeq, iWhichQuery, iWhichMod+1, iClipNtermMetOffset, pbDuplFragment, bDoPeffAnalysis, vPeffArray, dbe)) return false; } } @@ -5580,6 +5584,7 @@ void CometSearch::inittwiddle(int m, int n, int *p) // except when lMaxIterations is hit bool CometSearch::MergeVarMods(char *szProteinSeq, int iWhichQuery, + int iClipNtermMetOffset, bool *pbDuplFragment, bool *bDoPeffAnalysis, vector * vPeffArray, @@ -5829,8 +5834,13 @@ bool CometSearch::MergeVarMods(char *szProteinSeq, for (i = 0; i < n; ++i) { + // iClipNtermMetOffset is 0 unless the N-term methionine is clipped off + // then it's set to 1. This shifts the PEFF mod positions down by 1 to + // place them on the correct residue after methionine removal. + int iPeffPosition = (*vPeffArray).at(i).iPosition - iClipNtermMetOffset; + // only consider those PEFF mods that are within the peptide - if ((*vPeffArray).at(i).iPosition >= _varModInfo.iStartPos && (*vPeffArray).at(i).iPosition <= _varModInfo.iEndPos) + if (iPeffPosition >= _varModInfo.iStartPos && iPeffPosition <= _varModInfo.iEndPos) { int iSize = (int)(*vPeffArray).at(i).vectorWhichPeff.size(); for (int ii = 0; ii < iSize; ++ii) @@ -5851,7 +5861,7 @@ bool CometSearch::MergeVarMods(char *szProteinSeq, if (iWhichQuery != -1) { bool bValidPeffPosition = true; - int iTmpModPosition = (*vPeffArray).at(i).iPosition - _varModInfo.iStartPos; + int iTmpModPosition = iPeffPosition - _varModInfo.iStartPos; // make sure PEFF mod location doesn't conflict with existing variable mod if (piVarModSites[iTmpModPosition] == 0) diff --git a/CometSearch/CometSearch.h b/CometSearch/CometSearch.h index 9bfe1742..612d1b8b 100644 --- a/CometSearch/CometSearch.h +++ b/CometSearch/CometSearch.h @@ -209,12 +209,14 @@ class CometSearch int piVarModCounts[], int iStartPos, int iEndPos, + int iClipNtermMetOffset, bool *pbDuplFragment, struct sDBEntry *dbe); double TotalVarModMass(int *pVarModCounts); bool PermuteMods(char *szProteinSeq, int iWhichQuery, int iWhichMod, + int iClipNtermMetOffset, bool *pbDuplFragments, bool *bDoPeffAnalysis, vector * vPeffArray, @@ -223,6 +225,7 @@ class CometSearch void inittwiddle(int m, int n, int *p); bool MergeVarMods(char *szProteinSeq, int iWhichQuery, + int iClipNtermMetOffset, bool *pbDuplFragments, bool *bDoPeffAnalysis, vector * vPeffArray,