Skip to content

Commit 75d8377

Browse files
committed
Annotate decoy entries in pin outputs for FASTA files (non-internal decoys) with target-decoy sequences using the decoy_prefix parameter to note which are decoy matches.
1 parent 450b6a1 commit 75d8377

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

CometSearch/CometWritePercolator.cpp

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ bool CometWritePercolator::WritePercolator(FILE *fpout,
3636
FILE *fpdb)
3737
{
3838
int i;
39+
int iLenDecoyPrefix = strlen(g_staticParams.szDecoyPrefix);
3940

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

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

@@ -92,7 +93,8 @@ void CometWritePercolator::WritePercolatorHeader(FILE *fpout)
9293
bool CometWritePercolator::PrintResults(int iWhichQuery,
9394
FILE *fpout,
9495
FILE *fpdb,
95-
int iPrintTargetDecoy)
96+
int iPrintTargetDecoy,
97+
int iLenDecoyPrefix)
9698
{
9799
int i,
98100
iNumPrintLines,
@@ -132,11 +134,36 @@ bool CometWritePercolator::PrintResults(int iWhichQuery,
132134

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

135-
if (vProteinTargets.size() > 0)
136-
fprintf(fpout, "1\t"); // target label
137+
if (g_staticParams.options.iDecoySearch > 0) // using Comet's internal decoys
138+
{
139+
if (vProteinTargets.size() > 0)
140+
fprintf(fpout, "1\t"); // target label
141+
else
142+
fprintf(fpout, "-1\t"); // decoy label
143+
}
137144
else
138-
fprintf(fpout, "-1\t"); // decoy label
145+
{
146+
// Standard database search with possible user supplied decoys in the fasta.
147+
// So compare the protein string to see if any match g_staticParams.szDecoyPrefix.
148+
// If so, annotate those with a decoy label.
149+
bool bTarget = false;
150+
std::vector<string>::iterator it;
151+
152+
for (it = vProteinTargets.begin(); it != vProteinTargets.end(); it++)
153+
{
154+
if (strncmp((*it).c_str(), g_staticParams.szDecoyPrefix, iLenDecoyPrefix))
155+
{
156+
// if any protein string does not match the decoy prefix then it's a target
157+
bTarget = true;
158+
break;
159+
}
160+
}
139161

162+
if (bTarget)
163+
fprintf(fpout, "1\t"); // target label
164+
else
165+
fprintf(fpout, "-1\t"); // decoy label
166+
}
140167

141168
fprintf(fpout, "%d\t", pQuery->_spectrumInfoInternal.iScanNumber);
142169
fprintf(fpout, "%0.6f\t", pQuery->_pepMassInfo.dExpPepMass); //ExpMass

CometSearch/CometWritePercolator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class CometWritePercolator
3232
static bool PrintResults(int iWhichQuery,
3333
FILE *fpOut,
3434
FILE *fpdb,
35-
int iPrintTargetDecoy);
35+
int iPrintTargetDecoy,
36+
int iLenDecoyPrefix);
3637
static void PrintPercolatorSearchHit(int iWhichQuery,
3738
int iWhichResult,
3839
int iPrintTargetDecoy,

0 commit comments

Comments
 (0)