Commit 8dd80181 authored by Mikaël Salson's avatar Mikaël Salson

Tools: Use nuc_to_int instead of switch/case

parent b73346fd
......@@ -199,16 +199,7 @@ void OnlineFasta::next() {
current.seq = new int[current.sequence.length()];
for (int i=0; i< current.sequence.length(); i++)
{
int B ;
switch(current.sequence[i]) {
case 'A': B = 0; break;
case 'C': B = 1; break;
case 'G': B = 2; break;
case 'T': B = 3; break;
default:
B = 4; break;
}
current.seq[i] = B ;
current.seq[i] = nuc_to_int(current.sequence[i]) ;
}
} else
......
......@@ -241,16 +241,7 @@ vector<T> ArrayKmerStore<T>::getResults(const seqtype &seq, bool no_revcomp) {
int* intseq = new int[N];
for (int i=0; i<N; i++)
{
int B ;
switch(seq[i]) {
case 'A': B = 0; break;
case 'C': B = 1; break;
case 'G': B = 2; break;
case 'T': B = 3; break;
default:
B = 0; break;
}
intseq[i] = B ;
intseq[i] = nuc_to_int(seq[i]);
}
/* Compute results */
......@@ -351,14 +342,7 @@ template <class T>
int ArrayKmerStore<T>::index(const seqtype& word) const{
int index_word = 0;
for(int i = 0 ; i < this->k ; i++){
int B = 0;
switch(word[i]){
case 'A': B = 0; break;
case 'C': B = 1; break;
case 'G': B = 2; break;
case 'T': B = 3; break;
}
index_word = (index_word << 2) | B;
index_word = (index_word << 2) | nuc_to_int(word[i]);
}
return index_word;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment