Contig_AMOS.hh

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #ifndef __Contig_AMOS_HH
00011 #define __Contig_AMOS_HH 1
00012 
00013 #include "Sequence_AMOS.hh"
00014 #include "Layout_AMOS.hh"
00015 #include <vector>
00016 
00017 
00018 
00019 
00020 namespace AMOS {
00021 
00022 //================================================ Contig_t ====================
00034 //==============================================================================
00035 class Contig_t : public Sequence_t
00036 {
00037   
00038 private:
00039   bool gapsvalid_m;                   //<! indicates if gaps_m is up to date
00040   std::vector<Pos_t> gaps_m;          
00041   std::vector<Tile_t> reads_m;        
00042 
00043   //--------------------------------------------------- compress ---------------
00046   void compress ( );
00047 
00048 
00049   //--------------------------------------------------- uncompress -------------
00052   void uncompress ( );
00053 
00054 
00055   //--------------------------------------------------- indexGaps --------------
00058   void indexGaps();
00059 
00060 protected:
00061 
00062   //--------------------------------------------------- readRecord -------------
00063   virtual void readRecord (std::istream & fix, std::istream & var);
00064 
00065 
00066   //--------------------------------------------------- readRecordFix ----------
00067   virtual void readRecordFix (std::istream & fix);
00068 
00069 
00070   //--------------------------------------------------- writeRecord ------------
00071   virtual void writeRecord (std::ostream & fix, std::ostream & var) const;
00072 
00073 
00074 public:
00075 
00076   static const NCode_t NCODE;
00078 
00079 
00080   //--------------------------------------------------- Contig_t ---------------
00083   Contig_t ( )
00084    : gapsvalid_m(false)
00085   {
00086 
00087   }
00088 
00089 
00090   //--------------------------------------------------- Contig_t ---------------
00093   Contig_t (const Contig_t & source)
00094   {
00095     *this = source;
00096   }
00097 
00098 
00099   //--------------------------------------------------- ~Contig_t --------------
00102   ~Contig_t ( )
00103   {
00104 
00105   }
00106 
00107 
00108   //--------------------------------------------------- clear ------------------
00109   virtual void clear ( )
00110   {
00111     Sequence_t::clear( );
00112     gaps_m . clear( );
00113     reads_m . clear( );
00114     gapsvalid_m = false;
00115   }
00116 
00117 
00118   //--------------------------------------------------- gap2ungap --------------
00129   Pos_t gap2ungap (Pos_t gap);
00130 
00131 
00132   //--------------------------------------------------- ungap2gap --------------
00141   Pos_t ungap2gap (Pos_t ungap);
00142   
00143   //--------------------------------------------------- getGCContent --------------
00148   virtual double getGCContent (const Range_t & rng) const
00149   {
00150     int gc = 0;
00151     int all = 0;
00152 
00153     int start = rng.getLo();
00154     int stop = rng.getHi();
00155 
00156     if (stop > length_m)
00157       AMOS_THROW_ARGUMENT("Can't compute GC Content beyond sequence length");
00158 
00159     // skip ambiguities, gaps
00160 
00161     for (int i = start; i < stop; i++)
00162     {
00163       switch(seq_m[i])
00164       {
00165         case 'A':
00166         case 'a': 
00167         case 'T':
00168         case 't': all++; break;
00169 
00170         case 'C':
00171         case 'c':
00172         case 'G':
00173         case 'g': all++; gc++; break;
00174       };
00175     }
00176 
00177     return (all) ? ((double)gc)/all : 0.0;
00178   }
00179 
00180   //--------------------------------------------------- getGCContent --------------
00185   virtual double getGCContent ( ) const
00186   {
00187     return getGCContent(Range_t(0, length_m));
00188   }
00189 
00190 
00191 
00192   //--------------------------------------------------- getNCode ---------------
00193   virtual NCode_t getNCode ( ) const
00194   {
00195     return Contig_t::NCODE;
00196   }
00197 
00198 
00199   //--------------------------------------------------- getReadTiling ----------
00204   const std::vector<Tile_t> & getReadTiling ( ) const
00205   {
00206     return reads_m;
00207   }
00208 
00209 
00210   //--------------------------------------------------- getReadTiling ----------
00211   std::vector<Tile_t> & getReadTiling ( )
00212   {
00213     return reads_m;
00214   }
00215 
00216 
00217   //--------------------------------------------------- getSpan ----------------
00225   Size_t getSpan ( ) const;
00226 
00227 
00228   //--------------------------------------------------- getUngappedLength ------
00236   Size_t getUngappedLength ( ) const;
00237 
00238 
00239   //--------------------------------------------------- getUngappedQualString --
00246   std::string getUngappedQualString ( ) const
00247   {
00248     return getUngappedQualString (Range_t (0, getLength( )));
00249   }
00250 
00251 
00252   //--------------------------------------------------- getUngappedQualString --
00265   std::string getUngappedQualString (Range_t range) const;
00266 
00267 
00268   //--------------------------------------------------- getUngappedSeqString ---
00273   std::string getUngappedSeqString ( ) const
00274   {
00275     return getUngappedSeqString (Range_t (0, getLength( )));
00276   }
00277 
00278 
00279   //--------------------------------------------------- getUngappedSeqString ---
00292   std::string getUngappedSeqString (Range_t range) const;
00293 
00294 
00295 
00296   //--------------------------------------------------- insertGapColumn -------
00308   void insertGapColumn (Pos_t gindex);
00309 
00310 
00311 
00312   //--------------------------------------------------- getCovStat -------------
00317   double getCovStat(const double globalArrivalRate) const;
00318 
00319 
00320 
00321   //--------------------------------------------------- getAvgRho --------------
00326   double getAvgRho( ) const;
00327 
00328 
00329 
00330   //--------------------------------------------------- readMessage ------------
00331   virtual void readMessage (const Message_t & msg);
00332 
00333 
00334   //--------------------------------------------------- readUMD ----------------
00349   bool readUMD (std::istream & in);
00350 
00351   //--------------------------------------------------- reverseComplement ------
00359   void reverseComplement();
00360 
00361 
00362   //--------------------------------------------------- setReadTiling ----------
00368   void setReadTiling (const std::vector<Tile_t> & reads)
00369   {
00370     reads_m = reads;
00371   }
00372 
00373 
00374   //--------------------------------------------------- setReadTiling ----------
00380   void setReadTiling (const Layout_t & layout)
00381   {
00382     reads_m = layout . getTiling( );
00383   }
00384 
00385   //--------------------------------------------------- setSequence -----------
00390   void setSequence (const char * seq, const char * qual)
00391   {
00392     gapsvalid_m = false;
00393     Sequence_t::setSequence(seq, qual);
00394   }
00395 
00396   //--------------------------------------------------- setSequence -----------
00401   void setSequence (const std::string & seq, const std::string & qual)
00402   {
00403     gapsvalid_m = false;
00404     Sequence_t::setSequence(seq, qual);
00405   }
00406 
00407   //--------------------------------------------------- writeMessage -----------
00408   virtual void writeMessage (Message_t & msg) const;
00409 
00410 
00411   //--------------------------------------------------- writeUMD ---------------
00423   void writeUMD (std::ostream & out) const;
00424 
00425 };
00426 
00427 } // namespace AMOS
00428 
00429 #endif // #ifndef __Contig_AMOS_HH

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