liblast
last.h
Go to the documentation of this file.
00001 // last.h
00002 // modified 2010
00003 // (c) 2010 by Andreas Maunz, andreas@maunz.de, feb 2010
00004 
00005 /*
00006     This file is part of LibLast (liblast).
00007 
00008     LibLast 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     LibLast 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 LibLast.  If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 #ifndef LAST_H
00023 #define LAST_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 last_do_pruning;
00033     extern bool last_aromatic;
00034     extern ChisqLastConstraint* last_chisq;
00035     extern KSLastConstraint* last_ks;
00036     extern bool last_gsp_out;
00037     extern bool last_bbrc_sep;
00038     extern bool last_regression;
00039     extern int last_max_hops;
00040     extern bool last_db_built;
00041 
00042 }
00043 
00044 class Last : public Fminer {
00045 
00046   public:
00047 
00052     Last (); 
00053     /*
00054     Last (int _type, unsigned int _minfreq); //!< Like standard constructor, but type and minimum frequency configurable.
00055     Last (int _type, unsigned int _minfreq, float chisq_val, bool _do_backbone); //!< Like standard constructor, but type, minimum frequency, significance Lastlevel and BBRC configurable.
00056     */
00057     ~Last();
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     int GetMaxHops(); 
00080 
00082 
00087     void SetMinfreq(int val); 
00088     bool SetType(int val); 
00089     bool SetBackbone(bool val); 
00090     bool SetDynamicUpperBound(bool val); 
00091     bool SetPruning(bool val); 
00092     bool SetConsoleOut(bool val); 
00093     void SetAromatic(bool val); 
00094     bool SetRefineSingles(bool val); 
00095     void SetDoOutput(bool val); 
00096     bool SetBbrcSep(bool val); 
00097     bool SetChisqActive(bool val); 
00098     bool SetChisqSig(float _chisq_val); 
00099     bool SetRegression(bool val); 
00100     bool SetMaxHops(int val); 
00101 
00102     
00107     vector<string>* MineRoot(unsigned int j); 
00108     void ReadGsp(FILE* gsp); 
00109     bool AddCompound(string smiles, unsigned int comp_id); 
00110     bool AddActivity(float act, unsigned int comp_id); 
00111     int GetNoRootNodes() {if (!fm::last_db_built) AddDataCanonical() ; return fm::last_database->nodelabels.size();} 
00112     int GetNoCompounds() {if (!fm::last_db_built) AddDataCanonical() ; return fm::last_database->trees.size();} 
00113     float ChisqTest(vector<float> all, vector<float> feat);
00114     float KSTest(vector<float> all, vector<float> feat) {return fm::last_ks->KSTest(all, feat);} 
00115 
00116     
00117   private:
00118     void AddChiSq(float act){fm::last_chisq->nr_acts[act]++; fm::last_chisq->n++;}
00119     // KS: Insert value into set of activities
00120     void AddKS(float val){fm::last_ks->all.push_back(val);}
00121 
00122     bool init_mining_done;
00123     int comp_runner;
00124     int comp_no;
00125 
00126     vector<string> r;
00127     // ONLY FOR INTERNAL USE. DO NOT MAKE PUBLIC!
00128     map<string, pair<unsigned int, string> > inchi_compound_map;    // AM: structure inchi => (id, smi) for canonical input to check for double structures
00129     map<string, pair<unsigned int, string> > inchi_compound_mmap;   // AM: structure inchi => (id, smi) for canonical input to use for actual storage
00130     map<unsigned int, float> activity_map;                          // AM: structure inchi => (id, smi) for canonical input
00131     bool AddDataCanonical();                                        
00132     bool AddCompoundCanonical(string smiles, unsigned int comp_id); 
00133     bool AddActivityCanonical(float act, unsigned int comp_id);     
00134 
00135 };
00136 
00137 #endif