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

Read in the mascot.dat file.

/*
##############################################################################
# file: config_mascotdat.cpp #
# 'msparser' toolkit example code #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998-2005 Matrix Science Limited All Rights Reserved. #
# #
##############################################################################
# $Source: parser/examples/test_cxx/config_mascotdat.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 mascot.dat file has to be specified as a parameter" << std::endl;
std::cout << "The location should either be the full path to the mascot.dat 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_datfile file(argv[1], 0, &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;
}
// retrieving Databases-section content
const ms_databases* dbs = file.getDatabases();
// check if there is 'Databases' section in the file actually
if ( dbs->isSectionAvailable() )
{
int n = dbs->getNumberOfDatabases();
std::cout << "There are " << n << " databases configured:" << std::endl;
int i;
for(i=0; i < n; i++)
{
std::cout << dbs->getDatabase(i)->getName() << " : ";
std::cout << (dbs->getDatabase(i)->isActive() ? "active" : "inactive");
std::cout << std::endl;
}
}
else
{
std::cout << "Databases-section is missing" << std::endl;
}
std::cout << std::endl;
// retrieving Parse-section content
const ms_parseoptions* parseOptions = file.getParseOptions();
// check if there is 'Parse' section in the file actually
if ( parseOptions->isSectionAvailable() )
{
int n = parseOptions->getNumberOfParseRules();
std::cout << "Parse rules configured:" << std::endl;
int i;
for(i=0; i < n; i++)
{
// not all of them can be specified
if ( parseOptions->getParseRule(i)->isAvailable() )
{
std::cout << "Rule_" << i << " : ";
std::cout << parseOptions->getParseRule(i)->getRuleStr();
std::cout << std::endl;
}
}
}
else
{
std::cout << "Parse-section is missing" << std::endl;
}
std::cout << std::endl;
// retrieving WWW-section content
const ms_wwwoptions* wwwOptions = file.getWWWOptions();
// check if there is 'WWW' section in the file actually
if ( wwwOptions->isSectionAvailable() )
{
int n = wwwOptions->getNumberOfEntries();
std::cout << "There are " << n << " sequence report sources configured:" << std::endl;
int i;
for(i=0; i < n; i++)
{
std::cout << wwwOptions->getEntry(i)->getName() << "_";
std::cout << ((wwwOptions->getEntry(i)->getType() == WWW_SEQ) ? "SEQ" : "REP");
std::cout << std::endl;
}
}
else
{
std::cout << "WWW-section is missing" << std::endl;
}
std::cout << std::endl;
// retrieving Taxonomy-sections
std::cout << "Available taxonomy sources:" << std::endl;
int maxtax = file.getMaxTaxonomyRules();
int taxind;
for(taxind = 1; taxind <= maxtax; taxind++)
{
// check whether a certain taxonomy section exists
if ( file.getTaxonomyRules(taxind) != NULL )
{
std::cout << "TAXONOMY_" << taxind;
std::cout << file.getTaxonomyRules(taxind)->getIdentifier();
std::cout << std::endl;
}
}
std::cout << std::endl;
// retrieving Cluster-section content
const ms_clusterparams* clusterParams = file.getClusterParams();
// check if there is 'Cluster' section in the file actually
if ( clusterParams->isSectionAvailable() )
{
std::cout << "Cluster mode : ";
std::cout << (clusterParams->isEnabled() ? "enabled" : "disabled");
std::cout << std::endl;
}
else
{
std::cout << "Cluster-section is missing" << std::endl;
}
std::cout << std::endl;
// retrieving Processor-section content
const ms_processoroptions* procOptions = file.getProcessors();
// check if there is 'Processor' section in the file actually
if ( procOptions->isSectionAvailable() )
{
std::cout << procOptions->getNumberOfProcessors() << " CPU(s) configured";
std::cout << std::endl;
}
else
{
std::cout << "Processor-section is missing" << std::endl;
}
std::cout << std::endl;
// retrieving Options-section content
const ms_mascotoptions* mascotOptions = file.getMascotOptions();
// check if there is 'Options' section in the file actually
if ( mascotOptions->isSectionAvailable() )
{
std::cout << "MascotCmdLine : ";
std::cout << mascotOptions->getMascotCmdLine();
std::cout << std::endl;
}
else
{
std::cout << "Options-section is missing" << std::endl;
}
std::cout << std::endl;
// retrieving Cron-section content
const ms_cronoptions* cronOptions = file.getCronOptions();
// check if there is 'Cron' section in the file actually
if ( cronOptions->isSectionAvailable() )
{
if ( cronOptions->isCronEnabled() )
{
int n = cronOptions->getNumberOfCronJobs();
std::cout << "There are " << n << " cron-jobs configured:" << std::endl;
int i;
for(i=0; i < n; i++)
{
std::cout << cronOptions->getCronJob(i).getCommandStr() << std::endl;
}
}
else
{
std::cout << "Cron functionality is disabled" << std::endl;
}
}
else
{
std::cout << "Cron-section is missing" << std::endl;
}
std::cout << std::endl;
return 0;
}
/*
will give the output:
# test.exe ../config/mascot.dat
There are 4 databases configured:
MSDB : active
NCBInr : active
EST_human : inactive
EST_mouse : inactive
Parse rules configured:
Rule_1 : >owl[^ ]*|\‍([^ ]*\‍)
Rule_2 : >owl[^ ]*|[^ ]*[ ]\‍(.*\‍)
Rule_3 : >[A-Z][1-9];\‍([^ ]*\‍)
Rule_4 : >\‍([^ ]*\‍)
Rule_5 : >[^ ]* \‍(.*\‍)
There are 8 sequence report sources configured:
NCBInr_SEQ
NCBInr_REP
MSDB_SEQ
MSDB_REP
IPI_human_SEQ
IPI_human_REP
IPI_mouse_SEQ
IPI_mouse_REP
Available taxonomy sources:
TAXONOMY_1NCBI nr FASTA
TAXONOMY_2OWL REF
TAXONOMY_3Swiss-prot FASTA
TAXONOMY_4NCBI dbEST FASTA
Cluster mode : disabled
Processor-section is missing
MascotCmdLine : ../cgi/nph-mascot.exe
Cron functionality is disabled
*/
An instance of this class represents all the parameters specified in the Cluster section of mascot....
Definition: ms_clusterparams.hpp:72
bool isEnabled() const
Returns TRUE if Enabled parameter is set to 1 and FALSE otherwise.
Definition: ms_clusterparams.cpp:131
bool isSectionAvailable() const
Check whether the section has been actually read from the file.
Definition: ms_clusterparams.cpp:113
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 getCommandStr() const
Returns a string that is executed by the shell (command prompt) at the specified times.
Definition: ms_cronoptions.cpp:249
Contains parameters from the cron section of mascot.dat.
Definition: ms_cronoptions.hpp:150
bool isCronEnabled() const
Returns true if parameter CronEnabled is set to 1 and false otherwise.
Definition: ms_cronoptions.cpp:452
const ms_cronjob getCronJob(const int idx) const
Returns an object describing a single cron job by its number.
Definition: ms_cronoptions.cpp:495
int getNumberOfCronJobs() const
Returns the total number of cron-jobs configured.
Definition: ms_cronoptions.cpp:475
bool isSectionAvailable() const
Returns TRUE if the section was actually read from a file.
Definition: ms_cronoptions.cpp:431
bool isActive() const
Returns true if the database definition is active and false otherwise.
Definition: ms_databaseoptions.cpp:91
std::string getName() const
Returns the value of Name.
Definition: ms_databaseoptions.cpp:123
An instance of this class represents the Databases section of mascot.dat.
Definition: ms_databaseoptions.hpp:225
const ms_databaseoptions * getDatabase(const int index) const
Returns a database definition by its number.
Definition: ms_databaseoptions.cpp:611
int getNumberOfDatabases() const
Returns the total number of database definitions including inactive (commented out) databases.
Definition: ms_databaseoptions.cpp:600
bool isSectionAvailable() const
Check if the section has been actually read form the file or have to be saved.
Definition: ms_databaseoptions.cpp:585
Encapsulates the mascot.dat file that contains the most important parameters.
Definition: ms_datfile.hpp:47
const ms_processoroptions * getProcessors() const
Returns an instance of the class representing the Processors section.
Definition: ms_datfile.cpp:2219
const ms_cronoptions * getCronOptions() const
Returns an instance of the class representing the Cron section.
Definition: ms_datfile.cpp:2256
const ms_parseoptions * getParseOptions() const
Returns an instance of the class representing the PARSE section.
Definition: ms_datfile.cpp:2145
const ms_mascotoptions * getMascotOptions() const
Returns an instance of the class representing the Options section.
Definition: ms_datfile.cpp:2071
const ms_taxonomyrules * getTaxonomyRules(const int idx) const
Returns an instance of the class representing one of the Taxonomy_XXX sections.
Definition: ms_datfile.cpp:2376
const ms_databases * getDatabases() const
Returns an instance of the class representing the Databases section.
Definition: ms_datfile.cpp:2016
const ms_clusterparams * getClusterParams() const
Returns an instance of the class representing the Cluster section.
Definition: ms_datfile.cpp:2293
const ms_wwwoptions * getWWWOptions() const
Returns an instance of the class representing the WWW section.
Definition: ms_datfile.cpp:2182
int getMaxTaxonomyRules() const
Returns a maximum possible Taxonomy section number that can be used to retrieve/set the section conte...
Definition: ms_datfile.cpp:2421
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
An instance of this class represents all the parameters specified in the Options section of mascot....
Definition: ms_mascotoptions.hpp:91
std::string getMascotCmdLine() const
Returns the value of MascotCmdLine.
Definition: ms_mascotoptions.cpp:872
bool isSectionAvailable() const
Indicates whether the section has been actually read from the file.
Definition: ms_mascotoptions.cpp:569
Represents the PARSE section of mascot.dat.
Definition: ms_parserule.hpp:102
int getNumberOfParseRules() const
Can be used to get upper limit for a parse rule number.
Definition: ms_parserule.cpp:289
const ms_parserule * getParseRule(const int index) const
Returns a parse rule by number.
Definition: ms_parserule.cpp:252
bool isSectionAvailable() const
Check whether the section has been actually read from the file.
Definition: ms_parserule.cpp:232
bool isAvailable() const
Call this member to check if this rule has been specified in the file or just a placeholder.
Definition: ms_parserule.cpp:89
std::string getRuleStr() const
Returns a string representing the rule.
Definition: ms_parserule.cpp:103
An instance of this class represents all the parameters specified in the Processors section of mascot...
Definition: ms_processoroptions.hpp:109
int getNumberOfProcessors() const
Returns a number of processors specified in the ProcessorSet parameter.
Definition: ms_processoroptions.cpp:190
bool isSectionAvailable() const
Check whether the section has been actually read from the file.
Definition: ms_processoroptions.cpp:161
std::string getIdentifier() const
Returns the value of Identifier.
Definition: ms_taxonomyrules.cpp:537
WWW_TYPE getType() const
Returns the name of the database the entry refers to.
Definition: ms_wwwoptions.cpp:90
std::string getName() const
Returns the name of the database the entry refers to.
Definition: ms_wwwoptions.cpp:69
Represents the whole WWW section.
Definition: ms_wwwoptions.hpp:157
int getNumberOfEntries() const
Returns the total number of entries in the section.
Definition: ms_wwwoptions.cpp:314
const ms_wwwentry * getEntry(const int index) const
Returns an entry by its index.
Definition: ms_wwwoptions.cpp:325
bool isSectionAvailable() const
Check whether the section has been actually read from the file.
Definition: ms_wwwoptions.cpp:294