boxchain.h
Go to the documentation of this file.00001 #ifndef BOXCHAIN_H
00002 #define BOXCHAIN_H
00003
00004 #include <string>
00005
00006 #include <iostream>
00007 #include <list>
00008 #include <set>
00009 #include <map>
00010 #include "bioseq.h"
00011 #include "alignseg.h"
00012 #include "matrix.h"
00013 #include "kzblast.h"
00014 #include "dynaln.h"
00015
00016 using namespace std;
00017
00025
00026
00027
00030 class ltAlignsegexBeginYPtr {
00031 public:
00032 bool operator()(const Alignsegex *p1, const Alignsegex *p2) const {
00033 if (p1->getY() < p2->getY()) return true;
00034 else if (p1->getY() == p2->getY()) {
00035 if (p1->getScore()<p2->getScore()) return true;
00036 else return false;
00037 }
00038 else return false;
00039 }
00040 };
00041
00042 class ltAlignsegexEndYPtr {
00043 public:
00044 bool operator()(const Alignsegex *p1, const Alignsegex *p2) const {
00045 if (p1->getEndY() < p2->getEndY()) return true;
00046 else if (p1->getEndY() == p2->getEndY()) {
00047 if (p1->getMaxScore()<p2->getMaxScore()) return true;
00048 else return false;
00049 }
00050 else return false;
00051 }
00052 };
00053
00056 class Boxchain {
00057 public:
00058 Boxchain(Alignsegex* pe, const bioseq* xx, const bioseq* yy);
00059 ~Boxchain();
00060 friend ostream& operator<<(ostream& ous, const Boxchain& bc);
00061 void buildAlignment(Dynaln& aln);
00062 void printAlign(ostream &ous, const int width=70);
00063 int getXStart() const { return boxes.front()->getX(); }
00064 int getYStart() const { return boxes.front()->getY(); }
00065 int getXEnd() const { return boxes.back()->getEndX(); }
00066 int getYEnd() const { return boxes.back()->getEndY(); }
00067 int numberHSP() const { return boxes.size(); }
00068 int getScore() const { return sumscore; }
00069
00070 private:
00071 list<Alignsegex*> boxes;
00072 const bioseq* xseq;
00073 const bioseq* yseq;
00074 string top, buttom, middle;
00075 int sumscore;
00076 };
00077
00084 class Linkbox {
00085 public:
00086 ~Linkbox();
00090 Linkbox(const list<Alignseg> &asg, const bioseq* qseq, const bioseq* tseq);
00091 typedef multiset<Alignsegex*, ltAlignsegexEndYPtr>::iterator bestiterator;
00092 typedef multiset<Alignsegex*, ltAlignsegexEndYPtr>::reverse_iterator bestreverse_iterator;
00093 typedef multimap<int, Alignsegex*>::iterator mmiterator;
00094
00103 Boxchain* bestChain(Dynaln& aln);
00115 int connect(Alignsegex* as1, Alignsegex* as2, Dynaln& aln);
00116
00117
00118
00119
00120
00121
00122 void show_best(ostream &ous) const;
00123
00124 void show_start2match(ostream &ous) const;
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00142 void removeChain(Alignsegex* p);
00157 void repairEnds(const int window=4, const float frac=0.15);
00158 static void setMatrix(const Matrix* mt) { matrix=mt; }
00159 static void setBlastParameter(const BlastParameter* p) { blparam=p; }
00160
00161 private:
00162 set<int> xpoints;
00163
00164
00165 multimap<int, Alignsegex*> start2match;
00166 multimap<int, Alignsegex*> end2match;
00167
00168
00169
00170
00171
00172 multiset<Alignsegex*, ltAlignsegexEndYPtr> best;
00173
00174
00175
00176
00177
00178
00179
00180 void cleanUpBest(bestiterator bi);
00181 const bioseq* xseq;
00182 const bioseq* yseq;
00183
00184 static const BlastParameter* blparam;
00185 static const Matrix* matrix;
00186 };
00187
00188 #endif