alignment.h
Go to the documentation of this file.00001 #ifndef ALIGNMENT_H
00002 #define ALIGNMENT_H
00003
00004
00005
00006 #include <iostream>
00007
00008 #include <string>
00009 #include <vector>
00010
00011 using namespace std;
00012
00013 enum quality { best, good, partial_good, ok, bad };
00014
00015
00016
00017
00018
00019
00020 enum alnmethod { clustal, dialign };
00021
00027 list<pair<int, int> > listgap(const string &s, const char gapChar='-');
00028
00029 class alignpos {
00030 public:
00031 alignpos(int l, int w) : length(l), width(w) { allocate(); }
00032 ~alignpos() { deallocate(); }
00033 alignpos(const alignpos &alp);
00034 alignpos& operator=(const alignpos &alp);
00035
00036 private:
00037 void deallocate();
00038 void allocate();
00039 int **posmap;
00040 int length;
00041 int width;
00042 };
00043
00044 class alignment {
00045 public:
00046 alignment() : idenCnt(0), nogapCol(0), nogapsimCnt(0), simCnt(0) {}
00047
00048
00049
00050
00051 void read(istream &in);
00052
00054 void readDia(istream &in);
00056 void readClustal(istream &in);
00057
00059 void printPolymorphic(ostream &ous) const;
00060
00061 alignpos getPosition() const;
00062
00063
00064 friend ostream& operator<<(ostream &ou, const alignment &aln);
00065 string getalnmodel() const;
00066
00067
00068
00069 void dumpaln();
00070 bool highQuality(float cut=0.2);
00071
00072
00073 int length() const { return seqarr[0].length(); }
00074 int nogapLength() const { return nogapCol; }
00075
00076
00077 float identity() const { return (float)idenCnt/length(); }
00078
00079 float similarity() const { return (idenCnt+simCnt)/(float)length(); }
00080 int getIdentityCount() const { return idenCnt; }
00081 int getSimilarityCount() const { return simCnt; }
00082 bool goodSegment();
00083 float nogapIdentity() const { return (float)idenCnt/nogapCol; }
00084 float nogapSimilarity() { return (float)(idenCnt + nogapsimCnt)/nogapCol; }
00085 int seqCount() const { return seqarr.size(); }
00086 int size() const { return seqarr.size(); }
00087 ostream& dumpQuality(ostream &ou);
00088
00089
00090 float partialCount(float gapcut = 0.51);
00091 bool partialGood(float base);
00092
00093 quality getqual(float base = 0.08, float top = 1.2);
00094
00095 static const int nogapcolcut;
00096 float idenCut;
00097 alnmethod method;
00098 string clusterid;
00099
00100
00101 protected:
00102 float calcut(float top, float n, int iden);
00103 void count();
00104 void countDia();
00105
00106
00107
00108
00109 vector<string> seqarr, namearr;
00112 string consensus;
00113 int idenCnt, simCnt;
00114
00115 int nogapsimCnt, nogapCol;
00116 int partiden, partcol;
00117 float avgThick;
00118 };
00119
00120
00121 #endif