Matrix Science header

ms_taxonomyrules.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_taxonomyrules.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_taxonomyrules.hpp       $ #
00012 #     $Author: francoisr $ #
00013 #       $Date: 2016/05/17 12:49:19 $ #
00014 #   $Revision: 1.19 $ #
00015 # $NoKeywords::                                                            $ #
00016 ##############################################################################
00017 */
00018 
00019 #ifndef MS_TAXONOMYRULES_HPP
00020 #define MS_TAXONOMYRULES_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 {
00057     enum TAX_SPECIES_FORMAT
00058     {
00059         TAX_SPECIES_NCBI,         
00060         TAX_SPECIES_SWISSPROT,    
00061         TAX_SPECIES_PDB,          
00062         TAX_SPECIES_GI2TAXID,     
00063         TAX_SPECIES_ACC2TAXID,    
00064         TAX_SPECIES_EXPLICIT,     
00065         TAX_SPECIES_FORMAT_COUNT        /* Always leave this one last */
00066     };
00067 
00069     class MS_MASCOTRESFILE_API ms_taxspeciesfiles
00070     {
00071         friend class ms_datfile;
00072         friend class ms_taxonomyrules;
00073 
00074     public:
00076         ms_taxspeciesfiles();
00077 
00079         ms_taxspeciesfiles(const ms_taxspeciesfiles& src);
00080 
00082         ~ms_taxspeciesfiles();
00083 
00085         void defaultValues();
00086 
00088         void copyFrom(const ms_taxspeciesfiles* right);
00089 
00090 #ifndef SWIG
00091 
00092         ms_taxspeciesfiles& operator=(const ms_taxspeciesfiles& right);
00093 #endif
00094 
00095         TAX_SPECIES_FORMAT getFormat() const;
00096 
00098         void setFormat(const TAX_SPECIES_FORMAT value);
00099 
00101         std::string getFileName() const;
00102 
00104         void setFileName(const char* name);
00105 
00106     private:
00107         TAX_SPECIES_FORMAT  format_;
00108         std::string         filename_;
00109 
00110         std::string getStringValue() const;
00111     }; // class ms_taxspeciesfiles
00112 
00118     enum TAX_NODE_FORMAT
00119     {
00120         TAX_NODE_NCBI,     
00121         TAX_NODE_GENCODE   
00122     };
00123 
00125 
00127     class MS_MASCOTRESFILE_API ms_taxnodesfiles
00128     {
00129         friend class ms_datfile;
00130         friend class ms_taxonomyrules;
00131     public:
00132 
00134         ms_taxnodesfiles();
00135 
00137         ms_taxnodesfiles(const ms_taxnodesfiles& src);
00138 
00140         ~ms_taxnodesfiles();
00141 
00143         void defaultValues();
00144 
00146         void copyFrom(const ms_taxnodesfiles* right);
00147 
00148 #ifndef SWIG
00149 
00150         ms_taxnodesfiles& operator=(const ms_taxnodesfiles& right);
00151 #endif
00152 
00153         TAX_NODE_FORMAT getFormat() const;
00154 
00156         void setFormat(const TAX_NODE_FORMAT value);
00157 
00159         std::string getFileName() const;
00160 
00162         void setFileName(const char* name);
00163 
00164     private:
00165         TAX_NODE_FORMAT format_;
00166         std::string     filename_;
00167         std::string getStringValue() const;
00168     }; // class ms_taxnodesfiles
00169 
00171     class MS_MASCOTRESFILE_API ms_parserule_plus
00172     {
00173         friend class ms_datfile;
00174         friend class ms_taxonomyrules;
00175 
00176     public:
00178 
00181         enum TAX_CHOP_TYPES
00182         {
00183             TAX_CHOP_PREFIX = 0x0001, 
00184             TAX_CHOP_SUFFIX = 0x0002, 
00185             TAX_CHOP_WORDS  = 0x0004  
00186         };
00187 
00189         typedef unsigned int TAX_CHOP_SRC;
00190 
00192         ms_parserule_plus();
00193 
00195         ms_parserule_plus(const ms_parserule_plus& src);
00196 
00198         ~ms_parserule_plus();
00199 
00201         void defaultValues();
00202 
00204         void copyFrom(const ms_parserule_plus* right);
00205 
00206 #ifndef SWIG
00207 
00208         ms_parserule_plus& operator=(const ms_parserule_plus& right);
00209 #endif
00210 
00211         TAX_SPECIES_FORMAT getFileTypeToSearch() const;
00212 
00214         void setFileTypeToSearch(const TAX_SPECIES_FORMAT value);
00215 
00217         const ms_parserule* getRule() const;
00218 
00220         void setRule(const ms_parserule* src);
00221 
00223         TAX_CHOP_SRC getChopSource() const;
00224 
00226         void setChopSource(const TAX_CHOP_SRC value);
00227 
00229         std::string getNameOfDB() const;
00230 
00232         void setNameOfDB(const char* name);
00233 
00234     private:
00235         TAX_SPECIES_FORMAT  fileTypeToSearch_;
00236         ms_parserule        rule_;
00237         TAX_CHOP_SRC        chopSrc_;
00238         std::string         nameOfDb_;
00239         std::string getStringValue() const;
00240     }; // ms_parserule_plus
00241 
00243 
00265     class MS_MASCOTRESFILE_API ms_taxonomyrules: public ms_customproperty
00266     {
00267         friend class ms_datfile;
00268 
00269     public:
00271         ms_taxonomyrules();
00272 
00274         ms_taxonomyrules(const ms_taxonomyrules& src);
00275 
00277         ~ms_taxonomyrules();
00278 
00280         void defaultValues();
00281 
00283         void copyFrom(const ms_taxonomyrules* right);
00284 
00285 #ifndef SWIG
00286 
00287         ms_taxonomyrules& operator=(const ms_taxonomyrules& right);
00288 #endif
00289 
00290         bool isSectionAvailable() const;
00291 
00293         void setSectionAvailable(const bool value);
00294 
00296         bool isEnabled() const;
00297 
00299         void setEnabled(const bool flag);
00300 
00302         std::string getIdentifier() const;
00303 
00305         void setIdentifier(const char* str);
00306 
00308         int getErrorLevel() const;
00309 
00311         void setErrorLevel(const int value);
00312 
00314         bool isFromRefFile() const;
00315 
00317         void setFromRefFile(const bool flag);
00318 
00320         bool isConcatRefFileLines() const;
00321 
00323         void setConcatRefFileLines(const bool flag);
00324 
00326         char getDescriptionLineSep() const;
00327 
00329         void setDescriptionLineSep(const char value);
00330 
00332         int getNumberOfNoBreakDescLineIf() const;
00333 
00335         std::string getNoBreakDescLineIf(const int index) const;
00336 
00338         void clearNoBreakDescLineIf();
00339 
00341         void appendNoBreakDescLineIf(const char* str);
00342 
00344         int getNumberOfSpeciesFiles() const;
00345 
00347         const ms_taxspeciesfiles * getSpeciesFile(const int index) const;
00348 
00350         void clearSpeciesFiles();
00351 
00353         void appendSpeciesFile(const ms_taxspeciesfiles * item);
00354 
00355         // no longer in use
00356         int getNumberOfStrFiles() const;
00357         // no longer in use
00358         const ms_taxspeciesfiles * getStrFile(const int index) const;
00359         // no longer in use
00360         void clearStrFiles();
00361         // no longer in use
00362         void appendStrFile(const ms_taxspeciesfiles * item);
00363 
00364         // no longer in use
00365         const ms_parserule_plus* getStrRule() const;
00366         // no longer in use
00367         void setStrRule(const ms_parserule_plus* src);
00368 
00370         int getNumberOfNodesFiles() const;
00371 
00373         const ms_taxnodesfiles * getNodesFile(const int index) const;
00374 
00376         void clearNodesFiles();
00377 
00379         void appendNodesFile(const ms_taxnodesfiles * item);
00380 
00382         int getNumberOfGencodeFiles() const;
00383 
00385         const ms_taxnodesfiles * getGencodeFile(const int index) const;
00386 
00388         void clearGencodeFiles();
00389 
00391         void appendGencodeFile(const ms_taxnodesfiles * item);
00392 
00394         const ms_parserule_plus* getDefaultRule() const;
00395 
00397         void setDefaultRule(const ms_parserule_plus* src);
00398 
00400         int getNumberOfPrefixRemoves() const;
00401 
00403         std::string getPrefixRemove(const int index) const;
00404 
00406         void clearPrefixRemoves();
00407 
00409         void appendPrefixRemove(const char * item);
00410 
00412         int getNumberOfSuffixRemoves() const;
00413 
00415         std::string getSuffixRemove(const int index) const;
00416 
00418         void clearSuffixRemoves();
00419 
00421         void appendSuffixRemove(const char * item);
00422 
00424         const ms_parserule* getSrcDatabaseRule() const;
00425 
00427         void setSrcDatabaseRule(const ms_parserule* src);
00428 
00430         int getNumberOfPerDbSrcRules() const;
00431 
00433         const ms_parserule_plus * getPerDbSrcRule(const int index) const;
00434 
00436         void clearPerDbSrcRules();
00437 
00439         void appendPerDbSrcRule(const ms_parserule_plus * item);
00440 
00442         const ms_parserule* getDoThisRuleFirst() const;
00443 
00445         void setDoThisRuleFirst(const ms_parserule* src);
00446 
00448         const ms_parserule* getAccFromSpeciesLine() const;
00449 
00451         void setAccFromSpeciesLine(const ms_parserule* src);
00452 
00454         std::string getQuickRefSearch() const;
00455 
00457         void setQuickRefSearch(const char* str);
00458 
00460         int getDBLevelTaxId() const;
00461 
00463         void setDBLevelTaxId(const int value);
00464 
00466         bool isDBLevelTaxId() const;
00467 
00469         void clearDBLevelTaxId();
00470 
00472         bool isMitochondrialTranslation() const;
00473 
00475         void setMitochondrialTranslation(const bool flag);
00476 
00478         std::string getSpeciesFormatRegex(const TAX_SPECIES_FORMAT format) const;
00479 
00481         void setSpeciesFormatRegex(const TAX_SPECIES_FORMAT format, const std::string regex);
00482 
00483 #ifdef SUPPRESS_MS_CUSTOMPROPERTY_INHERITANCE
00484 #include "suppress_ms_customproperty.hpp"
00485 #endif
00486 
00487     private:
00488         bool                sectionAvailable_;
00489         bool                enabled_;
00490         std::string         identifier_;
00491         int                 errorLevel_;
00492         bool                fromRefFile_;
00493         bool                concatRefFileLines_;
00494         char                descriptionLineSep_;
00495 
00496         std::vector< std::string > noBreakDescLineIf_;
00497         std::vector< ms_taxspeciesfiles* > speciesFiles_;
00498         std::vector< ms_taxspeciesfiles* > strStrFiles_;
00499         std::vector< ms_taxnodesfiles* > nodesFiles_;
00500         std::vector< ms_taxnodesfiles* > gencodeFiles_;
00501         std::vector< ms_parserule_plus* > perDbSrcRules_;
00502         std::vector< std::string > prefixRemoves_;
00503         std::vector< std::string > suffixRemoves_;
00504         std::vector< std::string > speciesFormatRegex_;
00505 
00506         ms_parserule        srcDatabaseRule_;
00507         ms_parserule        doThisRuleFirst_;
00508         ms_parserule        accFromSpeciesLine_;
00509         ms_parserule_plus   defaultRule_;
00510         ms_parserule_plus   strStrRule_;
00511 
00512         std::string         quickRefSearch_;
00513         int                 dbLevelTaxId_;
00514         bool                mitochondrialTranslation_;
00515     }; // class ms_taxonomyrules
00516 
00517     class ms_tinycdb;
00518     class ms_taxonomychoice;
00519 
00521 
00559     class MS_MASCOTRESFILE_API ms_taxonomytree : public ms_errors
00560     {
00561     public:
00563         ms_taxonomytree(const ms_taxonomyrules * taxonomyRules, 
00564                         const char * taxonomyDirectory = "../taxonomy",
00565                         const bool useIndex = true);
00566 
00568         ms_taxonomytree(const ms_taxonomytree & src);
00569         
00571         ~ms_taxonomytree();
00572 
00574         void copyFrom(const ms_taxonomytree * right);
00575 
00576 #ifndef SWIG
00577 
00578         ms_taxonomytree& operator=(const ms_taxonomytree & right);
00579 
00580         struct TAX_TREE_NODE {
00581             int parentId;
00582             int tableId;
00583         };
00584         typedef std::vector<TAX_TREE_NODE> TAX_TREE_NODES;
00585 
00587         TAX_TREE_NODES * getTaxIDArray();
00588 #endif
00589 
00591         bool isSpeciesDescendantOf(const int parentID, const int id) const;
00592 
00594         bool getParent(const int id, int & ttParent, int & ttGenTable) const;
00595 
00597         bool isIncludedIn(const int id, const ms_taxonomychoice * choice) const;
00598 
00599     private:
00600         bool usingCDB_;
00601         std::vector<ms_taxnodesfiles> files_;
00602         TAX_TREE_NODES nodes_;
00603         std::vector<std::string> fileNames_;
00604         std::vector<ms_tinycdb *> cdbFiles_;
00605 
00606         bool readFile(const std::string & filename,
00607                       const bool isMitochondrialTranslation);
00608 
00609     };
00610 
00611  // end of config_group
00613 } // namespace matrix_science
00614 
00615 #endif // MS_TAXONOMYRULES_HPP
00616 
00617 /*------------------------------- End of File -------------------------------*/
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:51