From 0671fa94fbedebcb425c36a1917b23833b8ed758 Mon Sep 17 00:00:00 2001 From: Jimmy Eng Date: Fri, 4 Oct 2024 16:02:12 -0700 Subject: [PATCH] Revert initialization change in e5fe561 for classic search as it imparts a small performance penalty and isn't needed. --- CometSearch/CometDataInternal.h | 2 +- CometSearch/CometSearch.cpp | 111 +++++++++++++++++++++++++++----- RealtimeSearch/Search.cs | 49 +++++++------- 3 files changed, 121 insertions(+), 41 deletions(-) diff --git a/CometSearch/CometDataInternal.h b/CometSearch/CometDataInternal.h index 0d7e75bc..d6212171 100644 --- a/CometSearch/CometDataInternal.h +++ b/CometSearch/CometDataInternal.h @@ -1023,7 +1023,7 @@ struct Query Query() { - memset(iXcorrHistogram, 0, sizeof(int)*HISTO_SIZE); + memset(iXcorrHistogram, 0, sizeof(iXcorrHistogram)); iMatchPeptideCount = 0; iDecoyMatchPeptideCount = 0; diff --git a/CometSearch/CometSearch.cpp b/CometSearch/CometSearch.cpp index 1b1637cd..fc1767de 100644 --- a/CometSearch/CometSearch.cpp +++ b/CometSearch/CometSearch.cpp @@ -1464,11 +1464,12 @@ void CometSearch::SearchFragmentIndex(size_t iWhichQuery, iMaxFragmentCharge = 2; // Now get the set of binned fragment ions once to compare this peptide against all matching spectra. - // First initialize pbDuplFragment and _uiBinnedIonMasses + memset(pbDuplFragment, 0, sizeof(bool) * g_staticParams.iArraySizeGlobal); memset(uiBinnedIonMasses, 0, sizeof(uiBinnedIonMasses)); - memset(uiBinnedPrecursorNL, 0, sizeof(uiBinnedPrecursorNL)); + if (g_staticParams.iPrecursorNLSize > 0) + memset(uiBinnedPrecursorNL, 0, sizeof(uiBinnedPrecursorNL)); // set pbDuplFragment[bin] to true for each fragment ion bin for (ctCharge = 1; ctCharge <= g_pvQuery.at(iWhichQuery)->_spectrumInfoInternal.iMaxFragCharge; ++ctCharge) @@ -1499,7 +1500,6 @@ void CometSearch::SearchFragmentIndex(size_t iWhichQuery, if ((iWhichIonSeries <= 2 && ctLen >= iPositionNLB[x]) // 0/1/2 is a/b/c ions || (iWhichIonSeries >= 3 && iWhichIonSeries <= 5 && iLenMinus1-ctLen <= iPositionNLY[x])) // 3/4/5 is x/y/z ions { - int iScaleFactor; if (iWhichIonSeries <= 2) @@ -1947,11 +1947,37 @@ bool CometSearch::SearchForPeptides(struct sDBEntry dbe, } // Now get the set of binned fragment ions once to compare this peptide against all matching spectra. - // First initialize pbDuplFragment and _uiBinnedIonMasses - memset(pbDuplFragment, 0, sizeof(bool) * g_staticParams.iArraySizeGlobal); - memset(_uiBinnedIonMasses, 0, sizeof(_uiBinnedIonMasses)); - memset(_uiBinnedPrecursorNL, 0, sizeof(_uiBinnedPrecursorNL)); + for (ctCharge = 1; ctCharge <= g_massRange.iMaxFragmentCharge; ++ctCharge) + { + for (ctIonSeries = 0; ctIonSeries < g_staticParams.ionInformation.iNumIonSeriesUsed; ++ctIonSeries) + { + iWhichIonSeries = g_staticParams.ionInformation.piSelectedIonSeries[ctIonSeries]; + + for (ctLen = 0; ctLen < iLenMinus1; ++ctLen) + { + pbDuplFragment[BIN(GetFragmentIonMass(iWhichIonSeries, ctLen, ctCharge, _pdAAforward, _pdAAreverse))] = false; + _uiBinnedIonMasses[ctCharge][ctIonSeries][ctLen][0] = 0; + // note no need to initialize fragment NL positions as no mods here + } + + } + } + + for (int ctNL = 0; ctNL < g_staticParams.iPrecursorNLSize; ++ctNL) + { + for (ctCharge = g_pvQuery.at(iWhichQuery)->_spectrumInfoInternal.iChargeState; ctCharge >= 1; ctCharge--) + { + double dNLMass = (dCalcPepMass - PROTON_MASS - g_staticParams.precursorNLIons[ctNL] + ctCharge * PROTON_MASS) / ctCharge; + int iVal = BIN(dNLMass); + + if (iVal > 0) + { + pbDuplFragment[iVal] = false; + _uiBinnedPrecursorNL[ctNL][ctCharge] = 0; + } + } + } // Now set _uiBinnedIonMasses; use pbDuplFragment to make sure a fragment isn't counted twice for (ctCharge = 1; ctCharge <= g_massRange.iMaxFragmentCharge; ++ctCharge) @@ -2069,6 +2095,8 @@ bool CometSearch::SearchForPeptides(struct sDBEntry dbe, _pdAAreverseDecoy[iPosForward] = dYion; } + // Now get the set of binned fragment ions once for all matching decoy peptides + // First initialize pbDuplFragment and _uiBinnedIonMassesDecoy for (ctCharge = 1; ctCharge <= g_massRange.iMaxFragmentCharge; ++ctCharge) { for (ctIonSeries = 0; ctIonSeries < g_staticParams.ionInformation.iNumIonSeriesUsed; ++ctIonSeries) @@ -6045,12 +6073,66 @@ bool CometSearch::CalcVarModIons(char *szProteinSeq, _pdAAreverse[iPosForward] = dYion; } - // now get the set of binned fragment ions once for all matching peptides + // Now get the set of binned fragment ions once to compare this peptide against all matching spectra. + // First initialize pbDuplFragment and _uiBinnedIonMasses + for (ctCharge = 1; ctCharge <= g_massRange.iMaxFragmentCharge; ++ctCharge) + { + for (ctIonSeries = 0; ctIonSeries < g_staticParams.ionInformation.iNumIonSeriesUsed; ++ctIonSeries) + { + iWhichIonSeries = g_staticParams.ionInformation.piSelectedIonSeries[ctIonSeries]; + + for (ctLen = 0; ctLen < iLenMinus1; ++ctLen) + { + double dFragMass = GetFragmentIonMass(iWhichIonSeries, ctLen, ctCharge, _pdAAforward, _pdAAreverse); + + pbDuplFragment[BIN(dFragMass)] = false; + _uiBinnedIonMasses[ctCharge][ctIonSeries][ctLen][0] = 0; + + // initialize fragmentNL + if (g_staticParams.variableModParameters.bUseFragmentNeutralLoss) + { + for (int x = 0; x < VMODS; ++x) + { + if ((iWhichIonSeries <= 2 && ctLen >= iPositionNLB[x]) // 0/1/2 is a/b/c ions + || (iWhichIonSeries >= 3 && iWhichIonSeries <= 5 && iLenMinus1 - ctLen <= iPositionNLY[x])) // 3/4/5 is x/y/z ions + { + int iScaleFactor; + + if (iWhichIonSeries <= 2) + iScaleFactor = iCountNLB[x][ctLen]; + else + iScaleFactor = iCountNLY[x][ctLen]; + + double dNewMass = dFragMass - (iScaleFactor * g_staticParams.variableModParameters.varModList[x].dNeutralLoss / ctCharge); + + if (dNewMass > 0.0) + { + pbDuplFragment[BIN(dNewMass)] = false; + } + } + + _uiBinnedIonMasses[ctCharge][ctIonSeries][ctLen][x + 1] = 0; + } + } + } + } + } + + // initialize precursorNL + for (int ctNL = 0; ctNL < g_staticParams.iPrecursorNLSize; ++ctNL) + { + for (ctCharge = g_pvQuery.at(iWhichQuery)->_spectrumInfoInternal.iChargeState; ctCharge >= 1; ctCharge--) + { + double dNLMass = (dCalcPepMass - PROTON_MASS - g_staticParams.precursorNLIons[ctNL] + ctCharge * PROTON_MASS) / ctCharge; + int iVal = BIN(dNLMass); - // initialize pbDuplFragment here - memset(pbDuplFragment, 0, sizeof(bool) * g_staticParams.iArraySizeGlobal); - memset(_uiBinnedIonMasses, 0, sizeof(_uiBinnedIonMasses)); - memset(_uiBinnedPrecursorNL, 0, sizeof(_uiBinnedPrecursorNL)); + if (iVal > 0) + { + pbDuplFragment[BIN(dNLMass)] = false; + _uiBinnedPrecursorNL[ctNL][ctCharge] = 0; + } + } + } // set pbDuplFragment[bin] to true for each fragment ion bin for (ctCharge = 1; ctCharge <= g_massRange.iMaxFragmentCharge; ++ctCharge) @@ -6295,9 +6377,8 @@ bool CometSearch::CalcVarModIons(char *szProteinSeq, _pdAAreverseDecoy[iPosForward] = dYion; } - // now get the set of binned fragment ions once for all matching decoy peptides - - // initialize pbDuplFragment here + // Now get the set of binned fragment ions once for all matching decoy peptides + // First initialize pbDuplFragment and _uiBinnedIonMassesDecoy for (ctCharge = 1; ctCharge <= g_massRange.iMaxFragmentCharge; ++ctCharge) { for (ctIonSeries = 0; ctIonSeries < g_staticParams.ionInformation.iNumIonSeriesUsed; ++ctIonSeries) diff --git a/RealtimeSearch/Search.cs b/RealtimeSearch/Search.cs index f6c8f0cd..885fab4c 100644 --- a/RealtimeSearch/Search.cs +++ b/RealtimeSearch/Search.cs @@ -68,7 +68,7 @@ static void Main(string[] args) double[] pdInten; Stopwatch watch = new Stopwatch(); - int iMaxElapsedTime = 20; + int iMaxElapsedTime = 50; int[] piTimeSearch = new int[iMaxElapsedTime]; // histogram of search times for (int i = 0; i < iMaxElapsedTime; ++i) @@ -205,8 +205,8 @@ static void Main(string[] args) SearchMgr.FinalizeSingleSpectrumSearch(); // write out histogram of spectrum search times - for (int i = 0; i < iMaxElapsedTime; ++i) - Console.WriteLine("{0}\t{1}", i, piTimeSearch[i]); +// for (int i = 0; i < iMaxElapsedTime; ++i) +// Console.WriteLine("{0}\t{1}", i, piTimeSearch[i]); rawFile.Dispose(); } @@ -250,22 +250,37 @@ public bool ConfigureInputSettings(CometSearchManagerWrapper SearchMgr, sTmp = iTmp.ToString(); SearchMgr.SetParam("decoy_search", sTmp, iTmp); */ - dTmp = 3.0; // peptide mass tolerance plus + dTmp = 20.0; // peptide mass tolerance plus sTmp = dTmp.ToString(); SearchMgr.SetParam("peptide_mass_tolerance_upper", sTmp, dTmp); - dTmp = -3.0; // peptide mass tolerance minus ; if this is not set, will use -1*peptide_mass_tolerance_plus + dTmp = -20.0; // peptide mass tolerance minus ; if this is not set, will use -1*peptide_mass_tolerance_plus sTmp = dTmp.ToString(); SearchMgr.SetParam("peptide_mass_tolerance_lower", sTmp, dTmp); - iTmp = 0; // 0=Da, 2=ppm + iTmp = 2; // 0=Da, 2=ppm sTmp = iTmp.ToString(); SearchMgr.SetParam("peptide_mass_units", sTmp, iTmp); - iTmp = 0; + iTmp = 1; // 0 = Da, 1 = m/z tolerance + sTmp = iTmp.ToString(); + SearchMgr.SetParam("precursor_tolerance_type", sTmp, iTmp); + + iTmp = 2; // 0=off, 1=0/1 (C13 error), 2=0/1/2, 3=0/1/2/3, 4=-1/0/1/2/3, 5=-1/0/1 sTmp = iTmp.ToString(); SearchMgr.SetParam("isotope_error", sTmp, iTmp); + dTmp = 0.02; // fragment bin width + sTmp = dTmp.ToString(); + SearchMgr.SetParam("fragment_bin_tol", sTmp, dTmp); + + sTmp = dTmp.ToString(); + SearchMgr.SetParam("fragment_bin_offset", sTmp, dTmp); + + iTmp = 0; // 0=use flanking peaks, 1=M peak only + sTmp = iTmp.ToString(); + SearchMgr.SetParam("theoretical_fragment_ions", sTmp, iTmp); + iTmp = 3; sTmp = iTmp.ToString(); SearchMgr.SetParam("fragindex_min_ions_score", sTmp, iTmp); @@ -290,25 +305,9 @@ public bool ConfigureInputSettings(CometSearchManagerWrapper SearchMgr, sTmp = iTmp.ToString(); SearchMgr.SetParam("max_index_runtime", sTmp, iTmp); - iTmp = 0; // 1 = m/z tolerance + iTmp = 10; sTmp = iTmp.ToString(); - SearchMgr.SetParam("precursor_tolerance_type", sTmp, iTmp); - - iTmp = 0; // 0=off, 1=0/1 (C13 error), 2=0/1/2, 3=0/1/2/3, 4=-8/-4/0/4/8 (for +4/+8 labeling) - sTmp = iTmp.ToString(); - SearchMgr.SetParam("isotope_error", sTmp, iTmp); - - dTmp = 1.0005; // fragment bin width - sTmp = dTmp.ToString(); - SearchMgr.SetParam("fragment_bin_tol", sTmp, dTmp); - - dTmp = 0.4; // fragment bin offset - sTmp = dTmp.ToString(); - SearchMgr.SetParam("fragment_bin_offset", sTmp, dTmp); - - iTmp = 1; // 0=use flanking peaks, 1=M peak only - sTmp = iTmp.ToString(); - SearchMgr.SetParam("theoretical_fragment_ions", sTmp, iTmp); + SearchMgr.SetParam("minimum_peaks", sTmp, iTmp); iTmp = 3; // maximum fragment charge sTmp = iTmp.ToString();