Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
peptide_list.cpp

Show the list of peptides in a table - for use as a CGI application.

/*
##############################################################################
# file: peptide_list.cpp #
# 'msparser' toolkit #
# Test harness / example code #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998-2005 Matrix Science Limited All Rights Reserved. #
# #
##############################################################################
# $Source: parser/examples/test_cxx/peptide_list.cpp $ #
# $Author: robertog@matrixscience.com $ #
# $Date: 2024-09-04 10:23:46 +0100 $ #
# $Revision: 526921a73137894bb1eae0b0fc8ccb4bb52ea662 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $ #
# $NoKeywords:: $ #
##############################################################################
*/
/*
##############################################################################
# Print out a table of results - peptide based list for QA
# Table should contain a list of unique peptides - every significant match
# Copy the executable to the mascot/cgi directory, and then, when looking
# at a report replace the master_results.pl in the URL with peptide_list.exe
##############################################################################
*/
#include "msparser.hpp"
#include <set>
#include <iostream>
#include <time.h>
#include <iomanip>
// All the classes are part of the matrix_science namespace
using namespace matrix_science;
/*****************************************************************************/
/* main */
/* Call this program with a single argument - file=[name of the .dat file] */
/*****************************************************************************/
int main(int argc, char * argv[])
{
#ifdef _DEBUG
putenv("QUERY_STRING=file=../data/20021123/F018521.dat");
#endif
std::cout << "Content-type: text/html" << std::endl << std::endl;
std::cout << "<HTML>" << std::endl;
std::cout << "<HEAD>" << std::endl;
std::cout << " <TITLE>Mascot summary</TITLE>" << std::endl;
std::cout << "</HEAD>" << std::endl;
std::cout << "<BODY BGCOLOR=\"#ffffff\">" << std::endl;;
if (getenv("QUERY_STRING") && strncmp(getenv("QUERY_STRING"), "file=", 5) == 0)
{
ms_mascotresfilebase file = ms_mascotresfilebase::createResfile(getenv("QUERY_STRING")+strlen("file="));
if (file.isValid())
{
if (file.isMSMS())
{
ms_mascotresults * results;
results = new ms_peptidesummary(file,
ms_mascotresults::MSRES_GROUP_PROTEINS |
ms_mascotresults::MSRES_SHOW_SUBSETS,
0, // minProbability
1000, // number of hits
0, // ignoreIonsScoreBelow
0); // minimum peptide length
ms_protein * prot = results->getHit(1);
if (!prot)
std::cout << "No significant matches" << std::endl;
else
{
std::set<std::string> pep_strings;
std::cout << "<TABLE BORDER=1>" << std::endl;
std::cout << " <TR>" << std::endl;
std::cout << " <TD><B>Peptide</B></TD>" << std::endl
<< " <TD><B>Score</B></TD>" << std::endl
<< " <TD><B>Query</B></TD>" << std::endl
<< " <TD><B>Rank</B></TD>" << std::endl
<< " <TD><B>Proteins</B></TD>" << std::endl;
std::cout << " </TR>" << std::endl;
for (int query=1; query <= file.getNumQueries(); query++)
{
for (int p=1; p <= 10; p++)
{
double threshold = results->getPeptideIdentityThreshold(query, 20);
ms_peptide * pep;
if ( results->getPeptide(query, p, pep)
&& (pep->getIonsScore() >= threshold))
{
if (pep_strings.insert(pep->getPeptideStr()).second)
{
std::cout << " <TR>" << std::endl;
std::cout << " <TD>"
<< pep->getPeptideStr().c_str()
<< " </TD>"
<< std::endl;
std::cout << " <TD>"
<< pep->getIonsScore()
<< " </TD>"
<< std::endl;
std::cout << " <TD>" << query << " </TD>" << std::endl;
std::cout << " <TD>" << p << " </TD>" << std::endl;
std::cout << " <TD>"
<< results->getProteinsWithThisPepMatch(query, p).c_str()
<< " </TD>"
<< std::endl;
std::cout << " </TR>" << std::endl;
}
}
}
}
std::cout << "</TABLE>" << std::endl;
}
if (file.getLastError())
{
std::cout << "There was an error..." << std::endl;
std::cout << "Error: " << file.getLastErrorString() << std::endl;
}
}
}
else
std::cout << "Error: " << file.getLastErrorString() << std::endl;
}
else
std::cout << "Must supply 'file=[name of a .dat file]'"
<< "Number of args = " << argc
<< "QS=" << getenv("QUERY_STRING")
<<std::endl;
std::cout << "</BODY>" << std::endl;;
std::cout << "</HTML>" << std::endl;;
return 0;
}
/* Will give for example the following output:
<TABLE BORDER=1>
<TR>
<TD><B>Peptide</B></TD>
<TD><B>Score</B></TD>
<TD><B>Query</B></TD>
<TD><B>Rank</B></TD>
<TD><B>Proteins</B></TD>
</TR>
<TR>
<TD>GPSSVEDIK </TD>
<TD>68.06 </TD>
<TD>17 </TD>
<TD>1 </TD>
<TD>9:Q96AT6 </TD>
</TR>
<TR>
<TD>SGEVLVNVK </TD>
<TD>79.37 </TD>
<TD>18 </TD>
<TD>1 </TD>
<TD>13:S60335 15:Q9QZD9 </TD>
</TR>
<TR>
<TD>MSDGLFLQK </TD>
<TD>54.93 </TD>
<TD>29 </TD>
<TD>1 </TD>
<TD>16:S55282 </TD>
</TR>
<TR>
<TD>LGGSQEDQIK </TD>
<TD>67.93 </TD>
<TD>31 </TD>
<TD>1 </TD>
<TD>2:AAH10103 </TD>
</TR>
<TR>
<TD>AGLGHPAAFGR </TD>
<TD>57.48 </TD>
<TD>34 </TD>
<TD>1 </TD>
<TD>19:DDH1_HUMAN </TD>
</TR>
<TR>
<TD>TPEEYPESAK </TD>
<TD>54.88 </TD>
<TD>37 </TD>
<TD>1 </TD>
<TD>19:DDH1_HUMAN </TD>
</TR>
<TR>
<TD>SSGTSYPDVLK </TD>
<TD>63.42 </TD>
<TD>38 </TD>
<TD>1 </TD>
<TD>4:TRBOTR 6:1NTP </TD>
</TR>
<TR>
<TD>VCNYVSWIK </TD>
<TD>55.78 </TD>
<TD>41 </TD>
<TD>1 </TD>
<TD>4:TRBOTR 6:1NTP </TD>
</TR>
<TR>
<TD>IDTIEIITDR </TD>
<TD>69.04 </TD>
<TD>43 </TD>
<TD>1 </TD>
<TD>8:AAC26867 11:Q9TTV2 </TD>
</TR>
<TR>
<TD>DITSDTSGDFR </TD>
<TD>69.53 </TD>
<TD>45 </TD>
<TD>1 </TD>
<TD>1:LUHU 3:AAB19866 7:ANX1_MOUSE </TD>
</TR>
<TR>
<TD>LLGELLQDNAK </TD>
<TD>64.14 </TD>
<TD>46 </TD>
<TD>1 </TD>
<TD>2:AAH10103 </TD>
</TR>
<TR>
<TD>VGMIPVPYVEK </TD>
<TD>54.23 </TD>
<TD>52 </TD>
<TD>1 </TD>
<TD>18:S41754 </TD>
</TR>
<TR>
<TD>TPAQFDADELR </TD>
<TD>66.27 </TD>
<TD>53 </TD>
<TD>1 </TD>
<TD>1:LUHU 3:AAB19866 5:AAC78495 7:ANX1_MOUSE 27:CAA64477 </TD>
</TR>
<TR>
<TD>LSSTWEGIQAGK </TD>
<TD>77.53 </TD>
<TD>54 </TD>
<TD>1 </TD>
<TD>2:AAH10103 </TD>
</TR>
<TR>
<TD>SLDLDSIIAEVK </TD>
<TD>80.49 </TD>
<TD>56 </TD>
<TD>1 </TD>
<TD>17:AAG41947 </TD>
</TR>
<TR>
<TD>AVLENNLGAAVLR </TD>
<TD>57.63 </TD>
<TD>63 </TD>
<TD>1 </TD>
<TD>36:Q9BS89 </TD>
</TR>
<TR>
<TD>ALEESNYELEGK </TD>
<TD>59.06 </TD>
<TD>67 </TD>
<TD>1 </TD>
<TD>22:KRMSE1 </TD>
</TR>
<TR>
<TD>VLGTEELYGYLK </TD>
<TD>65.31 </TD>
<TD>68 </TD>
<TD>1 </TD>
<TD>14:B35838 </TD>
</TR>
<TR>
<TD>VLGTDELYGYLK </TD>
<TD>65.31 </TD>
<TD>68 </TD>
<TD>2 </TD>
<TD>12:B38611 </TD>
</TR>
<TR>
<TD>GVDEATIIDILTK </TD>
<TD>73.44 </TD>
<TD>69 </TD>
<TD>1 </TD>
<TD>1:LUHU 3:AAB19866 5:AAC78495 7:ANX1_MOUSE 20:LUGP1 </TD>
</TR>
<TR>
<TD>QSLEASLAETEGR </TD>
<TD>60.48 </TD>
<TD>70 </TD>
<TD>1 </TD>
<TD>22:KRMSE1 </TD>
</TR>
<TR>
<TD>TPYTDVNIVTIR </TD>
<TD>73.23 </TD>
<TD>71 </TD>
<TD>1 </TD>
<TD>16:S55282 </TD>
</TR>
<TR>
<TD>ALAGCDFLTISPK </TD>
<TD>58.07 </TD>
<TD>72 </TD>
<TD>1 </TD>
<TD>2:AAH10103 </TD>
</TR>
<TR>
<TD>WELLQQVDTSTR </TD>
<TD>64.49 </TD>
<TD>80 </TD>
<TD>1 </TD>
<TD>17:AAG41947 </TD>
</TR>
<TR>
<TD>EVYQQQQYGSGGR </TD>
<TD>66.95 </TD>
<TD>83 </TD>
<TD>1 </TD>
<TD>10:Q9BQ99 </TD>
</TR>
<TR>
<TD>IFVGGLNPEATEEK </TD>
<TD>62.15 </TD>
<TD>84 </TD>
<TD>1 </TD>
<TD>10:Q9BQ99 </TD>
</TR>
<TR>
<TD>IFVGGINPEATEEK </TD>
<TD>62.15 </TD>
<TD>84 </TD>
<TD>2 </TD>
<TD>23:PC4375 </TD>
</TR>
<TR>
<TD>QLYQILTDFDIR </TD>
<TD>63.62 </TD>
<TD>87 </TD>
<TD>1 </TD>
<TD>12:B38611 14:B35838 </TD>
</TR>
<TR>
<TD>GTDVNVFNTILTTR </TD>
<TD>71.62 </TD>
<TD>93 </TD>
<TD>1 </TD>
<TD>1:LUHU 3:AAB19866 </TD>
</TR>
<TR>
<TD>SDSEKLNLDSIIGR </TD>
<TD>58.2 </TD>
<TD>96 </TD>
<TD>1 </TD>
<TD>39:Q9Z1G2 </TD>
</TR>
<TR>
<TD>DSCQGDSGGPVVCSGK </TD>
<TD>71.13 </TD>
<TD>97 </TD>
<TD>1 </TD>
<TD>4:TRBOTR 6:1NTP </TD>
</TR>
<TR>
<TD>DLAKDITSDTSGDFR </TD>
<TD>57.65 </TD>
<TD>99 </TD>
<TD>1 </TD>
<TD>1:LUHU 3:AAB19866 7:ANX1_MOUSE </TD>
</TR>
<TR>
<TD>GLGTDEDTLIEILASR </TD>
<TD>87.32 </TD>
<TD>103 </TD>
<TD>1 </TD>
<TD>1:LUHU 5:AAC78495 </TD>
</TR>
<TR>
<TD>GAGTEEACLIDILASR </TD>
<TD>54.48 </TD>
<TD>103 </TD>
<TD>2 </TD>
<TD>33:O93444 </TD>
</TR>
<TR>
<TD>SEDFGVNEDLADSDAR </TD>
<TD>103.46 </TD>
<TD>105 </TD>
<TD>1 </TD>
<TD>1:LUHU </TD>
</TR>
<TR>
<TD>LISWYDNEFGYSNR </TD>
<TD>58.42 </TD>
<TD>107 </TD>
<TD>1 </TD>
<TD>28:DEHUG3 30:AAC16069 </TD>
</TR>
<TR>
<TD>LVTWYDNEFGYSNR </TD>
<TD>57.61 </TD>
<TD>107 </TD>
<TD>2 </TD>
<TD>37:Q90Z48 </TD>
</TR>
<TR>
<TD>TPALVFEYINNTDFK </TD>
<TD>69.27 </TD>
<TD>108 </TD>
<TD>1 </TD>
<TD>12:B38611 14:B35838 </TD>
</TR>
<TR>
<TD>IFVGGLNPEATEEKIR </TD>
<TD>54.63 </TD>
<TD>109 </TD>
<TD>1 </TD>
<TD>10:Q9BQ99 </TD>
</TR>
<TR>
<TD>IFVGGINPEATEEKIR </TD>
<TD>54.63 </TD>
<TD>109 </TD>
<TD>2 </TD>
<TD>23:PC4375 </TD>
</TR>
<TR>
<TD>VGAVAGNDWLIWDITR </TD>
<TD>63.06 </TD>
<TD>113 </TD>
<TD>1 </TD>
<TD>35:Q9H644 </TD>
</TR>
<TR>
<TD>VGAVAGNDWIIWDITR </TD>
<TD>63.06 </TD>
<TD>113 </TD>
<TD>2 </TD>
<TD>32:Q9CWU9 </TD>
</TR>
<TR>
<TD>LFIGGLSFETTDESLR </TD>
<TD>61.89 </TD>
<TD>117 </TD>
<TD>1 </TD>
<TD>25:1HA11 </TD>
</TR>
<TR>
<TD>LFIGGLSFETTEESLR </TD>
<TD>61.89 </TD>
<TD>117 </TD>
<TD>2 </TD>
<TD>8:AAC26867 21:S40776 </TD>
</TR>
<TR>
<TD>LFIGGLSFETTDDSLR </TD>
<TD>61.89 </TD>
<TD>117 </TD>
<TD>3 </TD>
<TD>26:Q9CRI0 </TD>
</TR>
<TR>
<TD>MTDQEAIQDLWQWR </TD>
<TD>58.31 </TD>
<TD>118 </TD>
<TD>1 </TD>
<TD>9:Q96AT6 </TD>
</TR>
<TR>
<TD>GFSEGLWEIENNPTVK </TD>
<TD>54.12 </TD>
<TD>119 </TD>
<TD>1 </TD>
<TD>24:Q9XSK7 </TD>
</TR>
<TR>
<TD>QAWFIENEEQEYVQTVK </TD>
<TD>71.47 </TD>
<TD>132 </TD>
<TD>1 </TD>
<TD>1:LUHU </TD>
</TR>
<TR>
<TD>LGEDNINVVEGNEQFISASK </TD>
<TD>83.36 </TD>
<TD>134 </TD>
<TD>1 </TD>
<TD>4:TRBOTR 6:1NTP </TD>
</TR>
<TR>
<TD>MSVQPTVSLGGFEITPPVVLR </TD>
<TD>81.19 </TD>
<TD>140 </TD>
<TD>1 </TD>
<TD>9:Q96AT6 </TD>
</TR>
<TR>
<TD>GGPGSAVSPYPTFNPSSDVAALHK </TD>
<TD>64.58 </TD>
<TD>149 </TD>
<TD>1 </TD>
<TD>1:LUHU </TD>
</TR>
</TABLE>
*/
bool isValid() const
Call this function to determine if there have been any errors.
Definition: ms_errors.cpp:1472
Abstract base class of ms_mascotresfile_dat and ms_mascotresfile_msr.
Definition: ms_mascotresfilebase.hpp:72
std::string getLastErrorString() const
Return the last error number - or an empty string.
Definition: ms_mascotresfilebase.cpp:824
int getLastError() const
Return the last error number - or ms_erros::ERR_NO_ERROR.
Definition: ms_mascotresfilebase.cpp:786
virtual bool isMSMS() const =0
Returns true if the search was an MSMS search (SEARCH=MIS).
virtual int getNumQueries(const int resfileID=0) const =0
Returns the number of queries (peptide masses or ms-ms spectra).
Abstract class for either ms_peptidesummary or ms_proteinsummary.
Definition: ms_mascotresults.hpp:83
virtual int getPeptideIdentityThreshold(const int query, double OneInXprobRnd, DB_MATCH_TYPE dbType=DM_FASTA) const
Return the threshold value for this ms-ms data being a random match.
Definition: ms_mascotresults.cpp:605
virtual ms_peptide getPeptide(const int q, const int p) const =0
Return the ms_peptide object given the query and either the rank (ms_peptidesummary) or the hit (ms_p...
virtual ms_protein * getHit(const int hit, const int memberNumber=0) const
Return the ms_protein hit - returns null if hit > number of hits.
Definition: ms_mascotresults.cpp:1030
virtual std::string getProteinsWithThisPepMatch(const int q, const int p, const bool quotes=false)=0
Return a partial list of proteins that matched the same peptide.
This class encapsulates a peptide from the mascot results file.
Definition: ms_peptide.hpp:57
double getIonsScore() const
Returns the ions score.
Definition: ms_peptide.cpp:1050
std::string getPeptideStr(bool substituteAmbiguous=true, const PSM psmComponent=PSM_COMPLETE) const
Returns the sequence found for the peptide.
Definition: ms_peptide.cpp:710
Use this class to get peptide summary results.
Definition: ms_peptidesummary.hpp:51
This class encapsulates a protein in the mascot results file.
Definition: ms_protein.hpp:57