Commit 74b4f961 authored by Mathieu Giraud's avatar Mathieu Giraud

core/filter.{h,cpp}: uses KmerStringAffect

parent b520bcb7
......@@ -27,7 +27,7 @@ void FilterWithACAutomaton::buildACAutomatonToFilterBioReader(string seed, float
indexes = nullptr;
return;
}
automaton = new PointerACAutomaton<KmerAffect>(seed, false, true);
automaton = new PointerACAutomaton<KmerStringAffect>(seed, false, true);
indexes = new vector<int>();
asciiNumber = SPECIFIC_KMERS_NUMBER;
automaton->insert(originalBioReader.sequence(0),std::string("") + char(asciiNumber), true, 0, seed);
......@@ -72,7 +72,7 @@ BioReader FilterWithACAutomaton::filterBioReaderWithACAutomaton(
seqtype &seq, int kmer_threshold, int pvalue){
BioReader result;
map<KmerAffect, int> mapAho;
map<KmerStringAffect, int> mapAho;
this->filtered_sequences_calls += 1;
if(!automaton || !indexes || kmer_threshold < 0){
this->filtered_sequences_nb += originalBioReader.size();
......@@ -110,17 +110,17 @@ BioReader FilterWithACAutomaton::filterBioReaderWithACAutomaton(
sorted map */
}else{
/* sort map */
using Comparator = bool (*) (pair<KmerAffect, int>, pair<KmerAffect, int>);
Comparator compFunctor = [](pair<KmerAffect, int> elem1 ,pair<KmerAffect, int> elem2){
using Comparator = bool (*) (pair<KmerStringAffect, int>, pair<KmerStringAffect, int>);
Comparator compFunctor = [](pair<KmerStringAffect, int> elem1 ,pair<KmerStringAffect, int> elem2){
return (elem1.second == elem2.second) ? elem1.first > elem2.first : elem1.second > elem2.second;
};
// Use a set to use the comparator and sort function
set<pair<KmerAffect, int>, Comparator> setOfWords(mapAho.begin(), mapAho.end(), compFunctor);
set<pair<KmerStringAffect, int>, Comparator> setOfWords(mapAho.begin(), mapAho.end(), compFunctor);
// Iterate over the pair and not the map
int nbKmers = 0;
int nb_kmers_limit = -1; // Limit number of kmers, defined when the last gene of interest is reached
for(pair<KmerAffect, int> element : setOfWords){
for(pair<KmerStringAffect, int> element : setOfWords){
// Add corresponding sequences to the BioReader
if(!element.first.isGeneric()){
continue;
......@@ -149,7 +149,7 @@ BioReader FilterWithACAutomaton::filterBioReaderWithACAutomaton(
return (result.size() == 0) ? originalBioReader : result;
}
void FilterWithACAutomaton::transferBioReaderSequences(const BioReader &src, BioReader &dst, KmerAffect k) const{
void FilterWithACAutomaton::transferBioReaderSequences(const BioReader &src, BioReader &dst, KmerStringAffect k) const{
char asciiChar = k.getLabel().at(0);
unsigned int asciiNum = int(asciiChar);
......@@ -161,7 +161,7 @@ void FilterWithACAutomaton::transferBioReaderSequences(const BioReader &src, Bio
}
}
int FilterWithACAutomaton::getSizeLongestTransferredSequence(const BioReader &reader, KmerAffect k) const{
int FilterWithACAutomaton::getSizeLongestTransferredSequence(const BioReader &reader, KmerStringAffect k) const{
char asciiChar = k.getLabel().at(0);
unsigned int asciiNum = int(asciiChar);
......@@ -181,7 +181,7 @@ vector<int>* FilterWithACAutomaton::getIndexes() const{
return this->indexes;
}
AbstractACAutomaton<KmerAffect>* FilterWithACAutomaton::getAutomaton() const{
AbstractACAutomaton<KmerStringAffect>* FilterWithACAutomaton::getAutomaton() const{
return this->automaton;
}
......
......@@ -8,7 +8,7 @@ class FilterWithACAutomaton {
private:
vector<int>* indexes;
AbstractACAutomaton<KmerAffect>* automaton;
AbstractACAutomaton<KmerStringAffect>* automaton;
public:
BioReader &originalBioReader;
......@@ -26,9 +26,9 @@ class FilterWithACAutomaton {
/**
This function will filter a BioReader
@param idxAho: A pointer to a pair containing an int vector pointer and
an AbstractACAutomaton pointer parametrized by KmerAffect.
an AbstractACAutomaton pointer parametrized by KmerStringAffect.
The int vector represents indexes of a BioReader and the
automaton is build with single char labels put in KmerAffect.
automaton is build with single char labels put in KmerStringAffect.
To know more about them, read doc of
buildACAutomatonToFilterBioReader function.
......@@ -103,7 +103,7 @@ class FilterWithACAutomaton {
/**
* Return the automaton stored.
*/
AbstractACAutomaton<KmerAffect>* getAutomaton() const;
AbstractACAutomaton<KmerStringAffect>* getAutomaton() const;
/**
......@@ -114,7 +114,7 @@ class FilterWithACAutomaton {
* The label stored in the K-mer is used to select sequences. For more informations
* about how the label is used, see buildACAutomatonToFilterBioReader's doc.
*/
void transferBioReaderSequences(const BioReader &src, BioReader &dst, const KmerAffect k) const;
void transferBioReaderSequences(const BioReader &src, BioReader &dst, const KmerStringAffect k) const;
friend ostream &operator<<(ostream&, const FilterWithACAutomaton&);
......@@ -123,6 +123,6 @@ class FilterWithACAutomaton {
* Get the size of the longest sequence among the sequences that were just
* transferred to the BioReader reader.
*/
int getSizeLongestTransferredSequence(const BioReader &reader, KmerAffect k) const;
int getSizeLongestTransferredSequence(const BioReader &reader, KmerStringAffect k) const;
};
#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