boxchain.h

Go to the documentation of this file.
00001 #ifndef BOXCHAIN_H
00002 #define BOXCHAIN_H
00003 
00004 #include <string>
00005 //#include <vector>
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 //class ltMatchQueryBeginPtr {
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; // passed on from the outside
00073       const bioseq* yseq; // from the outside
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       /* display the final best set content
00118        * this contains the final result
00119        */
00120       //void showBest(ostream &ous) const;
00121       /* show the best set content directly */
00122       void show_best(ostream &ous) const;
00123       //void show_end2match(ostream &ous) const;
00124       void show_start2match(ostream &ous) const;
00125 
00126       /* find sections on the target (genomic) where all matches
00127        * are in the same direction as regards to targets
00128        * Thse section may overlap.
00129        * Requirement: The tblastn must have been sorted by target.
00130        * This class does not have enough information to do
00131        * this job well. The data structure is also not easy
00132        * for deletion.
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       /* only this one holds the data 
00164        */
00165       multimap<int, Alignsegex*> start2match;
00166       multimap<int, Alignsegex*> end2match;
00167       /* although this set may contain elements starting
00168        * at the same b.y, their scores must be different
00169        * Order by queryBegin, then by maxScore
00170        */
00171       //multimap<int, Alignsegex*> best;
00172       multiset<Alignsegex*, ltAlignsegexEndYPtr> best;
00173       /* bi is the iterator pointing to the 
00174        * element just inserted.  This element will
00175        * be used for comparision, any element after
00176        * this one that has a smaller score will be
00177        * removed
00178        */
00179       //void cleanUpBest(bestiterator bi);
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

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