libbbrc
bbrc.h
Go to the documentation of this file.
00001 // bbrc.h
00002 // modified 2010
00003 // (c) 2010 by Andreas Maunz, andreas@maunz.de, feb 2010
00004 
00005 /*
00006     This file is part of LibBbrc (libbbrc).
00007 
00008     LibBbrc is free software: you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation, either version 3 of the License, or
00011     (at your option) any later version.
00012 
00013     LibBbrc is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with LibBbrc.  If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 #ifndef BBRC_H
00023 #define BBRC_H
00024 
00025 #include "../fminer/fminer.h"
00026 #include "misc.h"
00027 #include "closeleg.h"
00028 #include "graphstate.h"
00029 
00030 namespace fm { 
00031 
00032     extern bool bbrc_adjust_ub;
00033     extern bool bbrc_do_pruning;
00034     extern bool bbrc_aromatic;
00035     extern ChisqBbrcConstraint* bbrc_chisq;
00036     extern KSBbrcConstraint* bbrc_ks;
00037     extern bool bbrc_do_yaml;
00038     extern bool bbrc_gsp_out;
00039     extern bool bbrc_bbrc_sep;
00040     extern bool bbrc_regression;
00041     extern bool bbrc_db_built;
00042 
00043 }
00044 
00045 class Bbrc : public Fminer {
00046 
00047   public:
00048 
00053     Bbrc (); 
00054     Bbrc (int _type, unsigned int _minfreq); 
00055     Bbrc (int _type, unsigned int _minfreq, float chisq_val, bool _do_backbone); 
00056 
00057     ~Bbrc();
00058     void Reset(); 
00059     void Defaults(); 
00060 
00061 
00066     int GetMinfreq(); 
00067     int GetType(); 
00068     bool GetBackbone(); 
00069     bool GetDynamicUpperBound(); 
00070     bool GetPruning(); 
00071     bool GetConsoleOut(); 
00072     bool GetAromatic(); 
00073     bool GetRefineSingles(); 
00074     bool GetDoOutput(); 
00075     bool GetBbrcSep(); 
00076     bool GetChisqActive(); 
00077     float GetChisqSig(); 
00078     bool GetRegression(); 
00079 
00080 
00085     void SetMinfreq(int val); 
00086     bool SetType(int val); 
00087     bool SetBackbone(bool val); 
00088     bool SetDynamicUpperBound(bool val); 
00089     bool SetPruning(bool val); 
00090     bool SetConsoleOut(bool val); 
00091     void SetAromatic(bool val); 
00092     bool SetRefineSingles(bool val); 
00093     void SetDoOutput(bool val); 
00094     bool SetBbrcSep(bool val); 
00095     bool SetChisqActive(bool val); 
00096     bool SetChisqSig(float _chisq_val); 
00097     bool SetRegression(bool val); 
00098     bool SetMaxHops(int val); 
00099 
00100 
00104     vector<string>* MineRoot(unsigned int j); 
00105     void ReadGsp(FILE* gsp); 
00106     bool AddCompound(string smiles, unsigned int comp_id); 
00107     // KS: bool AddActivity(bool act, unsigned int comp_id); //!< Add an activity to the database.
00108     // KS: recognize regr field
00109     bool AddActivity(float act, unsigned int comp_id); 
00110     bool AddWeight(float weight, unsigned int comp_id); 
00111     int GetNoRootNodes() {if (!fm::bbrc_db_built) AddDataCanonical() ; return fm::bbrc_database->nodelabels.size();} 
00112     int GetNoCompounds() {if (!fm::bbrc_db_built) AddDataCanonical() ; return fm::bbrc_database->trees.size();} 
00113 
00114     
00115   private:
00116     void AddChiSq(float act){fm::bbrc_chisq->nr_acts[act]++; fm::bbrc_chisq->n++;}
00117     // KS: Insert value into set of activities
00118     void AddKS(float val){fm::bbrc_ks->all.push_back(val);}
00119 
00120     bool init_mining_done;
00121     int comp_runner;
00122     int comp_no;
00123 
00124     vector<string> r;
00125     // ONLY FOR INTERNAL USE. DO NOT MAKE PUBLIC!
00126     map<string, pair<unsigned int, string> > inchi_compound_map;    // AM: structure inchi => (id, smi) for canonical input to check for double structures
00127     map<string, pair<unsigned int, string> > inchi_compound_mmap;   // AM: structure inchi => (id, smi) for canonical input to use for actual storage
00128     map<unsigned int, float> activity_map;                          // AM: structure id => act for canonical input
00129     map<unsigned int, float> weight_map;                            // AM: structure id => weight for canonical input
00130 
00131     bool AddDataCanonical();                                        
00132     bool AddCompoundCanonical(string smiles, unsigned int comp_id); 
00133     bool AddActivityCanonical(float act, unsigned int comp_id);     
00134     bool CheckWeight(float weight, unsigned int comp_id);           
00135     bool NormalizeWeights(map<unsigned int, float> weight_map);     
00136     bool AddWeightCanonical(float weight, unsigned int comp_id);    
00137 
00138 };
00139 
00140 #endif