| 1 | |
|---|
| 2 | /* Conventions: All firstXxxx functions may return NULL, if no elements is available |
|---|
| 3 | * all nextXxxxx functions return NULL, if no more elements are available |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | const int maxErrorStringLength = 4000; |
|---|
| 7 | typedef int Boolean; |
|---|
| 8 | class SeerInterfaceData; |
|---|
| 9 | typedef struct gbs_hash_struct GB_HASH; |
|---|
| 10 | typedef struct gb_data_base_type GBDATA; |
|---|
| 11 | |
|---|
| 12 | int aw_message( const char *msg, char *buttons ); |
|---|
| 13 | void aw_message(const char *msg); |
|---|
| 14 | |
|---|
| 15 | /* ******************** Show a slider *********************************/ |
|---|
| 16 | void aw_openstatus( const char *title ); // show status |
|---|
| 17 | void aw_closestatus( void ); // hide status |
|---|
| 18 | |
|---|
| 19 | int aw_status( const char *text ); // return 1 if exit button is pressed + set statustext |
|---|
| 20 | int aw_status( double gauge ); // return 1 if exit button is pressed + set statusslider |
|---|
| 21 | int aw_status( void ); // return 1 if exit button is pressed |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | enum SeerInterfaceErrorType { |
|---|
| 26 | SIET_QUALITY_ERROR, |
|---|
| 27 | SIET_DATA_FORMAT_ERROR, |
|---|
| 28 | SIET_OBJECT_STORE_ERROR |
|---|
| 29 | }; |
|---|
| 30 | |
|---|
| 31 | enum SeerInterfaceOutputFormat { |
|---|
| 32 | SIOF_ASCII_FORMAT, |
|---|
| 33 | SIOF_HTML_FORMAT, |
|---|
| 34 | SIOF_READABLE_FORMAT |
|---|
| 35 | }; |
|---|
| 36 | |
|---|
| 37 | enum SeerInterfaceDataType { |
|---|
| 38 | SIDT_STRING, |
|---|
| 39 | SIDT_LINK, |
|---|
| 40 | SIDT_SET |
|---|
| 41 | }; |
|---|
| 42 | |
|---|
| 43 | enum SeerExportQualityLevel { |
|---|
| 44 | SQEX_TEMPORARY, |
|---|
| 45 | SQEX_MACHINE_GENERATED, |
|---|
| 46 | SQEX_HAND_EDITED, |
|---|
| 47 | SQEX_DOUBLE_CHECKED |
|---|
| 48 | }; |
|---|
| 49 | |
|---|
| 50 | enum SeerImportQualityLevel { |
|---|
| 51 | SQIM_MASKED_OUT, |
|---|
| 52 | SQIM_UNMODIFIED, |
|---|
| 53 | SQIM_TEMPORARY, |
|---|
| 54 | SQIM_MACHINE_GENERATED, |
|---|
| 55 | SQIM_HAND_EDITED, |
|---|
| 56 | SQIM_DOUBLE_CHECKED |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| 59 | enum SeerInterfaceSequenceDataType { |
|---|
| 60 | SISDT_REAL_SEQUENCE, |
|---|
| 61 | SISDT_CONSENSUS, // can be used as filter ... |
|---|
| 62 | SISDT_FILTER, // 0100101010001 string |
|---|
| 63 | SISDT_RATES, |
|---|
| 64 | SISDT_ETC |
|---|
| 65 | }; |
|---|
| 66 | |
|---|
| 67 | enum SeerInterfaceAttributeType { |
|---|
| 68 | SIAT_STRING, |
|---|
| 69 | SIAT_LINK |
|---|
| 70 | // SIAT_INTEGER_ARRAY, |
|---|
| 71 | // SIAT_FLOAT_ARRAY |
|---|
| 72 | }; |
|---|
| 73 | |
|---|
| 74 | enum SeerInterfaceAlignmentType { |
|---|
| 75 | SIAT_DNA, |
|---|
| 76 | SIAT_RNA, |
|---|
| 77 | SIAT_PRO |
|---|
| 78 | }; |
|---|
| 79 | |
|---|
| 80 | class SeerInterfaceError { |
|---|
| 81 | public: |
|---|
| 82 | enum SeerInterfaceErrorType errorType; |
|---|
| 83 | char *errorString; |
|---|
| 84 | SeerInterfaceData *errorSource; // the [optional] reason for the error, |
|---|
| 85 | SeerInterfaceError(SeerInterfaceErrorType type,const char *templateString,...); // length of string is limited to |
|---|
| 86 | // maxErrorStringLength |
|---|
| 87 | ~SeerInterfaceError(); |
|---|
| 88 | void print() const; |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | class SeerInterfaceDataString; |
|---|
| 95 | class SeerInterfaceDataLink; |
|---|
| 96 | class SeerInterfaceDataSet; |
|---|
| 97 | class SeerDataVisitor; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<new Class!!! |
|---|
| 98 | |
|---|
| 99 | class SeerInterfaceData { |
|---|
| 100 | friend class SeerInterfaceDataSet; |
|---|
| 101 | SeerInterfaceData *prev; |
|---|
| 102 | SeerInterfaceData *next; // linked list |
|---|
| 103 | SeerInterfaceDataSet *father; |
|---|
| 104 | protected: |
|---|
| 105 | SeerInterfaceData(); |
|---|
| 106 | public: |
|---|
| 107 | char *key; |
|---|
| 108 | enum SeerExportQualityLevel exportQualityLevel; |
|---|
| 109 | enum SeerImportQualityLevel importQualityLevel; |
|---|
| 110 | |
|---|
| 111 | virtual void print() const = 0; |
|---|
| 112 | virtual SeerInterfaceDataType type() = 0; |
|---|
| 113 | virtual ~SeerInterfaceData(); |
|---|
| 114 | virtual SeerInterfaceDataString *toDataString(); // converts this savely to String type |
|---|
| 115 | virtual SeerInterfaceDataSet *toDataSet(); // |
|---|
| 116 | virtual SeerInterfaceDataLink *toDataLink(); // |
|---|
| 117 | |
|---|
| 118 | virtual void accept(SeerDataVisitor&); // <<<<<<<<<<<<<<<<<<< <<<<<<<<<<new function!!!! |
|---|
| 119 | |
|---|
| 120 | }; |
|---|
| 121 | |
|---|
| 122 | class SeerInterfaceDataString: public SeerInterfaceData { |
|---|
| 123 | public: |
|---|
| 124 | virtual SeerInterfaceDataType type(); |
|---|
| 125 | char *value; |
|---|
| 126 | void set(const char *key, const char *value); |
|---|
| 127 | SeerInterfaceDataString(); |
|---|
| 128 | SeerInterfaceDataString(const char *key, const char *value); |
|---|
| 129 | virtual SeerInterfaceDataString *toDataString(); // converts this savely to String type |
|---|
| 130 | virtual void print() const ; |
|---|
| 131 | ~SeerInterfaceDataString(); |
|---|
| 132 | |
|---|
| 133 | virtual void accept(SeerDataVisitor&); // <<<<<<<<<<<<<<<<<<< <<<<<<<<<<new function!!!! |
|---|
| 134 | |
|---|
| 135 | }; |
|---|
| 136 | |
|---|
| 137 | class SeerInterfaceDataLink: public SeerInterfaceData { |
|---|
| 138 | public: |
|---|
| 139 | virtual SeerInterfaceDataType type(); |
|---|
| 140 | char *linktoTableName; |
|---|
| 141 | char *linktoTableId; |
|---|
| 142 | void set(const char *key, const char *table, const char *link); |
|---|
| 143 | SeerInterfaceDataLink(); |
|---|
| 144 | SeerInterfaceDataLink(const char *key, const char *table, const char *link); |
|---|
| 145 | virtual SeerInterfaceDataLink *toDataLink(); // conyverts this savely to String type |
|---|
| 146 | virtual void print() const; |
|---|
| 147 | ~SeerInterfaceDataLink(); |
|---|
| 148 | |
|---|
| 149 | virtual void accept(SeerDataVisitor&); // <<<<<<<<<<<<<<<<<<< <<<<<<<<<<new function!!!! |
|---|
| 150 | |
|---|
| 151 | }; |
|---|
| 152 | |
|---|
| 153 | class SeerInterfaceDataSet: public SeerInterfaceData { |
|---|
| 154 | SeerInterfaceData *firstElement; |
|---|
| 155 | SeerInterfaceData *lastElement; |
|---|
| 156 | SeerInterfaceData *localLoopPointer; |
|---|
| 157 | public: |
|---|
| 158 | virtual SeerInterfaceDataSet *toDataSet(); // |
|---|
| 159 | virtual SeerInterfaceDataType type(); |
|---|
| 160 | SeerInterfaceData *firstData(); |
|---|
| 161 | SeerInterfaceData *nextData(); |
|---|
| 162 | void addData(SeerInterfaceData *data); |
|---|
| 163 | void removeData(SeerInterfaceData *data); |
|---|
| 164 | SeerInterfaceData *findData(const char *key); |
|---|
| 165 | const SeerInterfaceData *findData(const char *key)const ; |
|---|
| 166 | virtual void print() const; // for debugging |
|---|
| 167 | SeerInterfaceDataSet(); |
|---|
| 168 | ~SeerInterfaceDataSet(); |
|---|
| 169 | |
|---|
| 170 | virtual void accept(SeerDataVisitor&); // <<<<<<<<<<<<<<<<<<< <<<<<<<<<<new function!!!! |
|---|
| 171 | |
|---|
| 172 | }; |
|---|
| 173 | |
|---|
| 174 | class SeerInterfaceDataStringSet: public SeerInterfaceDataSet { |
|---|
| 175 | public: |
|---|
| 176 | virtual SeerInterfaceDataType type(); |
|---|
| 177 | SeerInterfaceDataString *firstData() { return (SeerInterfaceDataString *)SeerInterfaceDataSet::firstData();}; |
|---|
| 178 | SeerInterfaceDataString *nextData() { return (SeerInterfaceDataString *)SeerInterfaceDataSet::nextData();}; |
|---|
| 179 | // void addData(SeerInterfaceDataString *data) { SeerInterfaceDataSet::addData(data);}; |
|---|
| 180 | SeerInterfaceDataString *findData(const char *searchKey) { return (SeerInterfaceDataString *)SeerInterfaceDataSet::findData(searchKey);}; |
|---|
| 181 | const SeerInterfaceDataString *findData(const char *searchKey)const { return (const SeerInterfaceDataString *)SeerInterfaceDataSet::findData(searchKey);}; |
|---|
| 182 | |
|---|
| 183 | virtual void accept(SeerDataVisitor&); // <<<<<<<<<<<<<<<<<<< <<<<<<<<<<new function!!!! |
|---|
| 184 | |
|---|
| 185 | }; |
|---|
| 186 | |
|---|
| 187 | class SeerDataVisitor { // <<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<< <<<< new Class!!! |
|---|
| 188 | public: |
|---|
| 189 | virtual void visitSeerInterfaceData(SeerInterfaceData&); |
|---|
| 190 | virtual void visitSeerInterfaceDataString(SeerInterfaceDataString&); |
|---|
| 191 | virtual void visitSeerInterfaceDataLink(SeerInterfaceDataLink&); |
|---|
| 192 | virtual void visitSeerInterfaceDataSet(SeerInterfaceDataSet&); |
|---|
| 193 | virtual void visitSeerInterfaceDataStringSet(SeerInterfaceDataStringSet&); |
|---|
| 194 | protected: |
|---|
| 195 | virtual ~SeerDataVisitor() = 0; |
|---|
| 196 | }; |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | class SeerInterfaceSequenceData { |
|---|
| 200 | SeerInterfaceSequenceData(); // no public default constructur |
|---|
| 201 | public: |
|---|
| 202 | char *uniqueID; // rdpSid ???? |
|---|
| 203 | SeerInterfaceSequenceDataType sequenceType; // filter or real sequences |
|---|
| 204 | SeerInterfaceDataStringSet sequences; // ??? whats the key of the real sequence ????? |
|---|
| 205 | SeerInterfaceDataSet attributes; |
|---|
| 206 | void print()const; // for debugging |
|---|
| 207 | SeerInterfaceSequenceData(const char *id); |
|---|
| 208 | ~SeerInterfaceSequenceData(); |
|---|
| 209 | }; |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | class SeerInterfaceTableData { |
|---|
| 213 | SeerInterfaceTableData(); |
|---|
| 214 | public: |
|---|
| 215 | char *uniqueID; |
|---|
| 216 | SeerInterfaceDataSet attributes; |
|---|
| 217 | void print()const; // for debugging |
|---|
| 218 | SeerInterfaceTableData(const char *id); |
|---|
| 219 | ~SeerInterfaceTableData(); |
|---|
| 220 | }; |
|---|
| 221 | |
|---|
| 222 | class SeerInterfaceAttribute { |
|---|
| 223 | public: |
|---|
| 224 | char *name; |
|---|
| 225 | char *pubCmnt; |
|---|
| 226 | enum SeerInterfaceAttributeType type; |
|---|
| 227 | Boolean changeable; |
|---|
| 228 | Boolean deleteable; |
|---|
| 229 | Boolean queryable; |
|---|
| 230 | Boolean requested; // needed by the arb side |
|---|
| 231 | Boolean element_for_upload; // in arb: at least one element has changes |
|---|
| 232 | int sortindex; |
|---|
| 233 | void print()const; |
|---|
| 234 | SeerInterfaceAttribute(); |
|---|
| 235 | ~SeerInterfaceAttribute(); |
|---|
| 236 | }; |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | class SeerInterfaceAlignment { |
|---|
| 241 | SeerInterfaceAlignment(); |
|---|
| 242 | public: |
|---|
| 243 | char *name; |
|---|
| 244 | char *pubCmnt; |
|---|
| 245 | SeerInterfaceAlignmentType typeofAlignment; |
|---|
| 246 | void print()const ; |
|---|
| 247 | SeerInterfaceAlignment(const char *name,const char *pub); |
|---|
| 248 | ~SeerInterfaceAlignment(); |
|---|
| 249 | }; |
|---|
| 250 | |
|---|
| 251 | class SeerInterfaceTableDescription { |
|---|
| 252 | SeerInterfaceTableDescription(); |
|---|
| 253 | public: |
|---|
| 254 | GB_HASH *attribute_hash; // used by arb |
|---|
| 255 | int sort_key; // attributes are sorted according to this entry |
|---|
| 256 | char *tablename; // should be a very short string like REF NOM GBT |
|---|
| 257 | char *tabledescription; // one user readable word |
|---|
| 258 | |
|---|
| 259 | virtual SeerInterfaceAttribute *firstAttribute(); // retrieve attribute_name - attribute_description |
|---|
| 260 | virtual SeerInterfaceAttribute *nextAttribute(); |
|---|
| 261 | |
|---|
| 262 | SeerInterfaceTableDescription(const char *name,const char *desc); |
|---|
| 263 | virtual ~SeerInterfaceTableDescription(); |
|---|
| 264 | void print(); |
|---|
| 265 | }; |
|---|
| 266 | |
|---|
| 267 | |
|---|
| 268 | class SeerInterface { |
|---|
| 269 | public: |
|---|
| 270 | |
|---|
| 271 | virtual SeerInterfaceError *beginSession(const char *username, const char *userpasswd); |
|---|
| 272 | virtual SeerInterfaceError *endSession(); |
|---|
| 273 | |
|---|
| 274 | virtual SeerInterfaceError *writeToArbDirectly(GBDATA *gb_main); // called after arb is fully loaded |
|---|
| 275 | |
|---|
| 276 | virtual SeerInterfaceError *beginTransaction(); |
|---|
| 277 | virtual SeerInterfaceError *commitTransaction(); |
|---|
| 278 | virtual SeerInterfaceError *abortTransaction(); |
|---|
| 279 | |
|---|
| 280 | virtual SeerInterfaceError *beginReadOnlyTransaction(); |
|---|
| 281 | virtual SeerInterfaceError *commitReadOnlyTransaction(); |
|---|
| 282 | |
|---|
| 283 | /* ************** next functions are called only within the scope of a transacton *****/ |
|---|
| 284 | virtual SeerInterfaceAlignment *firstAlignment(); // a list of all alignments in the database |
|---|
| 285 | virtual SeerInterfaceAlignment *nextAlignment(); // a list of all alignments in the database |
|---|
| 286 | |
|---|
| 287 | virtual SeerInterfaceTableDescription *firstTableDescription(); |
|---|
| 288 | virtual SeerInterfaceTableDescription *nextTableDescription(); |
|---|
| 289 | |
|---|
| 290 | virtual SeerInterfaceAttribute *firstAttribute(); // retrieve attribute_name - attribute_description |
|---|
| 291 | virtual SeerInterfaceAttribute *nextAttribute(); |
|---|
| 292 | /* a list of all available datas |
|---|
| 293 | * if an data is not directly attached to the sequenceData |
|---|
| 294 | * but seperated by a 1->n link, concatenate data names using the '/' |
|---|
| 295 | * delimiter, example |
|---|
| 296 | * 'reference/authors', 'reference/journal' 'gb_origin/from', 'gb_origin/acc' ... |
|---|
| 297 | */ |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | /* ****************** query database and retrieve data ************************/ |
|---|
| 301 | |
|---|
| 302 | virtual SeerInterfaceError *queryDatabase(const char *alignmentName, const char *attributeName=0,const char *attributeValue=0); |
|---|
| 303 | virtual SeerInterfaceSequenceData *querySingleSequence(const char *alignmentName, const char *uniqueId); |
|---|
| 304 | // query for an optional alignment and optional data=value |
|---|
| 305 | // There will be only one query at a time !!! |
|---|
| 306 | // After query is run the following functons may be called: |
|---|
| 307 | virtual long numberofMatchingSequences(); |
|---|
| 308 | virtual SeerInterfaceError *setAttributeFilter(SeerInterfaceDataStringSet *requestedAttributes);// default is to get everything |
|---|
| 309 | virtual void setOutputFormat(SeerInterfaceOutputFormat format); |
|---|
| 310 | |
|---|
| 311 | virtual SeerInterfaceSequenceData *firstSequenceData(); // fills in a SeerInterfaceSequence according to filter |
|---|
| 312 | virtual SeerInterfaceSequenceData *nextSequenceData(); // fills in a SeerInterfaceSequence according to filter |
|---|
| 313 | |
|---|
| 314 | /******************** table read/write **********************************************/ |
|---|
| 315 | virtual SeerInterfaceTableData *querySingleTableData(const char *tablename,const char *tableEntryId); // extra tables, like Nomenclature, References, Strains |
|---|
| 316 | |
|---|
| 317 | virtual SeerInterfaceError *queryTableData(const char *alignmentname, const char *tablename); |
|---|
| 318 | virtual long numberofMatchingTableData(); // called after queryTableData |
|---|
| 319 | virtual SeerInterfaceTableData *firstTableData(); // extra tables, like Nomenclature, References, Strains |
|---|
| 320 | virtual SeerInterfaceTableData *nextTableData(); |
|---|
| 321 | |
|---|
| 322 | virtual SeerInterfaceError *checkTableData(const SeerInterfaceTableData *tableData); |
|---|
| 323 | virtual SeerInterfaceError *storeTableData(const SeerInterfaceTableData *tableData); |
|---|
| 324 | |
|---|
| 325 | /* ****************** storing data in the database *********************** |
|---|
| 326 | * first check then store |
|---|
| 327 | * check should return very detailed error messages !!!! |
|---|
| 328 | */ |
|---|
| 329 | virtual SeerInterfaceError *readFromArbDirectly(GBDATA *gb_main); // should use the slider |
|---|
| 330 | |
|---|
| 331 | virtual SeerInterfaceError *checkAttributeName(const SeerInterfaceAttribute *attribute,SeerImportQualityLevel qLevel); |
|---|
| 332 | virtual SeerInterfaceError *storeAttributeName(const SeerInterfaceAttribute *attribute,SeerImportQualityLevel qLevel); |
|---|
| 333 | |
|---|
| 334 | virtual SeerInterfaceError *resortAttributeList(const SeerInterfaceDataStringSet *attributeList); |
|---|
| 335 | |
|---|
| 336 | virtual SeerInterfaceError *checkAlignmentName(const SeerInterfaceAlignment *alignment, SeerImportQualityLevel qLevel); |
|---|
| 337 | virtual SeerInterfaceError *storeAlignmentName(const SeerInterfaceAlignment *alignment, SeerImportQualityLevel qLevel); |
|---|
| 338 | |
|---|
| 339 | /* store sequences, SeerQualityLevel is taken from the datas !!! */ |
|---|
| 340 | virtual SeerInterfaceError *checkSequence(const char *alignmentname, const SeerInterfaceSequenceData *sequence); // error->errorSource should be set |
|---|
| 341 | virtual SeerInterfaceError *storeSequence(const char *alignmentname, const SeerInterfaceSequenceData *sequence); |
|---|
| 342 | |
|---|
| 343 | virtual void debug_function(void); |
|---|
| 344 | }; |
|---|
| 345 | |
|---|
| 346 | typedef SeerInterface *(SeerInterfaceCreator)(); // creates an seer interface |
|---|
| 347 | extern SeerInterfaceCreator *seerInterfaceCreator; |
|---|
| 348 | |
|---|
| 349 | class SeerInstallInterfaceCreator{ |
|---|
| 350 | int dummy; |
|---|
| 351 | public: |
|---|
| 352 | SeerInstallInterfaceCreator( SeerInterfaceCreator *ic ){ |
|---|
| 353 | seerInterfaceCreator = ic; |
|---|
| 354 | }; |
|---|
| 355 | }; |
|---|