00001
00002
00003
00005 #ifndef ANNOTATIONITEM_H
00006 #define ANNOTATIONITEM_H
00007
00008 #include "AnnotationScore.h"
00009 #include "RegionPrediction.h"
00010 #include "MatrixItemContents.h"
00011 #include "AnnotationMatrix.h"
00012 #include "localtypedef.h"
00013 #include <pair.h>
00014 #include <vector>
00015
00016 class DnaStr;
00017 class CustomScore;
00018
00031 class AnnotationItem {
00032 public:
00033 typedef pair<const AnnotationItem*,AnnotationScore> apair_t;
00034 typedef pair<int,apair_t> bpair_t;
00035 typedef pair<dsu::Strand_t,int> strnd_frm_t;
00036 struct tback {
00037 tback() : _item(NULL) { }
00038 tback(const AnnotationItem* i, strnd_frm_t strf, dsu::side_t sd, int type) : _item(i),
00039 _strf(strf.first,strf.second), _side(sd), _type(type) { }
00040 int get_type() const { return _type; }
00041 const AnnotationItem* _item;
00042 strnd_frm_t _strf;
00043 dsu::side_t _side;
00044 int _type;
00045 };
00046 public:
00047 AnnotationItem(const std::vector<RegionPrediction*>&,const DnaStr&, const DnaStr&);
00048 ~AnnotationItem() { }
00049
00050
00051 pair<AnnotationScore,MatrixItemContents>
00052 endScore(const CustomScore&,const AnnotationScore&,bool) const;
00053 int getEnd5AdjForStop(int model, dsu::Strand_t strnd) const;
00054 int getEnd3AdjForStop(int model, dsu::Strand_t strnd) const;
00055 dsu::Strand_t getStrnd() const { return _strnd; }
00056 int getEnd5() const { return _seq.getEnd5(); }
00057 int getEnd3() const { return _seq.getEnd3(); }
00058 int length() const { return _seq.length(); }
00059 const RegionPrediction& getRegionPrediction() const { return _seq; }
00060 const DnaStr& getSeq(dsu::Strand_t strnd) const
00061 { assert(strnd != dsu::eEither); return strnd==dsu::ePos? _posSeq : _negSeq; }
00062
00063 tback
00064 getPred(int,dsu::Strand_t,dsu::side_t,int) const;
00065
00066 void
00067 print(std::ostream&,const CustomScore&) const;
00068
00069
00081 void dpUpdate(const AnnotationItem&, std::vector<scr_pr>&,bool);
00082 void dpUpdate(std::vector<scr_pr>&, bool, bool);
00083 AnnotationScore computeNonCodingScore() const;
00084
00085 void
00086 update(const MatrixIdx&,const MatrixIdx&, const int, const AnnotationScore&, const AnnotationItem& );
00087 void
00088 update(const MatrixIdx&,const MatrixIdx&, const int, const AnnotationScore&);
00089
00090 static bool
00091 checkOrf(const AnnotationItem*, const MatrixIdx&,int,int,const DnaStr&);
00092
00093 pair<int,dsu::Strand_t>
00094 getPrevExonType(const MatrixIdx&) const;
00095
00096 const MatrixItemContents& getBest(const MatrixIdx&) const;
00097
00098 const RegionPrediction* getLeft() const { return _left; }
00099 const RegionPrediction* getRght() const { return _rght; }
00100
00101 private:
00102 MatrixItemContents& getBest(const MatrixIdx&);
00103
00104 void
00105 dpUpdate(const AnnotationItem& litem, dsu::Strand_t lstrnd,
00106 std::vector<scr_pr>& inv_scores,
00107 bool isContig, dsu::Strand_t rstrnd) ;
00108
00109 void
00110 updateScore(const AnnotationItem&, bool, std::vector<scr_pr>& inv_scores, int frame,dsu::Strand_t);
00111
00112 void setStrnd(dsu::Strand_t strnd) { _strnd = strnd; }
00113
00114 private:
00115 RegionPrediction& _seq;
00116 const DnaStr& _posSeq, _negSeq;
00117 dsu::Strand_t _strnd;
00118 std::vector<MatrixItemContents> _best;
00119 const RegionPrediction* _left;
00120 const RegionPrediction* _rght;
00121 };
00122
00123 #endif //ANNOTATIONITEM_H