Commit 62454e6a authored by Cyprien Borée's avatar Cyprien Borée
Browse files

Store pair attribute in Filter class and change methods

Since the pair attribute is stored in the Filter class, there is no need
to put a pair object in the Filter methods. The methods were changed to use
the object attribute, instead of the parameter.

For more informations see #3283.
parent 6301a234
......@@ -8,8 +8,8 @@ FilterWithACAutomaton::~FilterWithACAutomaton(){
}
void FilterWithACAutomaton::buildACAutomatonToFilterBioReader
(BioReader &origin, string seed){
pair<vector<int>*, AbstractACAutomaton<KmerAffect>*>* result;
vector<int>* indexes;
PointerACAutomaton<KmerAffect>* aho;
char asciiChar;
......@@ -18,9 +18,10 @@ FilterWithACAutomaton::~FilterWithACAutomaton(){
string previousLabel;
if(origin.size() < 1){
return nullptr;
p = nullptr;
return;
}
result = new pair<vector<int>*,AbstractACAutomaton<KmerAffect>*>();
p = new pair<vector<int>*,AbstractACAutomaton<KmerAffect>*>();
aho = new PointerACAutomaton<KmerAffect>(seed, false, true);
indexes = new vector<int>();
aho->insert(origin.sequence(0),std::string("") + char(1), true, 0, seed);
......@@ -35,8 +36,9 @@ FilterWithACAutomaton::~FilterWithACAutomaton(){
asciiNumber++;
}
if(asciiNumber > 127){
delete result; delete aho; delete indexes;
return nullptr;
delete p; delete aho; delete indexes;
p = nullptr;
return;
}
asciiChar = char(asciiNumber);
aho->insert(origin.sequence(i),std::string("") + asciiChar, true, 0, seed);
......@@ -44,9 +46,8 @@ FilterWithACAutomaton::~FilterWithACAutomaton(){
}
indexes->push_back(origin.size());
aho->build_failure_functions();
result->first = indexes;
result->second = aho;
return result;
p->first = indexes;
p->second = aho;
}
/*
......@@ -54,7 +55,6 @@ FilterWithACAutomaton::~FilterWithACAutomaton(){
based on it.
*/
BioReader FilterWithACAutomaton::filterBioReaderWithACAutomaton(
pair<vector<int>*, AbstractACAutomaton<KmerAffect>*>* idxAho,
BioReader &origin, seqtype &seq,
int kmer_threshold){
......@@ -65,11 +65,11 @@ BioReader FilterWithACAutomaton::filterBioReaderWithACAutomaton(
KmerAffect tmpKmer;
unsigned int asciiNum;
char asciiChar;
if(!idxAho || kmer_threshold < 0){
if(!p || kmer_threshold < 0){
return origin;
}
indexes = idxAho->first;
aho = idxAho->second;
indexes = p->first;
aho = p->second;
mapAho = aho->getMultiResults(seq);
//All k-mers selected : iterate over all map
......
......@@ -4,6 +4,9 @@
#include "automaton.hpp"
class FilterWithACAutomaton {
private:
pair<vector<int>*, AbstractACAutomaton<KmerAffect>*>* p;
public:
FilterWithACAutomaton(BioReader &origin, string seed);
~FilterWithACAutomaton();
......@@ -27,7 +30,6 @@ class FilterWithACAutomaton {
significant K-mers returned by getMultiResults.
*/
BioReader filterBioReaderWithACAutomaton(
pair<vector<int>*, AbstractACAutomaton<KmerAffect>*>* idxAho,
BioReader &origin, seqtype &seq,
int kmer_threshold = NO_LIMIT_VALUE);
/*
......@@ -78,7 +80,6 @@ class FilterWithACAutomaton {
The param "seed" is used while inserting sequences in the automaton. By default
the seed has a size of 10.
*/
pair<vector<int>*, AbstractACAutomaton<KmerAffect>*>*
buildACAutomatonToFilterBioReader(BioReader &origin, string seed);
void buildACAutomatonToFilterBioReader(BioReader &origin, string seed);
};
#endif
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