gbseq.h
Go to the documentation of this file.00001
00002
00003
00004
00005 #ifndef GBMODEL_H
00006 #define GBMODEL_H
00007
00008 #include <string>
00009 #include <vector>
00010 #include <iostream>
00011 #include "gbfn.h"
00012
00013
00014 #include "Refreader.h"
00015 #include "strformat.h"
00016 #include "pfeature.h"
00017
00018 using namespace std;
00019
00020 class feature;
00021
00022
00023
00024
00025 class gbseq {
00026 public:
00027
00028 gbseq() : seqLength(-1), features(), seg(0), segtotal(0), orgacronym()
00029 { line.reserve(84); sequence.reserve(5000); }
00030
00031 virtual ~gbseq() { for (int i=0; i<references.size(); i++) delete references[i]; }
00032
00033
00034
00035
00036
00037 virtual bool read(istream &ins);
00038
00039 virtual void writeAce(ostream &ous, ostream &sub, ostream &snp) = 0;
00040
00044 void writeSpecies(ostream& ous);
00045
00050 int getLength() const;
00056 int getSeqlen() const { return sequence.length(); }
00057
00058 string getDate() const { return locus.substr(56, 11); }
00059
00060
00061 void clear();
00062 string getKey() const { return accession[0]; }
00063 string getLocusName() const { return firstword(locus); }
00064 string getSegmentLocus() const;
00065
00069 string getType() const { string tmp= locus.substr(35,6); trim(tmp); return tmp; }
00075 string getMolType() const;
00076
00077
00083 string getOrgAcronym() const;
00084 string getOrganism() const { return organism; }
00085
00086 bool hasFeature(const string &f, int b, int e) const;
00087 bool isSegment() const { return seg>0; }
00088
00089 static const int VAL_START = 12;
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00102 static void init();
00104 static void loadOrgmap(const string &file);
00106 static void dumpOrgmap(const string &file);
00107
00108
00109 protected:
00110
00111
00112
00113 string locus;
00114 mutable int seqLength;
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 string definition;
00141 vector<string> accession;
00142 string version[2];
00143 string dbsource;
00144 string keywords;
00145
00146 int seg, segtotal;
00147 string source;
00148 string organism;
00149 string taxonomy;
00150
00151
00152 vector<Ref*> references;
00153 string comment;
00154 vector<feature> features;
00155 string sequence;
00156
00157
00158 string line;
00159 mutable string orgacronym;
00160
00169 static map<string,string> orgmap;
00170 static set<string> orgacronyms;
00171 static set<string> taxons;
00172 };
00173
00174 class gbprtseq : public gbseq {
00175 public:
00178 bool read(istream &ins);
00179
00180
00181 void writeAce(ostream &ous, ostream &sub, ostream &snp);
00182 };
00183
00184 class gbdnaseq : public gbseq {
00185 public:
00186 gbdnaseq() : gbseq(), subcnt(1) {}
00187 bool read(istream &ins);
00188
00189 void writeAce(ostream &ous, ostream &sub, ostream &snp);
00190 void clear();
00191 string getStrand() const { return locus.substr(32, 3); }
00192 int nextsub() const { return subcnt++; }
00193 int currsub() const { return subcnt; }
00194
00195 private:
00196 int A, C, G, T, O;
00197 mutable int subcnt;
00198 };
00199
00200 #endif