Commit e8ab3a56 authored by Mikaël Salson's avatar Mikaël Salson

Index: Put the ID in the base class

The ID was initialised in createIndex, but if it was not called,
the ID was not initialised. By transferring the initialisation to
the base constructor we ensure that the ID will be initialised.

The drawback is that classes that should be virtual now have a constructor.
parent b49a028c
......@@ -22,6 +22,8 @@ class AbstractACAutomaton: public IKmerStore<Info> {
protected:
void *initialState;
public:
AbstractACAutomaton();
/**
* Builds the failure functions. This function must be called before any
* query is made.
......
......@@ -5,6 +5,9 @@
//////////////////// IMPLEMENTATIONS ////////////////////
template <class Info>
AbstractACAutomaton<Info>::AbstractACAutomaton():IKmerStore<Info>() {}
template <class Info>
void AbstractACAutomaton<Info>::finish_building() {
build_failure_functions();
......@@ -37,17 +40,17 @@ size_t AbstractACAutomaton<Info>::smallestAnalysableLength() const {
///////////////////////
template <class Info>
PointerACAutomaton<Info>::PointerACAutomaton(bool revcomp){
PointerACAutomaton<Info>::PointerACAutomaton(bool revcomp):AbstractACAutomaton<Info>(){
init("##########",revcomp);
}
template <class Info>
PointerACAutomaton<Info>::PointerACAutomaton(string seed, bool revcomp) {
PointerACAutomaton<Info>::PointerACAutomaton(string seed, bool revcomp):AbstractACAutomaton<Info>() {
init(seed, revcomp);
}
template <class Info>
PointerACAutomaton<Info>::PointerACAutomaton(int k, bool revcomp) {
PointerACAutomaton<Info>::PointerACAutomaton(int k, bool revcomp):AbstractACAutomaton<Info>() {
init(seed_contiguous(k), revcomp);
}
......
......@@ -61,6 +61,8 @@ public:
list< pair <T, Fasta> > labels;
IKmerStore();
/**
* @param input: A single FASTA file
* @param label: label that must be associated to the given files
......@@ -173,6 +175,11 @@ public:
virtual T& operator[](seqtype& word) = 0;
};
template<class T>
IKmerStore<T>::IKmerStore() {
id = ++last_id;
}
template<class T> int IKmerStore<T>::last_id = 0;
template <class T>
......@@ -451,7 +458,7 @@ size_t IKmerStore<T>::smallestAnalysableLength() const {
// MapKmerStore
template <class T>
MapKmerStore<T>::MapKmerStore(string seed, bool revcomp){
MapKmerStore<T>::MapKmerStore(string seed, bool revcomp):IKmerStore<T>(){
this->seed = seed;
int k = seed_weight(seed);
this->k = k;
......@@ -461,7 +468,7 @@ MapKmerStore<T>::MapKmerStore(string seed, bool revcomp){
}
template <class T>
MapKmerStore<T>::MapKmerStore(int k, bool revcomp){
MapKmerStore<T>::MapKmerStore(int k, bool revcomp):IKmerStore<T>(){
this->seed = seed_contiguous(k);
this->k = k;
this->s = k;
......@@ -493,7 +500,7 @@ T& MapKmerStore<T>::operator[](seqtype& word){
// ArrayKmerStore
template <class T>
ArrayKmerStore<T>::ArrayKmerStore(int k, bool revcomp) {
ArrayKmerStore<T>::ArrayKmerStore(int k, bool revcomp):IKmerStore<T>() {
this->seed = seed_contiguous(k);
this->k = k;
this->s = k;
......@@ -503,7 +510,7 @@ ArrayKmerStore<T>::ArrayKmerStore(int k, bool revcomp) {
template <class T>
ArrayKmerStore<T>::ArrayKmerStore(string seed, bool revcomp){
ArrayKmerStore<T>::ArrayKmerStore(string seed, bool revcomp):IKmerStore<T>(){
this->seed = seed;
int k = seed_weight(seed);
this->k = k;
......@@ -580,8 +587,6 @@ IKmerStore<T> *KmerStoreFactory::createIndex(string seed, bool revcomp) {
index = new MapKmerStore<T>(seed, revcomp);
}
index->id = ++IKmerStore<T>::last_id;
return index;
}
......
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