Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
readfile.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<string>
00024 #include<iostream>
00025 #include<fstream>
00026 #include<vector>
00027 #include<map>
00028 #include<sstream>
00029 #include<set>
00030 #include "setTemplates.C"
00031 #include "motifDataset.h"
00032 using namespace std;
00033 
00034 #ifndef READFILE_MOTIFDATASETGREG
00035 #define READFILE_MOTIFDATASETGREG
00036 
00037 class readfile : public motifDataset
00038 {
00039 private:
00040   
00041   string filename;
00042   vector<string> columnToName,rowToName,columnToNameLO;
00043   map<string,int> nameToColumn,nameToRow,nameToColumnLO;
00044   vector<vector<double> > data, dataLO;
00045   vector<vector<bool> > mExists,mExistsLO;
00046   vector<vector<int> > mClassToExperiments;
00047   vector<vector<int> > mExperimentsToClass;
00048   vector<string> classLabels;
00049   string classString;
00050 
00051   void doRead(string infile);
00052   void readClasses();
00053   double atod(string in);
00054 
00055 public:
00056   static const int MISSING_VALUE;
00057 
00058   readfile(set<int>,string,string);
00059   readfile(const readfile& in);
00060 
00069   virtual void readProbeAliases(string aliasFile);
00070 
00081   virtual void readProbeInfo(string infoFile);
00082 
00083 
00084   
00085   void refactor(set<int> leaveOut);
00086 
00090   virtual bool isProbe(string id) const;
00091   
00092   virtual vector<string>* probes();
00093   virtual vector<string>* samples();
00094   virtual double operator()(int,int);
00095   virtual double operator()(string,string);
00096   virtual bool exists(int,int);
00097   virtual bool exists(string,string);
00098   virtual vector<vector<int> >* classToExperiments();
00099   virtual vector<vector<int> >* experimentsToClass();
00100 //  virtual vector<string>* classes() const;                            
00101 
00114   virtual string computeClassNameForSamples(const set< int > &columnSet, double frac = 1) const;
00115 
00118   virtual int computeClassIndexForSamples(const set< int > &columnSet, double frac = 1) const;
00119 
00121   virtual string getClassNameForSample(unsigned int index) const;
00122 
00124   virtual unsigned int getClassIndexForSample(unsigned int index) const;
00125 
00127   virtual string getClassName(unsigned int index) const;
00128 
00130   virtual unsigned int getClassSize(unsigned int index) const;
00131 
00133   virtual unsigned int getNumClasses() const
00134     {
00135       return(classLabels.size());
00136     }
00137         
00138   
00141   virtual int getColumnIndex(string name) const;
00142 
00145   virtual int getRowIndex(string name) const;
00146 
00148   virtual string getRowName(unsigned int index) const;
00149 
00150 
00151 };
00152 
00153 #endif
 All Classes Functions Variables Typedefs Friends