Matrix Science header

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: /vol/cvsroot/parser/examples/test_cxx/peptide_list.cpp,v $ #
#     $Author: davidc $ #
#       $Date: 2005/01/19 15:17:54 $ #
#   $Revision: 1.2 $ #
# $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_mascotresfile file(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>
*/
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:50