Matrix Science header

ms_datfile.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_datfile.hpp                                                       #
00004 # 'msparser' toolkit                                                         #
00005 # Encapsulates "mascot.dat"-file that describes most important parameters    #
00006 ##############################################################################
00007 # COPYRIGHT NOTICE                                                           #
00008 # Copyright 1998-2003 Matrix Science Limited  All Rights Reserved.           #
00009 #                                                                            #
00010 ##############################################################################
00011 #    $Archive:: /Mowse/ms_mascotresfile/include/ms_datfile.hpp             $ #
00012 #     $Author: davidc $ #
00013 #       $Date: 2017/05/17 15:16:24 $ #
00014 #   $Revision: 1.38 $ #
00015 # $NoKeywords::                                                            $ #
00016 ##############################################################################
00017 */
00018 
00019 #ifndef MS_DATFILE_HPP
00020 #define MS_DATFILE_HPP
00021 
00022 #ifdef _WIN32
00023 #pragma warning(disable:4251)   // Don't want all classes to be exported
00024 #pragma warning(disable:4786)   // Debug symbols too long
00025 #   ifndef _MATRIX_USE_STATIC_LIB
00026 #       ifdef MS_MASCOTRESFILE_EXPORTS
00027 #           define MS_MASCOTRESFILE_API __declspec(dllexport)
00028 #       else
00029 #           define MS_MASCOTRESFILE_API __declspec(dllimport)
00030 #       endif
00031 #   else
00032 #       define MS_MASCOTRESFILE_API
00033 #   endif
00034 #else
00035 #   define MS_MASCOTRESFILE_API
00036 #endif
00037 
00038 // for the sake of #include <string>
00039 #ifdef __ALPHA_UNIX__
00040 #include <ctype.h>
00041 #endif
00042 #include <string>
00043 #include <vector>
00044 
00045 
00046 namespace matrix_science {
00047 
00048     class ms_filesource;
00049 
00055 
00056 
00065     class MS_MASCOTRESFILE_API ms_datfile : public ms_errors
00066     {
00067     public:
00068 
00070 
00073         enum WST
00074         {
00075             WST_APACHE=0, 
00076             WST_IIS=1     
00077         };
00078 
00080 
00085         enum SEQDB_INSTALL
00086         {
00087             // Anything in the lower 16 bits (1..16) should result in asking the user to confirm that they want to update
00088             SEQDB_INSTALL_SHOULD_QUERY_USER = 0x0000FFFF, 
00089             SEQDB_INSTALL_CUSTOMISED        = 0x00000001, 
00090             SEQDB_INSTALL_INACTIVE          = 0x00000002, 
00091             SEQDB_INSTALL_INVALID_CONFIG    = 0x00000004, 
00092             SEQDB_INSTALL_EXISTING_LARGER   = 0x00000010, 
00093 
00094             // Bit 32 for something really bad.
00095             SEQDB_INSTALL_INVALID_DBNAME    = 0x00000000, 
00096 
00097             // Further information that may be useful in bits 16 to 31 
00098             SEQDB_INSTALL_MUST_UPDATE_CFG   = 0x000F000F, 
00099             SEQDB_INSTALL_MISSING_CONFIG    = 0x00010000, 
00100             SEQDB_INSTALL_OLD_RULES         = 0x00020000, 
00101             SEQDB_INSTALL_WRONG_WILDCARD    = 0x00040000, 
00102 
00103             // Additional information, but no need to update 
00104             SEQDB_INSTALL_CURRENT_RULES     = 0x01000000  
00105         };
00106 
00108 
00111         enum INST_FLAGS
00112         {
00113             IFLG_UPDATETAXONOMY          = 0x00000001,   
00114             IFLG_UPDATEPARSERULES        = 0x00000002,   
00115             IFLG_UPDATESWISSPROT         = 0x00000004,   
00116             IFLG_UPDATECLUSTER           = 0x00000008,   
00117             IFLG_UPDATEESTTAX            = 0x00000010,   
00118             IFLG_ADDMISSINGOPTIONS       = 0x00000020,   
00119             IFLG_ADDREPORTAUTO           = 0x00000040,   
00120             IFLG_UPDATEAPACHEFORKOPT     = 0x00000080,   
00121             IFLG_ADDPERCOLATOROPT        = 0x00000100,   
00122             IFLG_UPDATENCBIHTTPS         = 0x00000200,   
00123             IFLG_UPDATEPRIDECONTAMINANTS = 0x00000400,   
00124             IFLG_UPDATEDBMANAGERPERLPATH = 0x00000800,   
00125             IFLG_UPDATEMSPEPSEARCHOPTS   = 0x00001000,   
00126 
00127 
00128             IFLG_DEFAULTNEWINSTALL   = IFLG_UPDATECLUSTER       |
00129                                        IFLG_UPDATEAPACHEFORKOPT, 
00130             IFLG_DEFAULTUPGRADE      = IFLG_UPDATETAXONOMY      |
00131                                        IFLG_UPDATEPARSERULES    |
00132                                        IFLG_UPDATEESTTAX        |
00133                                        IFLG_ADDMISSINGOPTIONS   |
00134                                        IFLG_ADDREPORTAUTO       |
00135                                        IFLG_UPDATEAPACHEFORKOPT |
00136                                        IFLG_ADDPERCOLATOROPT    |
00137                                        IFLG_UPDATENCBIHTTPS     |
00138                                        IFLG_UPDATEDBMANAGERPERLPATH | 
00139                                        IFLG_UPDATEMSPEPSEARCHOPTS  
00140         };
00141 
00143         ms_datfile();
00144 
00146         ms_datfile(const ms_datfile& src);
00147 
00149         ms_datfile(const char* filename, const int timeoutSec = 0,
00150                    const matrix_science::ms_connection_settings * cs = 0);
00151 
00153         ~ms_datfile();
00154 
00156         void defaultValues();
00157 
00159         void copyFrom(const ms_datfile* right);
00160 
00161 #ifndef SWIG
00162 
00163         ms_datfile& operator=(const ms_datfile& right);
00164 #endif
00165 
00166         std::string getFileName() const;
00167 
00169         void setFileName(const char* name);
00170 
00172         void setConnectionSettings(const matrix_science::ms_connection_settings & cs);
00173 
00175         matrix_science::ms_connection_settings getConnectionSettings() const;
00176 
00178         void read_file();
00179 
00180         void read_buffer(const char * buffer);
00181 
00183         void save_file();
00184 
00186         bool editedByDatabaseManager() const;
00187 
00189         const ms_databases* getDatabases() const;
00190 
00192         void setDatabases(const ms_databases* dbs);
00193 
00195         const ms_libraryoptions* getLibraryOptions() const;
00196 
00198         void setLibraryOptions(const ms_libraryoptions* spectralLibraryOptions);
00199 
00201         const ms_parseoptions* getParseOptions() const;
00202 
00204         void setParseOptions(const ms_parseoptions* rules);
00205 
00207         const ms_wwwoptions* getWWWOptions() const;
00208 
00210         void setWWWOptions(const ms_wwwoptions* www);
00211 
00213         const ms_processoroptions* getProcessors() const;
00214 
00216         void setProcessors(const ms_processoroptions* info);
00217 
00219         const ms_taxonomyrules* getTaxonomyRules(const int idx) const;
00220 
00222         void setTaxonomyRules(const int idx, const ms_taxonomyrules* rules);
00223 
00225         int getMaxTaxonomyRules() const;
00226 
00228         const ms_clusterparams* getClusterParams() const;
00229 
00231         void setClusterParams(const ms_clusterparams* params);
00232 
00234         const ms_unigeneoptions* getUniGeneOptions() const;
00235 
00237         void setUniGeneOptions(const ms_unigeneoptions * uoptions);
00238 
00240         const ms_mascotoptions* getMascotOptions() const;
00241 
00243         void setMascotOptions(const ms_mascotoptions* opt);
00244 
00246         const ms_cronoptions* getCronOptions() const;
00247 
00249         void setCronOptions(const ms_cronoptions* options);
00250 
00252         const ms_mascotfiles* getMascotFiles() const;
00253 
00255         void setMascotFiles(const ms_mascotfiles* src);
00256 
00258         void setFindFileTimeout(const int seconds);
00259 
00261         int getFindFileTimeout() const;
00262 
00264         unsigned int checkSeqDBInstallRequest(const std::string & dbName,
00265                                               const double newFastaSize) const;
00266 
00268         bool updateForInstaller(ms_errs    & log,
00269                                 const char         * not_mascot_dat_path, 
00270                                 const char         * mascot_dat_path,
00271                                 const char         * licenseFilePath,
00272                                 const char         * pathToMascot,
00273                                 const char         * mascotURL,
00274                                 const char         * sequenceDatabases,
00275                                 const bool           clusterEnable,
00276                                 const WST            wst,
00277                                 const char         * NTGuestName,
00278                                 const char         * NTAdminName,
00279                                 const unsigned int   flags);
00280 
00282         std::string getHeaderComments() const;
00283 
00285         void setHeaderComments(const std::string headerComments);
00286 
00287     private:
00288         std::string         filename_;
00289 
00290         int                 findFileTimeout_;
00291 
00292         ms_databases        Databases;
00293 
00294         ms_libraryoptions   libraryOptions;
00295 
00296         ms_parseoptions     parseOptions;
00297 
00298         ms_wwwoptions       wwwOptions;
00299 
00300         ms_processoroptions Processors;
00301 
00302         ms_taxonomyrules    **taxonomyRules;
00303 
00304         ms_clusterparams    clusterParams;
00305 
00306         ms_unigeneoptions   unigeneOptions;
00307 
00308         ms_mascotoptions    Options;
00309 
00310         ms_cronoptions      cronOptions;
00311 
00312         ms_mascotfiles      MascotFiles;
00313 
00314         std::string         headerComments_;
00315         std::string         footerComments_;
00316 
00317         ms_connection_settings  cs_;
00318 
00319     private:
00320         void defaultFileName();
00321 
00322         void defaultTaxonomyRules();
00323         void copyTaxonomyRules(const ms_datfile* right);
00324 
00325         void get_db_info(ms_filesource *f);
00326         void save_db_info(void *f);
00327 
00328         void get_library_options(ms_filesource *f, const std::string & preceedingComments);
00329         void save_library_options(void *f);
00330 
00331         void get_parse_rules(ms_filesource *f, const std::string & preceedingComments);
00332         void save_parse_rules(void *f);
00333 
00334         void get_www(ms_filesource *f, const std::string & preceedingComments);
00335         void save_www(void *f);
00336 
00337         void get_taxonomy_rules(ms_filesource *f, const char * sectionTitle, const std::string & preceedingComments);
00338         void save_taxonomy(void *f, const int index);
00339 
00340         void get_cluster_params(ms_filesource *f, const std::string & preceedingComments);
00341         void save_cluster_params(void *f);
00342 
00343         void get_unigene_options(ms_filesource *f, const std::string & preceedingComments);
00344         void save_unigene_options(void *f);
00345 
00346         void get_processors(ms_filesource *f, const std::string & preceedingComments);
00347         void save_processors(void *f);
00348 
00349         void get_options(ms_filesource *f, const std::string & preceedingComments);
00350         void save_options(void *f);
00351 
00352         void get_cron_job_list(ms_filesource *f, const std::string & preceedingComments);
00353         void save_cron_job_list(void *f);
00354 
00355         bool get_parse_rule_plus(const char *lineForError, char *pSrc, ms_parserule_plus *pRulePlus);
00356         void setIamParameter();
00357         void checkAndCompileParseRules();
00358         bool parseStringIntoCron(const char *szBuf, ms_cronjob & cron);
00359 
00360         int parseIntoArray(const char * szBufCopy, 
00361                            bool * array, 
00362                            int minVal, 
00363                            int maxVal, 
00364                            int starMeans, 
00365                            const char * wholeLine);
00366 
00367         bool skipToEndOfSection(ms_filesource *f);
00368         bool getStringExcludingQuotes(const char *line, char *pDst);
00369         void readToEndOfLine(const char * pSrc, char * pDst, int maximumLength);
00370         void replaceHashes(matrix_science::ms_customproperty & section,
00371                            const std::string & localPath,
00372                            const std::string & hostname,
00373                            const std::string & url);
00374 
00375         void read_filesource(ms_filesource & fsource);
00376         bool updateForInstallerDatabase(ms_errs               & log, 
00377                                         const std::string     & dbName, 
00378                                         const std::string     & defaultWildcard, 
00379                                         ms_databases          & dbs, 
00380                                         const ms_databases    * not_dbs,
00381                                         ms_parseoptions       & thisParse,
00382                                         const ms_parseoptions * notMascotDatParse);
00383     }; // class ms_datfile // end of config_group
00385 } // namespace matrix_science
00386 
00387 #endif // MS_DATFILE_HPP
00388 
00389 /*------------------------------- End of File -------------------------------*/
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:50