00001
00002
00003
00004 #ifndef _RAA_H_
00005 #define _RAA_H_
00006
00007 extern "C" {
00008 #include "RAA_acnuc.h"
00009 }
00010
00011 #include <string>
00012 #include <Seq/Sequence.h>
00013 #include <Seq/alphabets>
00014
00015 #include "RaaList.h"
00016 #include "RaaSpeciesTree.h"
00017 #include "RaaSeqAttributes.h"
00018
00019 namespace bpp
00020 {
00021
00022
00026 class RaaAddress {
00027 friend class RAA;
00028 int div;
00029 raa_long faddr;
00030 public:
00034 int getDiv() {return div; };
00038 raa_long getAddr() {return faddr; };
00039 };
00040
00041
00065 class RAA {
00066 friend class RaaList;
00067 public:
00068
00089 RAA(const std::string &dbname, int port = 5558, const std::string &server = "pbil.univ-lyon1.fr") throw(int);
00090
00105 RAA(int port=5558, const std::string &server = "pbil.univ-lyon1.fr") throw(int);
00106
00110 ~RAA();
00111
00126 int openDatabase(const std::string &dbname, char *(*getpasswordf)(void *) = NULL, void *p = NULL);
00127
00133 void closeDatabase();
00134
00146 int knownDatabases(vector<std::string> &name, vector<std::string> &description);
00147
00162 RaaSeqAttributes *getAttributes(const std::string &name_or_accno);
00163
00171 RaaSeqAttributes *getAttributes(int seqrank);
00172
00184 Sequence *getSeq(const std::string &name_or_accno, int maxlength=100000);
00185
00197 Sequence *getSeq(int seqrank, int maxlength=100000);
00198
00208 int getSeqFrag(int seqrank, int first, int length, std::string &sequence);
00209
00219 int getSeqFrag(const std::string &name_or_accno, int first, int length, std::string &sequence);
00220
00227 std::string getFirstAnnotLine(int seqrank);
00228
00235 std::string getNextAnnotLine();
00236
00242 RaaAddress getCurrentAnnotAddress();
00243
00251 std::string getAnnotLineAtAddress(RaaAddress address);
00252
00264 Sequence *translateCDS(int seqrank) throw(BadCharException);
00265
00277 Sequence *translateCDS(const std::string &name) throw(BadCharException);
00278
00287 char translateInitCodon(int seqrank);
00288
00308 RaaList *processQuery(const std::string &query, const std::string &listname) throw(std::string);
00309
00320 RaaList *createEmptyList(const std::string &listname, const std::string &kind=RaaList::LIST_SEQUENCES) throw(int);
00321
00327 void deleteList(RaaList *list);
00328
00329
00359 RaaList *getDirectFeature(const std::string &seqname, const std::string &featurekey, const std::string &listname,
00360 const std::string &matching = "");
00361
00370 vector<std::string> listDirectFeatureKeys();
00371
00380 vector<std::string> listAllFeatureKeys();
00381
00382
00398 void *prepareGetAnyFeature(int seqrank, const std::string &featurekey) throw(std::string);
00399
00409 Sequence *getNextFeature(void *opaque);
00410
00417 void interruptGetAnyFeature(void *opaque);
00418
00437 RaaSpeciesTree *loadSpeciesTree(bool showprogress=true);
00438
00444 void freeSpeciesTree(RaaSpeciesTree *tree);
00445
00446
00454 int keywordPattern(const std::string &pattern);
00455
00462 int nextMatchingKeyword(std::string &matching);
00463
00467 protected:
00468 raa_db_access *raa_data;
00469 private:
00470 RaaAddress current_address;
00471 int current_kw_match;
00472 std::string *kw_pattern;
00473 Sequence *getSeq_both(const std::string &name_or_accno, int rank, int maxlength);
00474 };
00475
00476 }
00477
00478 #endif // _RAA_H_
00479