Skip to content

Commit 7c9150d

Browse files
committed
add support for the hidden parameter 'export_additional_pepxml_scores' which adss lnrSp, deltLCn, lnExpect, and IonFrac search scores to the pep.xml output
1 parent cc7bba6 commit 7c9150d

File tree

5 files changed

+53
-8
lines changed

5 files changed

+53
-8
lines changed

Comet.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void SetOptions(char *arg,
148148
else
149149
pSearchMgr->SetOutputFileBaseName(szTmp);
150150
break;
151-
case 'F':
151+
case 'F': // first scan
152152
if (sscanf(arg+2, "%511s", szTmp) == 0 )
153153
logerr("Missing text for parameter option -F<num>. Ignored.\n");
154154
else
@@ -162,7 +162,7 @@ void SetOptions(char *arg,
162162
pSearchMgr->SetParam("scan_range", szParamStringVal, iScanRange);
163163
}
164164
break;
165-
case 'L':
165+
case 'L': // last scan
166166
if (sscanf(arg+2, "%511s", szTmp) == 0 )
167167
logerr("Missing text for parameter option -L<num>. Ignored.\n");
168168
else
@@ -176,7 +176,7 @@ void SetOptions(char *arg,
176176
pSearchMgr->SetParam("scan_range", szParamStringVal, iScanRange);
177177
}
178178
break;
179-
case 'B':
179+
case 'B': // batch size
180180
if (sscanf(arg+2, "%511s", szTmp) == 0 )
181181
logerr("Missing text for parameter option -B<num>. Ignored.\n");
182182
else
@@ -737,6 +737,13 @@ void LoadParameters(char *pszParamsFile,
737737
sprintf(szParamStringVal, "%lf %lf", doubleRangeParam.dStart, doubleRangeParam.dEnd);
738738
pSearchMgr->SetParam("clear_mz_range", szParamStringVal, doubleRangeParam);
739739
}
740+
else if (!strcmp(szParamName, "export_additional_pepxml_scores"))
741+
{
742+
sscanf(szParamVal, "%d", &iIntParam);
743+
szParamStringVal[0] = '\0';
744+
sprintf(szParamStringVal, "%d", iIntParam);
745+
pSearchMgr->SetParam("export_additional_pepxml_scores", szParamStringVal, iIntParam);
746+
}
740747
else if (!strcmp(szParamName, "print_expect_score"))
741748
{
742749
sscanf(szParamVal, "%d", &iIntParam);

CometSearch/CometDataInternal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct Options // output parameters
117117
int bShowFragmentIons;
118118
int bExplicitDeltaCn; // if set to 1, do not use sequence similarity logic
119119
int bPrintExpectScore;
120+
int bExportAdditionalScoresPepXML; // if 1, also report lnrSp, lnExpect, IonFrac, lnNumSP to pepXML output
120121
int bOverrideCharge;
121122
int bCorrectMass; // use selectionMZ instead of monoMZ if monoMZ is outside selection window
122123
int bTreatSameIL;
@@ -168,6 +169,7 @@ struct Options // output parameters
168169
bShowFragmentIons = a.bShowFragmentIons;
169170
bExplicitDeltaCn = a.bExplicitDeltaCn;
170171
bPrintExpectScore = a.bPrintExpectScore;
172+
bExportAdditionalScoresPepXML = a.bExportAdditionalScoresPepXML;
171173
bOverrideCharge = a.bOverrideCharge;
172174
bCorrectMass = a.bCorrectMass;
173175
bTreatSameIL = a.bTreatSameIL;
@@ -763,6 +765,7 @@ struct StaticParams
763765
options.bShowFragmentIons = 0;
764766
options.bExplicitDeltaCn = 0;
765767
options.bPrintExpectScore = 1;
768+
options.bExportAdditionalScoresPepXML = 0;
766769
options.bOverrideCharge = 0;
767770
options.bCorrectMass = 0;
768771
options.bTreatSameIL = 1;

CometSearch/CometSearchManager.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ bool CometSearchManager::InitializeStaticParams()
757757

758758
GetParamValue("print_expect_score", g_staticParams.options.bPrintExpectScore);
759759

760+
GetParamValue("export_additional_pepxml_scores", g_staticParams.options.bExportAdditionalScoresPepXML);
761+
760762
GetParamValue("output_sqtstream", g_staticParams.options.bOutputSqtStream);
761763

762764
GetParamValue("output_sqtfile", g_staticParams.options.bOutputSqtFile);

CometSearch/CometWritePepXML.cpp

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,20 @@ void CometWritePepXML::PrintResults(int iWhichQuery,
560560
if (iWhichResult > 0 && !isEqual(pOutput[iWhichResult].fXcorr, pOutput[iWhichResult-1].fXcorr))
561561
iRankXcorr++;
562562

563+
double dLastDeltaCn = 1.0; // this is deltaCn between first and last peptide in output list
564+
565+
if (g_staticParams.options.bExportAdditionalScoresPepXML)
566+
{
567+
if (pOutput[iWhichResult].fXcorr > 0.0 && pOutput[iNumPrintLines-1].fXcorr >= 0.0)
568+
dLastDeltaCn = (pOutput[iWhichResult].fXcorr - pOutput[iNumPrintLines-1].fXcorr)/pOutput[iWhichResult].fXcorr;
569+
else if (pOutput[iWhichResult].fXcorr > 0.0 && pOutput[iNumPrintLines-1].fXcorr < 0.0)
570+
dLastDeltaCn = 1.0;
571+
else
572+
dLastDeltaCn = 0.0;
573+
}
574+
563575
if (pOutput[iWhichResult].fXcorr > g_staticParams.options.dMinimumXcorr)
564-
PrintPepXMLSearchHit(iWhichQuery, iWhichResult, iRankXcorr, iPrintTargetDecoy, pOutput, fpout, fpdb, dDeltaCn);
576+
PrintPepXMLSearchHit(iWhichQuery, iWhichResult, iRankXcorr, iPrintTargetDecoy, pOutput, fpout, fpdb, dDeltaCn, dLastDeltaCn);
565577
}
566578

567579
fprintf(fpout, " </search_result>\n");
@@ -576,7 +588,8 @@ void CometWritePepXML::PrintPepXMLSearchHit(int iWhichQuery,
576588
Results *pOutput,
577589
FILE *fpout,
578590
FILE *fpdb,
579-
double dDeltaCn)
591+
double dDeltaCn,
592+
double dLastDeltaCn)
580593
{
581594
int i;
582595
int iNTT;
@@ -881,11 +894,30 @@ void CometWritePepXML::PrintPepXMLSearchHit(int iWhichQuery,
881894
fprintf(fpout, " </modification_info>\n");
882895
}
883896

884-
fprintf(fpout, " <search_score name=\"xcorr\" value=\"%0.3f\"/>\n", pOutput[iWhichResult].fXcorr);
885-
fprintf(fpout, " <search_score name=\"deltacn\" value=\"%0.3f\"/>\n", dDeltaCn);
897+
fprintf(fpout, " <search_score name=\"xcorr\" value=\"%0.4f\"/>\n", pOutput[iWhichResult].fXcorr);
898+
fprintf(fpout, " <search_score name=\"deltacn\" value=\"%0.4f\"/>\n", dDeltaCn);
886899
fprintf(fpout, " <search_score name=\"spscore\" value=\"%0.1f\"/>\n", pOutput[iWhichResult].fScoreSp);
887900
fprintf(fpout, " <search_score name=\"sprank\" value=\"%d\"/>\n", pOutput[iWhichResult].iRankSp);
888901
fprintf(fpout, " <search_score name=\"expect\" value=\"%0.2E\"/>\n", pOutput[iWhichResult].dExpect);
902+
903+
if (g_staticParams.options.bExportAdditionalScoresPepXML)
904+
{
905+
fprintf(fpout, " <search_score name=\"lnrSp\" value=\"%0.4f\"/>\n", log((double)pOutput[iWhichResult].iRankSp));
906+
fprintf(fpout, " <search_score name=\"deltLCn\" value=\"%0.4f\"/>\n", dLastDeltaCn);
907+
fprintf(fpout, " <search_score name=\"lnExpect\" value=\"%0.4f\"/>\n", log(pOutput[iWhichResult].dExpect));
908+
fprintf(fpout, " <search_score name=\"IonFrac\" value=\"%0.4f\"/>\n", (double)pOutput[iWhichResult].iMatchedIons / pOutput[iWhichResult].iTotalIons);
909+
910+
unsigned long uliNumMatch;
911+
if (iPrintTargetDecoy == 2)
912+
uliNumMatch = pQuery->_uliNumMatchedDecoyPeptides;
913+
else
914+
uliNumMatch = pQuery->_uliNumMatchedPeptides;
915+
if (uliNumMatch > 0)
916+
fprintf(fpout, " <search_score name=\"lnNumSP\" value=\"%0.4f\"/>\n", log((double)(uliNumMatch)));
917+
else
918+
fprintf(fpout, " <search_score name=\"lnNumSP\" value=\"%0.4f\"/>\n", -20.0);
919+
}
920+
889921
fprintf(fpout, " </search_hit>\n");
890922
}
891923

CometSearch/CometWritePepXML.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class CometWritePepXML
5757
Results *pOutput,
5858
FILE *fpOut,
5959
FILE *fpdb,
60-
double dDeltaCn);
60+
double dDeltaCn,
61+
double dLastDeltaCn);
6162

6263
static void GetVal(char *szElement,
6364
char *szAttribute,

0 commit comments

Comments
 (0)