Skip to content

Commit

Permalink
Annotate decoy entries in pin outputs for FASTA files (non-internal d…
Browse files Browse the repository at this point in the history
…ecoys) with target-decoy sequences using the decoy_prefix parameter to note which are decoy matches.
  • Loading branch information
jke000 committed Apr 28, 2022
1 parent 450b6a1 commit 75d8377
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
39 changes: 33 additions & 6 deletions CometSearch/CometWritePercolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ bool CometWritePercolator::WritePercolator(FILE *fpout,
FILE *fpdb)
{
int i;
int iLenDecoyPrefix = strlen(g_staticParams.szDecoyPrefix);

// Print results.
for (i=0; i<(int)g_pvQuery.size(); i++)
{
if (g_pvQuery.at(i)->_pResults[0].fXcorr > g_staticParams.options.dMinimumXcorr)
{
PrintResults(i, fpout, fpdb, 0); // print search hit (could be decoy if g_staticParams.options.iDecoySearch=1)
PrintResults(i, fpout, fpdb, 0, iLenDecoyPrefix); // print search hit (could be decoy if g_staticParams.options.iDecoySearch=1)
}

if (g_staticParams.options.iDecoySearch == 2 && g_pvQuery.at(i)->_pDecoys[0].fXcorr > g_staticParams.options.dMinimumXcorr)
{
PrintResults(i, fpout, fpdb, 2); // print decoy hit
PrintResults(i, fpout, fpdb, 2, iLenDecoyPrefix); // print decoy hit
}
}

Expand Down Expand Up @@ -92,7 +93,8 @@ void CometWritePercolator::WritePercolatorHeader(FILE *fpout)
bool CometWritePercolator::PrintResults(int iWhichQuery,
FILE *fpout,
FILE *fpdb,
int iPrintTargetDecoy)
int iPrintTargetDecoy,
int iLenDecoyPrefix)
{
int i,
iNumPrintLines,
Expand Down Expand Up @@ -132,11 +134,36 @@ bool CometWritePercolator::PrintResults(int iWhichQuery,

CometMassSpecUtils::GetProteinNameString(fpdb, iWhichQuery, iWhichResult, iPrintTargetDecoy, vProteinTargets, vProteinDecoys);

if (vProteinTargets.size() > 0)
fprintf(fpout, "1\t"); // target label
if (g_staticParams.options.iDecoySearch > 0) // using Comet's internal decoys
{
if (vProteinTargets.size() > 0)
fprintf(fpout, "1\t"); // target label
else
fprintf(fpout, "-1\t"); // decoy label
}
else
fprintf(fpout, "-1\t"); // decoy label
{
// Standard database search with possible user supplied decoys in the fasta.
// So compare the protein string to see if any match g_staticParams.szDecoyPrefix.
// If so, annotate those with a decoy label.
bool bTarget = false;
std::vector<string>::iterator it;

for (it = vProteinTargets.begin(); it != vProteinTargets.end(); it++)
{
if (strncmp((*it).c_str(), g_staticParams.szDecoyPrefix, iLenDecoyPrefix))
{
// if any protein string does not match the decoy prefix then it's a target
bTarget = true;
break;
}
}

if (bTarget)
fprintf(fpout, "1\t"); // target label
else
fprintf(fpout, "-1\t"); // decoy label
}

fprintf(fpout, "%d\t", pQuery->_spectrumInfoInternal.iScanNumber);
fprintf(fpout, "%0.6f\t", pQuery->_pepMassInfo.dExpPepMass); //ExpMass
Expand Down
3 changes: 2 additions & 1 deletion CometSearch/CometWritePercolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class CometWritePercolator
static bool PrintResults(int iWhichQuery,
FILE *fpOut,
FILE *fpdb,
int iPrintTargetDecoy);
int iPrintTargetDecoy,
int iLenDecoyPrefix);
static void PrintPercolatorSearchHit(int iWhichQuery,
int iWhichResult,
int iPrintTargetDecoy,
Expand Down

0 comments on commit 75d8377

Please sign in to comment.