Matrix Science header

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_2_8_1-0-gea32989045 $                                                         #
# $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
    ms_connection_settings cs;
    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

*/

Copyright © 2022 Matrix Science Ltd.  All Rights Reserved. Generated on Thu Mar 31 2022 01:12:29