EnsemblServer/SSAHAWrapper.cpp File Reference

#include "SSAHAWrapper.h"
#include "SequenceReaderFasta.h"
#include "HashTableTranslated.h"
#include "SequenceEncoder.h"
#include <vector>
#include <string>

Include dependency graph for SSAHAWrapper.cpp:

Go to the source code of this file.

Classes

struct  CustomHitStore
class  HashTablePackedCustom

Functions

static HashTableGenericpHashTable (NULL)
const char * getSubjectName (unsigned int seqNum)
int loadTable (const char *const tableName)
int doSearch (const char *const pWords, const int numWords, SSAHAHit **const pHits, int **const pStarts)
int clearSearch (void)
int clearTable (void)

Variables

static const int wordLength = 5
static SequenceEncoderProtein encoder (wordLength, cerr)
static CustomHitStore hits
static PackedHitStore hitBuffer
static vector< int > hitStarts
static bool isPacked = false


Function Documentation

int clearSearch ( void   ) 

Definition at line 227 of file SSAHAWrapper.cpp.

References hits.

Referenced by doSearch(), loadTable(), and main().

00228 {
00229   hits.clear();
00230   hitStarts.clear();
00231 }

Here is the caller graph for this function:

int clearTable ( void   ) 

Definition at line 234 of file SSAHAWrapper.cpp.

References pHashTable.

Referenced by loadTable(), and main().

00235 {
00236   delete pHashTable;
00237   pHashTable = NULL;
00238 }

Here is the caller graph for this function:

int doSearch ( const char *const  pWords,
const int  numWords,
SSAHAHit **const  pHits,
int **const   pStarts 
)

Definition at line 163 of file SSAHAWrapper.cpp.

References clearSearch(), HashTablePackedCustom::convertHits(), SequenceEncoder::encode(), encoder, hitBuffer, hits, SequenceEncoder::linkSeq(), HashTableView< T, SUBCLASS >::matchWord(), pHashTable, HashTablePackedProtein::setQueryProtein(), and SequenceEncoder::unlinkSeq().

Referenced by main().

00169 {
00170   clearSearch();
00171   //  SequenceEncoderProtein encoder(wordLength, cerr);
00172   WordSequence w;
00173 
00174   encoder.linkSeq(w);
00175   encoder.encode(pWords, numWords*wordLength);
00176   encoder.unlinkSeq();
00177 
00178   if(w.empty())
00179   {
00180     hitStarts.push_back(-1);
00181     *pHits=NULL;
00182     *pStarts=&hitStarts[0];
00183     return -1;
00184   }
00185 
00186 
00187   if (isPacked)
00188   {
00189     HashTablePackedCustom* pTable
00190       = dynamic_cast<HashTablePackedCustom*>(pHashTable);
00191     assert(pTable!=NULL);
00192     pTable->setQueryProtein();
00193     for (WordSequence::iterator i(w.begin());i!=&w.back();i++)
00194     {
00195       //    cout << "got: " << printResidue(*i, wordLength) << endl;
00196       hitBuffer.clear();
00197       pTable->matchWord( *i, hitBuffer );
00198       //    pHashTable->convertHits( hitBuffer, hits );
00199       pTable->convertHits();
00200       hitStarts.push_back(hits.size());
00201     }
00202   } // ~for
00203   else
00204   {
00205     HashTableFred* pTable
00206       = dynamic_cast<HashTableFred*>(pHashTable);
00207     assert(pTable!=NULL);
00208     //    int n(hits.size());
00209     for (WordSequence::iterator i(w.begin());i!=&w.back();i++)
00210     {
00211       pTable->matchWord( *i, hits );
00212     }
00213     hitStarts.push_back(hits.size());
00214   }
00215 
00216 
00217   //  hits.push_back();
00218   //  hits.back().seqNum=1103; hits.back().seqPos=-1103;
00219   //  hitStarts.push_back(1);
00220   hitStarts.push_back(-1);
00221   *pHits=&hits[0];
00222   *pStarts=&hitStarts[0];
00223   return 0;
00224 }

Here is the call graph for this function:

Here is the caller graph for this function:

const char* getSubjectName ( unsigned int  seqNum  ) 

Definition at line 134 of file SSAHAWrapper.cpp.

References HashTableGeneric::getSequenceName(), and pHashTable.

Referenced by main().

00135 {
00136   return pHashTable->getSequenceName( seqNum );
00137 } // ~const char* getSubjectName( unsigned int seqNum )

Here is the call graph for this function:

Here is the caller graph for this function:

int loadTable ( const char *const  tableName  ) 

Definition at line 141 of file SSAHAWrapper.cpp.

References clearSearch(), clearTable(), HashTableGeneric::getWordLength(), HashTablePackedCustom::HashTablePackedCustom(), HashTableGeneric::loadHashTable(), pHashTable, and HashTableGeneric::setMaxNumHits().

Referenced by main().

00142 {
00143   clearSearch();
00144   clearTable();
00145 
00146   if (isPacked)
00147   {
00148     pHashTable = new HashTablePackedCustom( cerr, (string)tableName);
00149   }
00150   else
00151   {
00152     pHashTable = new HashTableFred( cerr, (string)tableName);
00153   }
00154 
00155   pHashTable->loadHashTable(); 
00156   // will throw exception if fails, eg if trying to load wrong table
00157   assert(pHashTable->getWordLength()==wordLength);
00158   pHashTable->setMaxNumHits( 100000000 );
00159 }

Here is the call graph for this function:

Here is the caller graph for this function:

static HashTableGeneric* pHashTable ( NULL   )  [static]


Variable Documentation

SequenceEncoderProtein encoder(wordLength, cerr) [static]

Referenced by doSearch(), fillSequenceReaderMulti(), findSequenceReader(), and main().

PackedHitStore hitBuffer [static]

Definition at line 68 of file SSAHAWrapper.cpp.

Referenced by HashTablePackedCustom::convertHits(), and doSearch().

CustomHitStore hits [static]

Definition at line 66 of file SSAHAWrapper.cpp.

Referenced by clearSearch(), HashTablePackedCustom::convertHits(), doSearch(), main(), HashTablePacked::matchSequenceRepeated(), and HashTable::matchSequenceRepeated().

vector<int> hitStarts [static]

Definition at line 69 of file SSAHAWrapper.cpp.

bool isPacked = false [static]

Definition at line 70 of file SSAHAWrapper.cpp.

const int wordLength = 5 [static]

Definition at line 64 of file SSAHAWrapper.cpp.

Referenced by QueryManager::doQuery(), main(), MatchAlgorithm::operator()(), and WordSequenceShifted::WordSequenceShifted().


Generated on Fri Dec 21 13:13:08 2007 for ssaha by  doxygen 1.5.2