Skip to content

Commit

Permalink
Revert initialization change in e5fe561 for classic search as it impa…
Browse files Browse the repository at this point in the history
…rts a small performance penalty and isn't needed.
  • Loading branch information
jke000 committed Oct 4, 2024
1 parent 55d75c6 commit 0671fa9
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 41 deletions.
2 changes: 1 addition & 1 deletion CometSearch/CometDataInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ struct Query

Query()
{
memset(iXcorrHistogram, 0, sizeof(int)*HISTO_SIZE);
memset(iXcorrHistogram, 0, sizeof(iXcorrHistogram));

iMatchPeptideCount = 0;
iDecoyMatchPeptideCount = 0;
Expand Down
111 changes: 96 additions & 15 deletions CometSearch/CometSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
49 changes: 24 additions & 25 deletions RealtimeSearch/Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 0671fa9

Please sign in to comment.