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

Example program for retrieving general search information.

/*
##############################################################################
# file: resfile_info.cpp #
# 'msparser' toolkit example code #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998-2005 Matrix Science Limited All Rights Reserved. #
# #
##############################################################################
# $Source: parser/examples/test_cxx/resfile_info.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:: $ #
##############################################################################
*/
#include "msparser.hpp"
#include <iostream>
// All the classes are part of the matrix_science namespace
using namespace matrix_science;
/*****************************************************************************/
/* Local functions */
/* (This test harness is 'C' and not C++) */
/*****************************************************************************/
static void searchInformation(ms_mascotresfilebase & file);
/*****************************************************************************/
/* main */
/* Call this program with a single argument - the name of the .dat file */
/*****************************************************************************/
int main(int argc, char * argv[])
{
if (argc == 2)
{
ms_mascotresfilebase file = ms_mascotresfilebase::createResfile(argv[1]);
if (file.isValid())
{
searchInformation(file);
}
else
std::cout << "Error: " << file.getLastErrorString() << std::endl;
}
else
std::cout << "Must supply the name of a .dat file as a command line argument" << std::endl;
return 0;
}
/*****************************************************************************/
/* searchInformation */
/* Display parameters from the ms_mascotresfilebase object. The functions */
/* anyPMF, anyMSMS, anySQ should normally be used in preference to isPMF */
/* etc. because some people submit MSMS though the sequence query window. */
/*****************************************************************************/
static void searchInformation(ms_mascotresfilebase & file)
{
time_t t = (time_t)file.getDate();
struct tm * t1 = localtime(&t);
std::cout << "Search information from ms_mascotresfilebase" << std::endl;
std::cout << "========================================" << std::endl;
std::cout << "Number of queries : " << file.getNumQueries() << std::endl;
std::cout << "Number of sequences : " << file.getNumSeqs() << std::endl;
std::cout << "Sequences after tax : " << file.getNumSeqsAfterTax()
<< std::endl;
std::cout << "Number of residues : " << file.getNumResidues() << std::endl;
std::cout << "Execution time : " << file.getExecTime() << std::endl;
std::cout << "Date (seconds) : " << file.getDate() << std::endl;
std::cout << "Date : " << asctime(t1);
std::cout << "Mascot version : " << file.getMascotVer() << std::endl;
std::cout << "Fasta version : " << file.getFastaVer() << std::endl;
std::cout << "Is PMF? : " << file.isPMF() << std::endl;
std::cout << "Is MSMS? : " << file.isMSMS() << std::endl;
std::cout << "Is SQ? : " << file.isSQ() << std::endl;
std::cout << "Is Error tolerant : " << file.isErrorTolerant()<< std::endl;
std::cout << "Any PMF? : " << file.anyPMF() << std::endl;
std::cout << "Any MSMS? : " << file.anyMSMS() << std::endl;
std::cout << "Any SQ? : " << file.anySQ() << std::endl;
std::cout << "Any peptide matches : " << file.anyFastaMatches()
<< std::endl;
std::cout << std::endl;
}
/*
will give the output:
# test.exe F981123.dat
Search information from ms_mascotresfilebase
========================================
Number of queries : 4
Number of hits : 50
Number of sequences : 820227
Sequences after tax : 820227
Number of residues : 2.55697e+008
Execution time : 14
Date (seconds) : 1014568786
Date : Sun Feb 24 16:39:46 2002
Mascot version : 1.7.17
Fasta version : MSDB_20020121.fasta
Is PMF? : 0
Is MSMS? : 1
Is SQ? : 0
Is Error tolerant : 0
Any PMF? : 0
Any MSMS? : 1
Any SQ? : 0
Any peptide matches : 1
*/
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
virtual int getExecTime() const =0
Returns the time taken for the search.
std::string getLastErrorString() const
Return the last error number - or an empty string.
Definition: ms_mascotresfilebase.cpp:824
virtual bool anyFastaMatches(const bool isDecoy=false) const =0
Returns true if there are any FASTA matches.
virtual int getDate() const =0
Returns the date and time of the search in seconds since midnight January 1st 1970.
virtual double getNumResidues(const int idx=0) const =0
Returns the number of residues in the FASTA file(s) searched.
virtual int getNumSeqs(const int idx=0) const =0
Returns the number of sequences in the FASTA file(s) searched.
virtual int getNumSeqsAfterTax(const int idx=0) const =0
Returns the number of sequences that passed the taxonomy filter in the FASTA file(s) searched.
virtual bool anyMSMS() const =0
Returns true if any of the queries in the search contain ions data.
virtual bool isPMF() const =0
Returns true if the search was a PMF search (SEARCH=PMF).
virtual std::string getMascotVer() const =0
Returns the version of Mascot used to perform the search.
virtual bool isMSMS() const =0
Returns true if the search was an MSMS search (SEARCH=MIS).
virtual bool isErrorTolerant() const =0
Returns true if the search was an error tolerant search.
virtual bool isSQ() const =0
Returns true if the search was a sequence query search (SEARCH=SQ).
virtual std::string getFastaVer(int idx=1) const =0
Returns the FASTA file version.
virtual bool anyPMF() const =0
Returns true if any of the queries in the search just contain a single peptide mass.
virtual int getNumQueries(const int resfileID=0) const =0
Returns the number of queries (peptide masses or ms-ms spectra).
virtual bool anySQ() const =0
Returns true if any of the queries in the search contain seq or comp commands.