00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00023
00024
00025
00026
00027 #ifndef DATATABLE_INCLUDED
00028 #define DATATABLE_INCLUDED
00029
00030 #include "FileTypeClassifier.h"
00031 #include "DataColumn.h"
00032
00033 #include "TableParser.h"
00034
00035 #include "FieldLabels.h"
00036
00037 #include "ColorSeriesStack.h"
00038
00039 #include <set>
00040 #include <string>
00041 #include <vector>
00042
00059 class DataTable {
00060
00061 public:
00062
00063 enum TableType { PEDIGREE, GENETICMAP, DECOMPOSED, RESULTS, ALLELEFREQUENCY, UNKNOWNTABLETYPE };
00064 static const int COLUMN_IS_MISSING = -1;
00065
00066 private:
00067
00068
00069 struct ltstr
00070 {
00071 bool operator()(DataColumn *c1, DataColumn *c2) const
00072 {
00073
00074
00075
00076 return c1->getCaseInvariantName() < c2->getCaseInvariantName();
00077 }
00078 };
00079
00080 TableType _tabletype;
00081
00082
00083 FileTypeClassifier _fileTypeClassifier;
00084 FileTypeClassifier::FILE_TYPE _fileType;
00085 const char* _fileTypeName;
00086
00087
00088
00089 std::set<DataColumn *,ltstr> _columnSet;
00090
00091
00092 std::vector< std::set<DataColumn *,ltstr>::iterator > _columnVector;
00093
00094
00095
00096
00097
00098 std::vector<DATATYPE> _finalTypes;
00099
00100
00101
00102
00103 unsigned long _rows;
00104 unsigned _columns;
00105
00106
00107
00108
00109 std::vector<unsigned> _iconColumns;
00110 std::vector<unsigned> _labelColumns;
00111
00112 ColorSeriesStack *_colorSeriesStack;
00113 ColorSeriesStack *_blackAndWhiteSeriesStack;
00114
00115
00116
00117
00118 int _affectedColumnIndex;
00119 int _deceasedColumnIndex;
00120 int _dobColumnIndex;
00121 int _dzTwinColumnIndex;
00122 int _mzTwinColumnIndex;
00123 int _probandColumnIndex;
00124 int _sampledColumnIndex;
00125
00126
00127
00128
00129 void _setDeclaredTypesFromParser(const std::vector<char> *pDeclaredTypes);
00130 void _determineTableType(const std::vector<std::string> *pTitles);
00131 void _classifyRemainingColumns(const std::vector<std::string> *pElements, const std::vector<std::string> *pTitles);
00132 void _setColorSeriesStack(void);
00133
00134
00135 public:
00136
00137 static FieldLabels labels;
00138
00139
00140
00141 DataTable(TableParser &parser);
00142
00143
00144
00145
00146 ~DataTable();
00147
00148
00149
00150
00151 void addColumn( DataColumn *column);
00152
00153
00154
00155
00156 unsigned getColumnOrdinal ( const char *name ) const;
00157
00158
00159
00160
00161 std::string getColumnName ( unsigned ordinal ) const;
00162
00163
00164
00165
00166 unsigned getNumberOfColumns( void ) const;
00167
00168
00169
00170
00171
00172 DataColumn* getColumn( unsigned ordinal ) const;
00173
00174
00175
00176
00177 DataColumn* getColumn(const std::string &name ) const;
00178
00179 void deleteFrontColumn();
00180 void display();
00181
00182
00183 const TableType getTableType( void ) const { return _tabletype; };
00184 std::string getTableTypeAsString(void) const;
00185
00186
00187 const unsigned getNumberOfRows( void ) const { return _rows; };
00188
00189
00190 bool columnExists(const std::string &name) const;
00191
00192
00193 void toggleColumnsForPedigree(const std::vector<std::string> &columns);
00194 unsigned getNumberOfShowOnPedigreeColumns() const;
00195 Data* getDataAtIndex(const std::string name, unsigned long index) const;
00196 Data* getDataAtIndex(unsigned columnIndex, unsigned long index) const;
00197
00198
00199
00200 inline int getAffectedColumnIndex(void) const { return _affectedColumnIndex; }
00201 inline int getDeceasedColumnIndex(void) const { return _deceasedColumnIndex; }
00202 inline int getDOBColumnIndex(void) const { return _dobColumnIndex; }
00203 inline int getDZTwinColumnIndex(void) const { return _dzTwinColumnIndex; }
00204 inline int getMZTwinColumnIndex(void) const { return _mzTwinColumnIndex; }
00205 inline int getProbandColumnIndex(void) const { return _probandColumnIndex; }
00206 inline int getSampledColumnIndex(void) const { return _sampledColumnIndex; }
00207
00208
00209
00210
00211 unsigned getIconColumnCount(void) const;
00212
00213
00214
00215 unsigned getIconColumnIndex(unsigned nth) const;
00216
00217
00218
00219 unsigned getLabelColumnIndex(unsigned nth) const;
00220
00221 const std::vector<unsigned> * getIconColumnVector(void) const;
00222 const std::vector<unsigned> * getLabelColumnVector(void) const;
00223
00224 ColorSeriesStack *getColorSeriesStack(void) const;
00225 ColorSeries *getColorSeriesFromStack(unsigned nth) const;
00226 ColorSeries *getBlackAndWhiteSeriesFromStack(unsigned nth) const;
00227
00228 };
00229
00230 #endif