00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef INCLUDED_HashTableTranslated
00032 #define INCLUDED_HashTableTranslated
00033
00034
00035
00036
00037 #include "HashTablePacked.h"
00038
00039 #include "SequenceEncoder.h"
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 class HashTableComponent : public HashTablePacked
00056 {
00057 public:
00058
00059 HashTableComponent( ostream& monitoringStream, string name,
00060 Allocator<PositionPacked>& hitListAllocator
00061 = defaultHitListAllocator,
00062 Allocator<PositionInHitList>& arrayAllocator
00063 = defaultArrayAllocator );
00064
00065 virtual void convertHits
00066 ( PackedHitStore& hits, HitList& hitListFwd );
00067
00068 void setQueryFrame( int qf ) { queryFrame_ = qf; }
00069
00070
00071 private:
00072 int queryFrame_;
00073
00074
00075
00076 };
00077
00078
00079
00080
00081
00082
00083
00084
00085 class HashTablePackedProtein : public HashTablePacked
00086 {
00087 public:
00088 typedef void (HashTablePackedProtein::* MatchSequencePointer)
00089 (WordSequence&, HitList&);
00090
00091 HashTablePackedProtein( ostream& monitoringStream, string name = "",
00092 Allocator<PositionPacked>& hitListAllocator
00093 = defaultHitListAllocator,
00094 Allocator<PositionInHitList>& arrayAllocator
00095 = defaultArrayAllocator );
00096
00097
00098 virtual void convertHits
00099 ( PackedHitStore& packedHits, HitList& hitListFwd );
00100
00101 virtual void matchSequence
00102 ( WordSequence& seq, HitList& hitListFwd )
00103 {
00104 (this->*pMatchSequence_)(seq, hitListFwd);
00105 }
00106
00107 void matchSequenceProtein( WordSequence& seq, HitList& hitListFwd );
00108 void matchSequenceTranslatedDNA( WordSequence& seq, HitList& hitListFwd );
00109
00110 void setQueryProtein( void )
00111 {
00112 pMatchSequence_ = &HashTablePackedProtein::matchSequenceProtein;
00113 queryMult_ = 1;
00114 queryFrame_ = 0;
00115 }
00116 void setQueryTranslatedDNA( void )
00117 {
00118 pMatchSequence_ = &HashTablePackedProtein::matchSequenceTranslatedDNA;
00119 queryMult_ = gNumReadingFrames;
00120 queryFrame_ = 0;
00121 }
00122
00123 private:
00124 CodonList codons_;
00125 SequenceEncoderCodon codonEncoder_;
00126
00127 int queryFrame_;
00128 int queryMult_;
00129
00130 MatchSequencePointer pMatchSequence_;
00131
00132
00133
00134
00135 };
00136
00137
00138
00139
00140
00141 class HashTableTranslated : public HashTableGeneric
00142 {
00143
00144
00145 public:
00146 typedef void (HashTableTranslated::* MatchSequencePointer)
00147 (WordSequence&, HitList&);
00148
00149 enum { eDNAWordSizeForHashing = gMaxBasesPerWord-1 };
00150
00151
00152
00153
00154
00155
00156
00157 HashTableTranslated( ostream& monitoringStream=cerr,
00158 string name="",
00159 Allocator<PositionPacked>& hitListAllocator
00160 = HashTablePacked::defaultHitListAllocator,
00161 Allocator<PositionInHitList>& arrayAllocator
00162 = HashTablePacked::defaultArrayAllocator );
00163
00164
00165
00166
00167
00168
00169 virtual ~HashTableTranslated() {}
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 virtual void loadHashTable( SourceReaderIndex* pSourceReader=NULL );
00189 virtual void saveHashTable( void );
00190
00191
00192
00193 virtual void setupPointerArray( void );
00194 virtual int countWordsAndGetNames
00195 ( SequenceReader& sequenceReader, SequenceAdapter* seq );
00196
00197 virtual void computePointerArray( void );
00198 virtual void setupHitList( void );
00199 virtual void hashAllWords
00200 ( SequenceReader& sequenceReader, SequenceAdapter* seq, int numSeqs );
00201 virtual void cleanupTempData( void );
00202
00203 virtual void hashWords
00204 ( SequenceAdapter& thisSeq, SequenceNumber seqNum );
00205 virtual void countWords( SequenceAdapter& thisSeq );
00206
00207 virtual void matchSequence
00208 ( WordSequence& seq, HitList& hitListFwd )
00209 {
00210 (this->*pMatchSequence_)(seq, hitListFwd);
00211 }
00212
00213 void matchSequenceProtein( WordSequence& seq, HitList& hitListFwd );
00214 void matchSequenceTranslatedDNA( WordSequence& seq, HitList& hitListFwd );
00215
00216
00217 virtual void setNumRepeats( int nr);
00218 virtual void setSubstituteThreshold( int ns );
00219
00220 virtual char* getHitListStart( void ) const;
00221 virtual int getHitTypeSize( void ) const;
00222 virtual void allocateHitList( unsigned long size );
00223 virtual void loadHitList( unsigned long size );
00224 virtual void saveHitList( void );
00225
00226
00227 virtual int getMaxNumHits() const;
00228
00229 virtual void setMaxNumHits( int mnh );
00230
00231
00232
00233 virtual void printHashStats( void );
00234
00235
00236
00237 virtual unsigned long getTotalNumWords( void ) const;
00238
00239
00240 void setForward( void ) { pHash_ = &hashFwd_; }
00241 void setReverse( void ) { pHash_ = &hashRev_; }
00242
00243 void setQueryProtein( void )
00244 {
00245 pMatchSequence_ = &HashTableTranslated::matchSequenceProtein;
00246 }
00247 void setQueryTranslatedDNA( void )
00248 {
00249 pMatchSequence_ = &HashTableTranslated::matchSequenceTranslatedDNA;
00250 }
00251
00252
00253
00254
00255
00256
00257
00258
00259 bool isForward( void ) const { return (pHash_==&hashFwd_); }
00260
00261
00262
00263
00264 protected:
00265
00266
00267
00268
00269 private:
00270 HashTableTranslated( const HashTableTranslated&);
00271 HashTableTranslated& operator=(const HashTableTranslated&);
00272
00273
00274 protected:
00275 int translatedWordLength_;
00276
00277 HashTableComponent hashFwd_;
00278 HashTableComponent hashRev_;
00279 HashTableComponent* pHash_;
00280
00281 CodonList codons_;
00282 SequenceEncoderCodon codonEncoder_;
00283
00284 MatchSequencePointer pMatchSequence_;
00285
00286
00287 };
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297 #endif
00298
00299