ContigIterator_AMOS.hh

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 #ifndef CONTIG_ITERATOR_HH
00013 #define CONTIG_ITERATOR_HH 1
00014 
00015 #include "Contig_AMOS.hh"
00016 #include "Read_AMOS.hh"
00017 
00018 #include <map>
00019 #include <list>
00020 #include <vector>
00021 #include <string>
00022 #include <queue>
00023 #include <functional>
00024 
00025 namespace AMOS 
00026 {
00027 
00035 class TiledRead_t 
00036 {
00037 public:
00038 
00040   TiledRead_t(Tile_t tile, Read_t red, int readidx);
00041 
00043   char base(Pos_t gindex) const
00044   {
00045     if (gindex < m_loffset || gindex > m_roffset) { return ' '; }
00046     return m_seq[gindex-m_loffset];
00047   }
00048   
00050   int qv(Pos_t gindex) const
00051   {
00052     if (gindex < m_loffset || gindex > m_roffset) { return -1; }
00053     return m_qual[gindex-m_loffset] - MIN_QUALITY;
00054   }
00055 
00057   int32_t m_readidx;
00058 
00060   Pos_t m_loffset;
00061 
00063   Pos_t m_roffset;
00064 
00066   bool m_isRC;
00067 
00069   ID_t m_fragid;
00070 
00072   ID_t m_iid;
00073 
00075   std::string m_eid;
00076 
00077 private:
00079   std::string m_seq;
00080   
00082   std::string m_qual;
00083 };
00084 
00085 typedef std::list<TiledRead_t> TiledReadList_t;
00086 
00093 struct TileOrderCmp
00094 {
00095   bool operator () (const Tile_t & a, const Tile_t & b)
00096   {
00097     int offdiff = b.offset - a.offset;
00098 
00099     if (offdiff)
00100     {
00101       if (offdiff < 0) { return false; }
00102       return true;
00103     }
00104 
00105     int lendiff = (b.getGappedLength()) - (a.getGappedLength());
00106 
00107     if (lendiff)
00108     {
00109       if (lendiff < 0) { return false; }
00110       return true;
00111     }
00112 
00113     return (a.source < b.source);
00114   }
00115 };
00116 
00117 
00118 
00119 
00128 class BaseStats_t
00129 {
00130 public:
00132   BaseStats_t(char base);
00133 
00135   char m_base;
00136 
00138   int  m_cumqv;
00139 
00141   int  m_maxqv;
00142 
00144   std::vector<TiledReadList_t::const_iterator> m_reads;
00145 
00147   void addRead(TiledReadList_t::const_iterator tile, Pos_t gindex);
00148 };
00149 
00150 
00151 
00153 struct BaseStatsCmp
00154 {
00155   bool operator() (const BaseStats_t * a, const BaseStats_t * b)
00156   {
00157     if (a->m_reads.size() == b->m_reads.size())
00158     {
00159       if (a->m_cumqv == b->m_cumqv)
00160       {
00161         return a->m_maxqv > b->m_maxqv;
00162       }
00163 
00164       return a->m_cumqv > b->m_cumqv;
00165     }
00166     
00167     return a->m_reads.size() > b->m_reads.size();
00168   }
00169 };
00170 
00171 
00172 
00173 class ContigIterator_t;
00174 
00188 class Column_t 
00189 {
00190 public:
00192   Column_t (ContigIterator_t & ci);
00193 
00195   std::vector<BaseStats_t *> getBaseInfo();
00196 
00198   Pos_t m_gindex;
00199   
00201   Pos_t m_uindex;
00202 
00204   char m_cons;
00205   
00207   int m_cqv;
00208 
00210   int32_t m_depth;
00211 
00213   std::map<char, BaseStats_t> m_baseinfo;
00214 };
00215 
00216 
00217 
00231 class ContigIterator_t 
00232 {
00233 public:
00235   ContigIterator_t(Contig_t & ctg, Bank_t * rdbank);
00236 
00238   bool seek(Pos_t gindex);
00239 
00241   bool advanceNext();
00242 
00244   Pos_t uindex() const;
00245 
00247   Pos_t gindex() const { return m_gindex; }
00248 
00250   bool hasSNP() const;
00251 
00253   char cons()   const { return m_consensus[m_gindex]; }
00254   
00256   int cqv()    const { return m_consqual[m_gindex] - MIN_QUALITY;  }
00257 
00259   Column_t getColumn();
00260 
00262   const Contig_t &        getContig()      const { return m_contig; }
00263 
00264 
00266   const TiledReadList_t & getTilingReads() const { return m_tilingreads; }
00267 
00268 
00269 
00270 
00271 private:
00273   void renderTile(Tile_t & tile, int tilingIndex);
00274 
00276   struct ReadListItEndCmp
00277   {
00278     bool operator () (const TiledReadList_t::iterator & a, const TiledReadList_t::iterator & b)
00279     {
00280       return (a->m_roffset > b->m_roffset);
00281     }
00282   };
00283 
00285   std::priority_queue<TiledReadList_t::iterator, std::vector<TiledReadList_t::iterator>, ReadListItEndCmp > m_ends;
00286 
00288   Bank_t * m_readBank;
00289 
00291   std::string m_consensus;
00292 
00294   std::string m_consqual;
00295 
00297   Pos_t m_gindex;
00298 
00300   Pos_t m_uindex;
00301 
00303   int32_t m_currenttile;
00304 
00306   int32_t m_numreads;
00307 
00309   Contig_t m_contig;
00310 
00312   static int32_t s_tilingreadsoffset;
00313   
00315   int32_t m_tilingreadsoffset;
00316 
00318   TiledReadList_t m_tilingreads;
00319 };
00320 
00321 
00322 } // namespace AMOS
00323 
00324 
00325 #endif

Generated on Mon Feb 22 17:36:27 2010 for libAMOS by  doxygen 1.4.7