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

Read in the taxonomy file.

/*
##############################################################################
# file: config_taxonomy.cpp #
# 'msparser' toolkit example code #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998-2005 Matrix Science Limited All Rights Reserved. #
# #
##############################################################################
# $Source: parser/examples/test_cxx/config_taxonomy.cpp $ #
# $Author: villek@matrixscience.com $ #
# $Date: 2018-07-30 16:23:53 +0100 $ #
# $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | 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;
int main(int argc, char * argv[])
{
if ( argc < 2 )
{
std::cout << "The location of taxonomy file has to be specified as a parameter" << std::endl;
std::cout << "The location should either be the full path to the taxonomy file" << std::endl;
std::cout << "or a URL to a Mascot server - e.g. http://mascot-server/mascot/cgi" << std::endl;
return 1;
}
// A sessionID can optionally be passed as the second parameter
// This will only be required if the 'file' is a URL
if (argc > 2)
{
cs.setSessionID(argv[2]);
}
ms_taxonomyfile file(argv[1], &cs);
if (!file.isValid())
{
std::cout << "There are errors. Cannot continue. The last error description:" << std::endl;
std::cout << file.getLastErrorString() << std::endl;
return 1;
}
int n = file.getNumberOfEntries();
std::cout << "There are " << n << " taxonomy choice entries configured:" << std::endl;
// now get'em all!
int i = 0;
for(i=0; i < n; i++)
{
std::cout << file.getEntryByNumber(i)->getTitle() << std::endl;
std::cout << "Include: ";
int j;
for(j=0; j < file.getEntryByNumber(i)->getNumberOfIncludeTaxonomies(); j++)
{
if ( j > 0 )
std::cout << ",";
std::cout << file.getEntryByNumber(i)->getIncludeTaxonomy(j);
}
std::cout << std::endl;
std::cout << "Exclude: ";
for(j=0; j < file.getEntryByNumber(i)->getNumberOfExcludeTaxonomies(); j++)
{
if ( j > 0 )
std::cout << ",";
std::cout << file.getEntryByNumber(i)->getExcludeTaxonomy(j);
}
std::cout << std::endl;
}
return 0;
}
/*
will give the output, for instance:
# config_taxonomy ../config/taxonomy
There are 64 taxonomy choice entries configured:
All entries
Include: 1
Exclude: 0
. . Archaea (Archaeobacteria)
Include: 2157
Exclude:
. . Eukaryota (eucaryotes)
Include: 2759
Exclude:
. . . . Alveolata (alveolates)
Include: 33630
Exclude:
. . . . . . Plasmodium falciparum (malaria parasite)
Include: 5833
Exclude:
. . . . . . Other Alveolata
Include: 33630
Exclude: 5833
...
*/
Settings required to make an HTTP connection to a Mascot server.
Definition: ms_connection_settings.hpp:54
void setSessionID(const std::string sessionID)
Sets the Mascot security sessionID to be used for the connection.
Definition: ms_connection_settings.cpp:242
std::string getLastErrorString() const
Return the error description of the last error that occurred.
Definition: ms_errors.cpp:1488
bool isValid() const
Call this function to determine if there have been any errors.
Definition: ms_errors.cpp:1472
int getIncludeTaxonomy(const int n) const
Traverse the included taxonomy IDs.
Definition: ms_taxonomyfile.cpp:107
std::string getTitle() const
Returns the taxonomy choice title.
Definition: ms_taxonomyfile.cpp:91
int getExcludeTaxonomy(const int n) const
Traverse the excluded taxonomy IDs.
Definition: ms_taxonomyfile.cpp:141
Use this class in order to read in a taxonomy file.
Definition: ms_taxonomyfile.hpp:145
int getNumberOfEntries() const
Returns a number of taxonomy choices currently held in memory.
Definition: ms_taxonomyfile.cpp:469
const ms_taxonomychoice * getEntryByNumber(const int index) const
Returns a taxonomy choice entry by its number.
Definition: ms_taxonomyfile.cpp:493