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 int _superscriptColumnIndex;
00126 int _consultandColumnIndex;
00127 int _carrierColumnIndex;
00128 int _relationshipEndedColumnIndex;
00129 int _infertilityColumnIndex;
00130 int _sterilityColumnIndex;
00131
00132
00133
00134
00135 void _setDeclaredTypesFromParser(const std::vector<char> *pDeclaredTypes);
00136 void _determineTableType(const std::vector<std::string> *pTitles);
00137 void _classifyRemainingColumns(const std::vector<std::string> *pElements, const std::vector<std::string> *pTitles);
00138 void _setColorSeriesStack(void);
00139
00140
00141 public:
00142
00143 static FieldLabels labels;
00144
00145
00146
00147 DataTable(TableParser &parser);
00148
00149
00150
00151
00152 ~DataTable();
00153
00154
00155
00156
00157 void addColumn( DataColumn *column);
00158
00159
00160
00161
00162 unsigned getColumnOrdinal ( const char *name ) const;
00163
00164
00165
00166
00167 std::string getColumnName ( unsigned ordinal ) const;
00168
00169
00170
00171
00172 unsigned getNumberOfColumns( void ) const;
00173
00174
00175
00176
00177
00178 DataColumn* getColumn( unsigned ordinal ) const;
00179
00180
00181
00182
00183 DataColumn* getColumn(const std::string &name ) const;
00184
00185 void deleteFrontColumn();
00186 void display();
00187 void printInputTableAsTabDelimited(std::string filename) const;
00188 void printPedigreeTableAsTabDelimited(std::string filename) const;
00189
00190
00191 const TableType getTableType( void ) const { return _tabletype; };
00192 std::string getTableTypeAsString(void) const;
00193
00194
00195 const unsigned getNumberOfRows( void ) const { return _rows; };
00196
00197
00198 bool columnExists(const std::string &name) const;
00199
00200
00201 void toggleColumnsForPedigree(const std::vector<std::string> &columns);
00202 unsigned getNumberOfShowOnPedigreeColumns() const;
00203 Data* getDataAtIndex(const std::string name, unsigned long index) const;
00204 Data* getDataAtIndex(unsigned columnIndex, unsigned long index) const;
00205
00206
00207
00208 inline int getAffectedColumnIndex(void) const { return _affectedColumnIndex; }
00209 inline int getDeceasedColumnIndex(void) const { return _deceasedColumnIndex; }
00210 inline int getDOBColumnIndex(void) const { return _dobColumnIndex; }
00211 inline int getDZTwinColumnIndex(void) const { return _dzTwinColumnIndex; }
00212 inline int getMZTwinColumnIndex(void) const { return _mzTwinColumnIndex; }
00213 inline int getProbandColumnIndex(void) const { return _probandColumnIndex; }
00214 inline int getSampledColumnIndex(void) const { return _sampledColumnIndex; }
00215 inline int getSuperscriptColumnIndex(void) const { return _superscriptColumnIndex; }
00216 inline int getConsultandColumnIndex(void) const { return _consultandColumnIndex; }
00217 inline int getCarrierColumnIndex(void) const { return _carrierColumnIndex; }
00218 inline int getRelationshipEndedColumnIndex(void) const { return _relationshipEndedColumnIndex; }
00219 inline int getInfertilityColumnIndex(void) const { return _infertilityColumnIndex; }
00220 inline int getSterilityColumnIndex(void) const { return _sterilityColumnIndex; }
00221
00222
00223
00224
00225 unsigned getIconColumnCount(void) const;
00226
00227
00228
00229 unsigned getIconColumnIndex(unsigned nth) const;
00230
00231
00232
00233 unsigned getLabelColumnIndex(unsigned nth) const;
00234
00235 const std::vector<unsigned> * getIconColumnVector(void) const;
00236 const std::vector<unsigned> * getLabelColumnVector(void) const;
00237
00238 ColorSeriesStack *getColorSeriesStack(void) const;
00239 ColorSeries *getColorSeriesFromStack(unsigned nth) const;
00240 ColorSeries *getBlackAndWhiteSeriesFromStack(unsigned nth) const;
00241
00242 };
00243
00244 #endif