blast.h

Go to the documentation of this file.
00001 #ifndef ALNSUMMARY_H
00002 #define ALNSUMMARY_H
00003 #include <string>
00004 #include <iostream>
00005 
00006 #ifndef LINE
00007 #define LINE 90
00008 #endif
00009 
00010 //const int  COVERAGE 24  //sets the limit of coverage in one region
00011 //defined in main program
00012 
00013 //#define SCORE_THRESHOLD  40  //only scores larger than this is considered
00014 //for extending an coverage
00015 //#define E_THRESHOLD 0.3  
00016 
00017 #define MATRIX BLOSUM62
00018 #define Mexp -0.945
00019 
00020 extern const int PAM120[24][24]; 
00021 extern const int BLOSUM62[24][24]; 
00022 extern const int BLOSUM62_12[24][24];
00023 extern const double aafq[20];
00024 
00025 using namespace std;
00026 
00027 void split(char ln[], int &s, string &seq, int &e);
00028 
00029 //for the header portion of blast results
00030 class alnsummary
00031 {
00032  public:
00033         int score() const {return s;}
00034         bool scoreHigherThan(double ss) const {return s>ss;}
00035         bool scoreLessThan(double ss) const {return s<ss;}
00036         void read(const char ln[], int ss);
00037         bool eLessThan(double ee) const {return e < ee;}
00038         bool eMoreThan(double ee) const {return e > ee;}
00039         string subjName() const ; //return subject Name
00040 
00041  private:
00042         string subj;  //target sequence name
00043         int s;  //score
00044         double e;  //E Value
00045         int n;  //number of matching segments
00046 };
00047 
00048 //for the alignment portion of blast results
00049 //starting from the Score = line
00050 class alignment
00051 {
00052  public:
00053         int read(istream &ins, char ln[], string &bf);
00054         //will read upto BLASTX(N) or end
00055         //return 0 when reaching the end
00056         //old contents of bf will be flushed away
00057         int begin() const {return qs;}
00058         int end() const {return qe;}
00059         int sbjbegin() const {return ss;}
00060         int sbjend() const {return se;}
00061         float score() const {return sco;}
00062         double eValue() const {return exp;}
00063         int length() const {return len;}
00064         int identical_residue() const {return iden;}
00065         double calBias(double &efflen, int psw = 6) const;  
00066         //calculate the bias-ratio, efflen is the len minus XXX ZZZ BBB
00067         string querySeq() const {return qseq;}
00068         string matchSeq() const {return sbjseq;}
00069         float identity() const {return (float)iden/len;}
00070         bool isup() const {return qe>qs;}
00071         bool iscompl() const {return qs>qe;} //lower strand of DNA
00072 
00073         friend void split(char ln[], int &s, string &seq, int &e);
00074 
00075 friend class region;
00076 
00077  private:
00078    //int expScore(); //calculate expected score
00079         float sco;  //score
00080         double exp;
00081         int iden; //number of identical residues
00082         int simil; //number of similar residues
00083         int len; //length of the alignment
00084         string qseq;
00085         string sbjseq;
00086         int qs;  //query start position
00087         int qe;  //query end position
00088         int ss;
00089         int se;
00090 };
00091 
00092 class region
00093 {
00094  public:
00095         region(const alignment &al);  //copy constructor
00096         void assign(int be, int en, float sc, double ex);
00097         int cover(region &r) const; //return 0 if no overlap with r
00098         //return 1 if overlap start, return 3 if overlap end
00099         //return 2 if completely covered; return 4 if not determined
00100         int add(const alignment &r, bool &accept, double scut, 
00101                 double ecut, int cl); 
00102         //same as cover except action will be taken
00103         //to consolidate two regions of hit if they overlap, otherwise
00104         //no action will be taken
00105         bool isup()  const {return f>s;}
00106         bool iscompl() const {return s>f;} //lower strand of DNA
00107         bool sameDirection(alignment &r) const;
00108         int distance(const alignment &aa) const;
00109         //returns the distance between this region and alignment aa
00110         //returns -1 if overlaping
00111 
00112  private:
00113         int s, f; //start, finish
00114         float hs; //highest score; or the score for a new region
00115         double exp;
00116         int tc; //times covered
00117 };
00118 
00119 #endif

Generated on Wed Aug 10 11:56:56 2011 for Softwares from Orpara by  doxygen 1.5.6