forked from soedinglab/MMseqs2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Indexer.cpp
44 lines (34 loc) · 1.06 KB
/
Indexer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Indexer.h"
#include "Debug.h"
Indexer::Indexer(const size_t alphabetSize, const int maxKmerSize){
this->maxKmerSize = maxKmerSize;
this->powers = new size_t[maxKmerSize];
this->alphabetSize = alphabetSize;
size_t pow = 1;
for( int i=0; i<maxKmerSize; ++i ){
this->powers[i] = pow;
pow *= alphabetSize;
}
this->maxKmerIndex = 0;
for( int i=0; i<maxKmerSize; ++i ){
this->maxKmerIndex += alphabetSize*this->powers[i];
}
this->lastKmerIndex = this->maxKmerIndex;
workspace = new size_t[100];
}
Indexer::~Indexer(){
delete[] this->powers;
delete[] workspace;
}
void Indexer::reset(){
this->lastKmerIndex = this->maxKmerIndex;
}
void Indexer::printKmer(size_t kmerIdx, int kmerSize, char* int2aa){
index2int(workspace, kmerIdx, kmerSize);
for (int j = 0; j < kmerSize; j++)
Debug(Debug::INFO) << int2aa[workspace[j]];
}
void Indexer::printKmer(const int* kmer, int kmerSize, char* int2aa){
for (int j = 0; j < kmerSize; j++)
Debug(Debug::INFO) << int2aa[kmer[j]];
}