blast.h

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

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