Example program for extracting the peptide or protein summary.
#include "msparser.hpp"
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace matrix_science;
static void displayPeptideInfo(bool showFullDetails,
bool isDuplicate,
bool isBold,
bool showCheckBox);
bool peptideSummary,
const int flags,
const double minProbability = 0,
const int maxHitsToDisplay = 50,
const double ignoreIonsScoreBelow = 0,
const int minPepLenInPepSummary = 0,
const int flags2 = ms_peptidesummary::MSPEPSUM_NONE);
int main(int argc, char * argv[])
{
int returnValue = EXIT_FAILURE;
if (argc == 2)
{
if (checkErrors(file))
{
bool usePeptideSummary;
unsigned int flags, flags2, minPepLenInPepSummary;
int maxHitsToReport;
double minProbability, ignoreIonsScoreBelow;
if (datfile.isValid())
{
mascotOptions = *(datfile.getMascotOptions());
}
mascotOptions,
&flags,
&minProbability,
&maxHitsToReport,
&ignoreIonsScoreBelow,
&minPepLenInPepSummary,
&usePeptideSummary,
&flags2);
bool bResult;
if (usePeptideSummary)
{
std::cout << "-------------------------------------------------------------" << std::endl;
std::cout << "--- Peptide summary report ---" << std::endl;
std::cout << "-------------------------------------------------------------" << std::endl;
bResult = showResults(file,
usePeptideSummary,
flags,
minProbability,
maxHitsToReport,
ignoreIonsScoreBelow,
minPepLenInPepSummary,
flags2);
}
else
{
std::cout << "-------------------------------------------------------------" << std::endl;
std::cout << "--- Full Protein summary report ---" << std::endl;
std::cout << "-------------------------------------------------------------" << std::endl;
bResult = showResults(file,
usePeptideSummary,
flags,
minProbability,
maxHitsToReport,
ignoreIonsScoreBelow,
minPepLenInPepSummary,
flags2);
if (bResult && checkErrors(file))
{
std::cout << std::endl;
flags |= ms_mascotresults::MSRES_GROUP_PROTEINS;
flags |= ms_mascotresults::MSRES_SHOW_SUBSETS;
std::cout << "-------------------------------------------------------------" << std::endl;
std::cout << "--- Concise Protein summary report ---" << std::endl;
std::cout << "-------------------------------------------------------------" << std::endl;
bResult = showResults(file,
usePeptideSummary,
flags,
minProbability,
maxHitsToReport,
ignoreIonsScoreBelow,
minPepLenInPepSummary,
flags2);
}
}
if (bResult && checkErrors(file))
{
returnValue = EXIT_SUCCESS;
}
}
}
else
{
std::cout << "Must supply the name of a .dat file as a command line argument" << std::endl;
}
return returnValue;
}
bool peptideSummary,
const int flags,
const double minProbability,
const int maxHitsToDisplay,
const double ignoreIonsScoreBelow,
const int minPepLenInPepSummary,
const int flags2)
{
if (peptideSummary)
{
0, ignoreIonsScoreBelow, minPepLenInPepSummary, "", flags2);
}
else
{
}
if (!checkErrors(file))
{
return false;
}
int family = 1;
int hit = 1;
while (prot)
{
int dbIdx = prot->
getDB();
std::cout << "Protein Hit " << hit;
if (flags & ms_mascotresults::MSRES_CLUSTER_PROTEINS)
{
std::cout << "." << family;
}
std::cout << "\n===================\n";
std::cout << "Accession : " << accession << std::endl;
std::cout << "Description : " << description << std::endl;
std::cout <<
"Score : " << prot->
getScore() << std::endl;
std::cout << "Mass : " << mass << std::endl;
std::cout <<
"Frame : " << prot->
getFrame() << std::endl;
std::cout <<
"Coverage : " << prot->
getCoverage() << std::endl;
int i;
{
if (p != -1
&& query != -1
{
{
displayPeptideInfo(false, pep, results,
}
}
}
if ( (flags & ms_mascotresults::MSRES_GROUP_PROTEINS) || (flags & ms_mascotresults::MSRES_CLUSTER_PROTEINS) )
{
std::cout << "Proteins matching the same set of peptides:" << std::endl;
i = 1;
{
if (flags & ms_mascotresults::MSRES_CLUSTER_PROTEINS)
{
int dbIdx = prot->
getDB();
if (dbIdx > 1)
{
std::cout << dbIdx << "::";
}
}
std::cout << accession.c_str()
<<
" - Total score: " << prot->
getScore()
<< std::endl;
i++;
}
if (flags & ms_mascotresults::MSRES_SHOW_SUBSETS)
{
std::cout << "Proteins matching a subset of these peptides:" << std::endl;
i = 1;
{
int dbIdx = prot->
getDB();
if ( (flags & ms_mascotresults::MSRES_CLUSTER_PROTEINS) && dbIdx > 1)
{
std::cout << dbIdx << "::";
}
std::cout << accession.c_str()
<<
" - Total score: " << prot->
getScore()
<< std::endl;
if (flags & ms_mascotresults::MSRES_CLUSTER_PROTEINS)
{
int j = 1;
{
std::cout << " Proteins matching the same set of peptides for this subset:" << std::endl;
}
while ((similar_subset_prot =
{
std::string similar_subset_accession = similar_subset_prot->
getAccession();
int similar_subset_dbIdx = similar_subset_prot->
getDB();
std::cout << " ";
if (similar_subset_dbIdx > 1)
{
std::cout << similar_subset_dbIdx << "::";
}
std::cout << similar_subset_accession.c_str()
<<
" - Total score:" << similar_subset_prot->
getScore()
<< std::endl;
j++;
}
}
i++;
}
}
}
if (flags & ms_mascotresults::MSRES_CLUSTER_PROTEINS)
{
if (!prot)
{
hit++;
family = 1;
}
}
else
{
hit++;
}
std::cout << std::endl;
}
{
std::cout << "Unassigned list" << std::endl
<< "---------------" << std::endl;
{
displayPeptideInfo(false, &pep, results, false, true, true);
}
}
if (peptideSummary)
displayYellowPopupInfo(results, 1);
delete results;
return true;
}
{
std::cout << "Score Delta Hit Protein Peptide" << std::endl;
int p;
for (p=1; p <= 10; p++)
{
if (!seq.empty())
{
std::string hit = " ";
std::string protein = " ";
if (!tmp.empty())
{
hit = tmp.substr(0, tmp.find(':'));
std::string::size_type start = tmp.find(":\"");
if (start != tmp.rfind(":\""))
hit += "+";
protein = tmp.substr(2 + start, tmp.find("\" ") - start -2);
}
<< hit << " "
<< protein << " "
}
}
p = 1;
std::cout << "Accessions that matched query " << q
<< " rank " << p << ":- "
<< std::endl << std::endl;
}
static void displayPeptideInfo(bool showFullDetails,
bool isDuplicate,
bool isBold,
bool showCheckBox)
{
if (showFullDetails)
{
std::cout << "Peptide hit" << std::endl;
{
std::cout << " Query : " << q << std::endl;
std::cout <<
" Rank : " << p->
getRank() << std::endl;
std::cout <<
" Matched : " << p->
getAnyMatch() << std::endl;
std::cout <<
" mrCalc : " << p->
getMrCalc() << std::endl;
std::cout <<
" delta : " << p->
getDelta() << std::endl;
std::cout <<
" observed : " << p->
getObserved() << std::endl;
std::cout <<
" charge : " << p->
getCharge() << std::endl;
std::cout <<
" peptideStr : " << p->
getPeptideStr() << std::endl;
std::cout <<
" varModsStr : " << p->
getVarModsStr() << std::endl;
std::cout <<
" tag matches : " << r->
getTagString(q, 1) << std::endl;
std::cout <<
" first tag : 1:" << r->
getTagStart(q,1,1)
std::cout <<
" ionsScore : " << p->
getIonsScore() << std::endl;
std::cout << " idth, hth, p: "
<< std::endl;
}
else
std::cout << " No match" << std::endl;
}
else
{
if (showCheckBox)
std::cout << "CB ";
else
std::cout << "-- ";
if (isBold)
std::cout << "BOLD ";
else
std::cout << "dim ";
std::cout << std::setiosflags(std::ios::left) << std::setw(4) << std::setfill(' ') << q;
std::cout << std::setiosflags(std::ios::left) << std::setw(11) << std::setfill(
' ') << p->
getObserved();
std::cout << std::setiosflags(std::ios::left) << std::setw(3) << std::setfill(
' ') << p->
getRank();
std::cout << "(";
std::cout << std::setiosflags(std::ios::left) << std::setw(3) << std::setfill(
' ') << p->
getPrettyRank();
std::cout << ")";
std::cout << std::setiosflags(std::ios::left) << std::setw(20) << std::setfill(
' ') << p->
getPeptideStr()
<< "\t";
if (isDuplicate)
else
std::cout << "\t";
std::cout << std::endl;
}
}
{
{
{
std::cout << "Error number: "
<< " : "
<< std::endl;
}
}
return bIsValid;
}
Encapsulates the mascot.dat file that contains the most important parameters.
Definition: ms_datfile.hpp:47
bool isValid() const
Call this function to determine if there have been any errors.
Definition: ms_errors.cpp:1472
void clearAllErrors()
Remove all errors from the current list of errors.
Definition: ms_errors.cpp:1457
An instance of this class represents all the parameters specified in the Options section of mascot....
Definition: ms_mascotoptions.hpp:91
Abstract base class of ms_mascotresfile_dat and ms_mascotresfile_msr.
Definition: ms_mascotresfilebase.hpp:72
int getErrorNumber(const int num=-1) const
Return a specific error number - or ms_errs::ERR_NO_ERROR.
Definition: ms_mascotresfilebase.cpp:776
int getLastError() const
Return the last error number - or ms_erros::ERR_NO_ERROR.
Definition: ms_mascotresfilebase.cpp:786
std::string get_ms_mascotresults_params(const ms_mascotoptions &opts, ms_mascotresults_params ¶ms) const
Return default flags and parameters for creating an ms_peptidesummary or ms_proteinsummary object.
Definition: ms_mascotresfilebase.cpp:1380
std::string getErrorString(const int num) const
Return a specific error as a string.
Definition: ms_mascotresfilebase.cpp:814
int getNumberOfErrors() const
Return the number of errors since the last call to clearAllErrors.
Definition: ms_mascotresfilebase.cpp:749
Abstract class for either ms_peptidesummary or ms_proteinsummary.
Definition: ms_mascotresults.hpp:83
virtual int getTagStart(const int q, const int p, const int tagNumber) const
Return the start position for the tag-match from h1_q2_tag or q1_p1_tag.
Definition: ms_mascotresults.cpp:2174
std::string getProteinDescription(const char *accession, const int dbIdx=1) const
Return protein description if available.
Definition: ms_mascotresults.cpp:243
double getProteinMass(const char *accession, const int dbIdx=1) const
Return protein mass if available.
Definition: ms_mascotresults.cpp:299
virtual ms_protein * getNextFamilyProtein(const int masterHit, const int id) const
Find the next protein in the family masterHit.
Definition: ms_mascotresults.cpp:1144
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 int getTagDeltaRangeEnd(const int q, const int p) const =0
Return the second number from h1_q2_drange=0,256.
virtual ms_protein * getNextSimilarProteinOf(const char *masterAccession, const int masterDB, const int id) const
Return the next protein that contains all the peptides in the 'master' protein.
Definition: ms_mascotresults.cpp:1122
virtual std::string getTagString(const int q, const int p) const =0
Return the complete tag string from h1_q2_tag or q1_p1_tag.
int getNumberOfUnassigned() const
Return the number of peptides in the unassigned list.
Definition: ms_mascotresults.cpp:2316
virtual ms_protein * getNextSubsetProteinOf(const char *masterAccession, const int masterDB, const int id) const
Return the next protein that contains some of the peptides in the 'master' protein.
Definition: ms_mascotresults.cpp:1193
bool createUnassignedList(sortBy s=QUERY)
To have a list of unassigned peptides, need to call this first.
Definition: ms_mascotresults.cpp:2295
virtual int getTagDeltaRangeStart(const int q, const int p) const =0
Return the first number from h1_q2_drange=0,256.
virtual int getTagSeries(const int q, const int p, const int tagNumber) const
Return the series ID for the tag-match from h1_q2_tag or q1_p1_tag.
Definition: ms_mascotresults.cpp:2257
virtual double getProbOfPepBeingRandomMatch(const double score, const int query) const
Definition: ms_mascotresults.cpp:901
virtual int getHomologyThreshold(const int query, double OneInXprobRnd, const int rank=1) const
Returns the 'homology' threshold.
Definition: ms_mascotresults.cpp:828
ms_peptide getUnassigned(const int num) const
Need to call createUnassignedList() before calling this.
Definition: ms_mascotresults.cpp:2337
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 int getTagEnd(const int q, const int p, const int tagNumber) const
Return the end position for the tag-match from h1_q2_tag or q1_p1_tag.
Definition: ms_mascotresults.cpp:2197
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.
virtual std::string getReadableVarMods(const int q, const int p, const int numDecimalPlaces=2, const ms_peptide::PSM psmComponent=ms_peptide::PSM_COMPLETE) const
Return a 'human readable' string with the variable, summed and error tolerant mods.
Definition: ms_mascotresults.cpp:1608
This class encapsulates a peptide from the mascot results file.
Definition: ms_peptide.hpp:57
int getPrettyRank() const
Similar to getRank() except that equivalent scores get the same rank.
Definition: ms_peptide.cpp:517
int getRank() const
Return the 'rank' of the peptide match.
Definition: ms_peptide.cpp:458
int getMissedCleavages(const PSM psmComponent=PSM_COMPLETE) const
Returns the number of missed cleavages.
Definition: ms_peptide.cpp:583
bool getAnyMatch() const
Returns true if there was a peptide match to this spectrum.
Definition: ms_peptide.cpp:557
std::string getVarModsStr(const PSM psmComponent=PSM_COMPLETE) const
Variable modifications as a string of digits.
Definition: ms_peptide.cpp:834
int getNumIonsMatched() const
Returns the number of ions matched.
Definition: ms_peptide.cpp:685
int getPeaksUsedFromIons1() const
Returns number of peaks used from ions1.
Definition: ms_peptide.cpp:748
int getCharge() const
Returns the charge state for the parent mass.
Definition: ms_peptide.cpp:658
std::string getSeriesUsedStr() const
Returns the series used as a string.
Definition: ms_peptide.cpp:1100
double getObserved() const
Returns the observed mass / charge value.
Definition: ms_peptide.cpp:629
double getDelta() const
Returns the difference between the calculated and experimental relative masses.
Definition: ms_peptide.cpp:619
double getMrExperimental() const
Returns the observed mz value as a relative mass.
Definition: ms_peptide.cpp:644
int getPeaksUsedFromIons2() const
Returns number of peaks used from ions2.
Definition: ms_peptide.cpp:774
double getIonsScore() const
Returns the ions score.
Definition: ms_peptide.cpp:1050
double getMrCalc(const PSM psmComponent=PSM_COMPLETE) const
Returns the calculated relative mass for this peptide .
Definition: ms_peptide.cpp:610
std::string getPeptideStr(bool substituteAmbiguous=true, const PSM psmComponent=PSM_COMPLETE) const
Returns the sequence found for the peptide.
Definition: ms_peptide.cpp:710
int getQuery() const
Each peptide is associate with a query.
Definition: ms_peptide.cpp:441
int getPeaksUsedFromIons3() const
Returns number of peaks used from ions3.
Definition: ms_peptide.cpp:800
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
double getScore() const
Return the protein score for this protein.
Definition: ms_protein.cpp:574
int getNumPeptides() const
Return the number of peptides that had a match in this protein.
Definition: ms_protein.cpp:621
int getNumDisplayPeptides(bool aboveThreshold=false) const
Return the number of peptides excluding those that with duplicate matches to same query.
Definition: ms_protein.cpp:1587
DUPLICATE getPeptideDuplicate(const int pepNumber, const bool allowErrTolDuplicate=true) const
Return the DUPLICATE status given the peptide 'number'.
Definition: ms_protein.cpp:966
int getPeptideP(const int pepNumber) const
Return the 'rank' number given the peptide 'number'.
Definition: ms_protein.cpp:751
int getPeptideQuery(const int pepNumber) const
Return the query number given the peptide 'number'.
Definition: ms_protein.cpp:727
int getDB() const
Return the index of the database where the sequence is found.
Definition: ms_protein.cpp:494
bool getPeptideIsBold(const int pepNumber) const
Returns true if this peptide should be displayed in bold in a Mascot report.
Definition: ms_protein.cpp:1448
std::string getAccession() const
Return the accession string for a protein.
Definition: ms_protein.cpp:479
bool getPeptideShowCheckbox(const int pepNumber) const
Returns true if a check box for repeat searches should be shown in a Mascot report.
Definition: ms_protein.cpp:1490
int getFrame() const
Returns the frame number for the protein.
Definition: ms_protein.cpp:1403
long getCoverage() const
Return the number of residues covered.
Definition: ms_protein.cpp:1244
Definition: ms_proteinsummary.hpp:45