Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
itemsetEnrichment.h
00001 /**************************************************************************
00002  * Copyright (c) 2005-2011 T. M. Murali                                   *
00003  * Copyright (c) 2008-2011 Naveed Massjouni                               *
00004  * Copyright (c) 2004 Greg Grothaus                                       *
00005  *                                                                        *
00006  * This file is part of Biorithm.                                         *
00007  *                                                                        *
00008  * Biorithm 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  * Biorithm 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 Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00020  *                                                                        *
00021  **************************************************************************/
00022 
00023 #include<set>
00024 #include<string>
00025 #include<iostream>
00026 #include<fstream>
00027 #include<algorithm>
00028 #include<vector>
00029 #include<cmath>
00030 #include<utility>
00031 
00032 #include "motifDataset.h"
00033 #include "setTemplates.C"
00034 #include "readfile.h"
00035 #include "xmotif.h"
00036 #include "motifDataset.h"
00037 #include "enrichment.h"
00038 #include "GO.h"
00039 #include "stlConversions.cpp"
00040 
00041 using namespace std;
00042 
00043 #ifndef ITEMENRICHGREG
00044 #define ITEMENRICHGREG
00045 
00046 struct itemsetEnrichRecord
00047 {
00048         string theClass;
00049         int classID;
00050         double score;
00051         int xMotifID;
00052         string relation;
00053         string reason;
00054         string theCategory;
00055         set<string> annotated;
00056 
00057         bool operator<(const itemsetEnrichRecord& a) const
00058         {
00059                 //sort by score, then by name of function
00060                 if(score!=a.score)
00061                         return score<a.score;
00062                 return relation<a.relation;
00063         }
00064 };
00065 struct itemsetNavRecord
00066 {
00067         int id;
00068         string theClass;
00069         double score;
00070 
00071         bool operator<(const itemsetNavRecord& a) const
00072         {
00073                 //sort first by class, then score
00074                 if(theClass!=a.theClass)
00075                         return theClass<a.theClass;
00076                 return score<a.score;
00077         }
00078 };
00079 struct itemsetGeneRecord
00080 {
00081         string probename;
00082         int probeid;
00083         int green;
00084         bool operator<(const itemsetGeneRecord& a) const
00085         {
00086                 if(green!=a.green)
00087                         return green<a.green;
00088                 return probename<a.probename;
00089         }
00090 };
00091 
00092 class itemsetEnrichment
00093 {
00094 private:
00095   string web;
00096   double myAlpha;
00097   map<string,Enrichment<string,string> > functionClasses;
00098   // list of itemsets in the classifier. i am losing encapsulation
00099   // here. why should itemsetEnrichment know about the classifier, but
00100   // i need this info in the navigation file.
00101   set<itemsetNavRecord> classifierItemsetList;
00102   // list of itemsets not in the classifier.
00103   set<itemsetNavRecord> nonClassifierItemsetList;
00104   GeneOntology *GO;
00105   motifDataset *myDataset;
00106 
00107   
00108   void buildDataFile(int id, const itemset &item, vector<itemsetEnrichRecord> &de);
00109   void buildDataFile();
00110   void buildIndexFile();
00111   void buildNavFile();
00112 
00113 public:
00114   itemsetEnrichment(string annotFile, string gofile,
00115                     string path,motifDataset *m,double alpha);
00116   void processItemset(const itemset &in,int id);
00117 };
00118         
00119 #endif
 All Classes Functions Variables Typedefs Friends