feature.h
Go to the documentation of this file.00001
00002 #ifndef FEATURE_H
00003 #define FEATURE_H
00004
00005 #include <vector>
00006 #include <string>
00007 #include "seqinfo.h"
00008 #include "dseq.h"
00009 #include "gberr.h"
00010 #include "strformat.h"
00014 class featerr
00015 {
00016 public:
00017 featerr();
00018 featerr &pick(const string &m);
00019 featerr &pick(const char *m);
00020 void print(ostream &ous) const;
00021
00022 private:
00023 string info;
00024 };
00025
00029 struct qualif {
00030 char qkey[20];
00031 string qvalue;
00032
00033 qualif();
00034 qualif(const qualif &qu);
00035 qualif& operator=(const qualif &qu);
00036 bool keyis(const char* kk) const {return !strcmp(qkey, kk);}
00037 };
00038
00039
00040 class feature
00041 {
00042 public:
00043 feature();
00044 feature(const feature &fe);
00045 ~feature();
00046 feature &operator=(const feature &fe);
00047
00049
00050
00051
00052
00053
00054
00055
00056
00057 int read(istream &ins, char nxt[]);
00058
00063 int outSeg(ostream &ous) const;
00064
00070 ostream& outRange(ostream &ous) const;
00073 ostream& outRange(ostream &ous, const char ed) const {
00074 outRange(ous); ous << ed; return ous;
00075 }
00084 ostream& endInfo(ostream &ous, const bool emark=true) const;
00085
00089 void output(ostream &seq, ostream& sub, seqinfo &sinf) const;
00090
00091
00092
00093
00094 void dumpFeat(ostream &bd) const;
00095
00096 void writeCDS(ostream& seq, ostream& sub, seqinfo &sinf) const;
00097
00098 void writemRNA(ostream &seq, ostream& sub, seqinfo &sinf) const;
00099 void writeSource(ostream &seqout, ostream &subsout, seqinfo &sinf) const;
00100 void writeGene(ostream &seq, ostream &sub, seqinfo &sinf) const;
00101 void writeRNA(ostream &sout, ostream &subout, seqinfo &sinf) const;
00102 void writerpt(ostream &seq, ostream &sub, seqinfo &sinf) const;
00103 void writeExon(ostream &ous) const;
00104 void writeToken(ostream &seq, ostream &sub, seqinfo &sinf,
00105 const dseq &nt) const;
00106
00110 void writeAllele(ostream &seq, ostream &sub, seqinfo &sinf) const;
00111
00112
00113 void wjoinseg(ostream &sub, seqinfo &sinf) const;
00114
00118 void writeUTR(ostream &seq, ostream &sub, seqinfo &sinf) const;
00119
00126 void wFeature(ostream &ous, const seqinfo &sinf) const;
00127
00129
00133 bool isAbnormal() const;
00134
00135 bool complement() const;
00136 bool newfeat() const {return (findex() == -1);}
00137
00138
00139 bool is(const char *ff) const {return !strcmp(curFeat, ff);}
00140
00143 bool isjoinseg() const;
00144
00145
00146 bool locIsJoin() const { return n>0; }
00147
00149 const char *feat() const { return curFeat; }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00162 int findex() const;
00163
00164
00167 bool findQualif(const char* qk, string &vv) const;
00168
00173 string qvmap(const char *k) const;
00174
00179 int qfind(const char *kq) const;
00180
00181 friend const string orgtag(const seqinfo &sinf);
00182
00183
00184
00185
00186
00187 private:
00188 int nq;
00189 qualif *qv;
00190 vector<string> dbxref;
00191 vector<string> qnv;
00192
00193 int begin;
00194 int vb;
00195 int end;
00196 int ve;
00197 bool noLeft, noRight;
00198 string replseq;
00199
00200 int *loc;
00201 int n;
00202 char *locstr;
00203 int l, maxl;
00204 char curFeat[16];
00205
00206 void copy(const feature &lo);
00207
00217 int readloc(istream &ins, char ln[]);
00218
00219 static const char *ft[64];
00220 static const char *qt[74];
00221
00223 int qindex(const char qual[]) const;
00224
00225
00226 bool mktitle(string &tt) const;
00227
00228
00229 int subkey(string &sk) const;
00230
00231
00232
00233
00234
00238 bool tokey(string &tk) const;
00239
00240 void rptdump(ostream &ous, const seqinfo &sinf) const;
00241 void RNAdump(ostream &ous, const seqinfo &sinf) const;
00242
00243
00244 void subCDS(ostream &seq, ostream &sub, const string &cdsKey, const string &title, int tlnIdx, const seqinfo &sqinf) const;
00245 };
00246 #endif