Commit 167a3575 authored by Mikaël Salson's avatar Mikaël Salson

Germline: Any type of index can be created using IndexTypes.

Allows to build any type of index instead of relying on one specific type.
parent 08df07f4
...@@ -155,12 +155,12 @@ void Germline::finish() { ...@@ -155,12 +155,12 @@ void Germline::finish() {
index->finish_building(); index->finish_building();
} }
void Germline::new_index() void Germline::new_index(IndexTypes type)
{ {
assert(! seed.empty()); assert(! seed.empty());
bool rc = true ; bool rc = true ;
index = new PointerACAutomaton<KmerAffect>(seed, rc); index = KmerStoreFactory<KmerAffect>::createIndex(type, seed, rc);
index->refs = 1; index->refs = 1;
update_index(); update_index();
...@@ -192,7 +192,6 @@ void Germline::mark_as_ambiguous(Germline *other) ...@@ -192,7 +192,6 @@ void Germline::mark_as_ambiguous(Germline *other)
index->insert(other->rep_3, AFFECT_AMBIGUOUS_SYMBOL, -max_indexing, seed); index->insert(other->rep_3, AFFECT_AMBIGUOUS_SYMBOL, -max_indexing, seed);
} }
void Germline::override_rep5_rep3_from_labels(KmerAffect left, KmerAffect right) void Germline::override_rep5_rep3_from_labels(KmerAffect left, KmerAffect right)
{ {
rep_5 = index->getLabel(left); rep_5 = index->getLabel(left);
...@@ -230,7 +229,7 @@ ostream &operator<<(ostream &out, const Germline &germline) ...@@ -230,7 +229,7 @@ ostream &operator<<(ostream &out, const Germline &germline)
} }
MultiGermline::MultiGermline(bool _one_index_per_germline) MultiGermline::MultiGermline(IndexTypes indexType, bool _one_index_per_germline):indexType(indexType)
{ {
index = NULL; index = NULL;
one_index_per_germline = _one_index_per_germline; one_index_per_germline = _one_index_per_germline;
...@@ -251,7 +250,7 @@ void MultiGermline::insert(Germline *germline) ...@@ -251,7 +250,7 @@ void MultiGermline::insert(Germline *germline)
void MultiGermline::add_germline(Germline *germline) void MultiGermline::add_germline(Germline *germline)
{ {
if (one_index_per_germline) if (one_index_per_germline)
germline->new_index(); germline->new_index(indexType);
germlines.push_back(germline); germlines.push_back(germline);
} }
...@@ -300,7 +299,6 @@ void MultiGermline::build_from_json(string path, string json_filename, int filte ...@@ -300,7 +299,6 @@ void MultiGermline::build_from_json(string path, string json_filename, int filte
} }
/* if 'one_index_per_germline' was not set, this should be called once all germlines have been loaded */ /* if 'one_index_per_germline' was not set, this should be called once all germlines have been loaded */
void MultiGermline::insert_in_one_index(IKmerStore<KmerAffect> *_index, bool set_index) void MultiGermline::insert_in_one_index(IKmerStore<KmerAffect> *_index, bool set_index)
{ {
...@@ -321,7 +319,7 @@ void MultiGermline::insert_in_one_index(IKmerStore<KmerAffect> *_index, bool set ...@@ -321,7 +319,7 @@ void MultiGermline::insert_in_one_index(IKmerStore<KmerAffect> *_index, bool set
void MultiGermline::build_with_one_index(string seed, bool set_index) void MultiGermline::build_with_one_index(string seed, bool set_index)
{ {
bool rc = true ; bool rc = true ;
index = new PointerACAutomaton<KmerAffect>(seed, rc); index = KmerStoreFactory<KmerAffect>::createIndex(indexType, seed, rc);
insert_in_one_index(index, set_index); insert_in_one_index(index, set_index);
} }
......
...@@ -6,9 +6,11 @@ ...@@ -6,9 +6,11 @@
#include <list> #include <list>
#include "kmeraffect.h" #include "kmeraffect.h"
#include "kmerstore.h" #include "kmerstore.h"
#include "automaton.hpp"
#include "stats.h" #include "stats.h"
#include "tools.h" #include "tools.h"
#include "../lib/json.hpp" #include "../lib/json.hpp"
#include "kmerstorefactory.hpp"
enum SEGMENTATION_METHODS { enum SEGMENTATION_METHODS {
SEG_METHOD_53, // Regular or incomplete germlines, 5'-3' SEG_METHOD_53, // Regular or incomplete germlines, 5'-3'
...@@ -80,7 +82,7 @@ class Germline { ...@@ -80,7 +82,7 @@ class Germline {
*/ */
void finish(); void finish();
void new_index(); void new_index(IndexTypes type);
void set_index(IKmerStore<KmerAffect> *index); void set_index(IKmerStore<KmerAffect> *index);
void update_index(IKmerStore<KmerAffect> *_index = NULL); void update_index(IKmerStore<KmerAffect> *_index = NULL);
...@@ -114,7 +116,6 @@ class Germline { ...@@ -114,7 +116,6 @@ class Germline {
int delta_min; int delta_min;
}; };
ostream &operator<<(ostream &out, const Germline &germline); ostream &operator<<(ostream &out, const Germline &germline);
...@@ -125,7 +126,7 @@ enum GERMLINES_FILTER { GERMLINES_ALL, ...@@ -125,7 +126,7 @@ enum GERMLINES_FILTER { GERMLINES_ALL,
class MultiGermline { class MultiGermline {
private: private:
IndexTypes indexType;
public: public:
bool one_index_per_germline; bool one_index_per_germline;
list <Germline*> germlines; list <Germline*> germlines;
...@@ -133,7 +134,7 @@ class MultiGermline { ...@@ -133,7 +134,7 @@ class MultiGermline {
// A unique index can be used // A unique index can be used
IKmerStore<KmerAffect> *index; IKmerStore<KmerAffect> *index;
MultiGermline(bool one_index_per_germline = true); MultiGermline(IndexTypes indexType, bool one_index_per_germline = true);
~MultiGermline(); ~MultiGermline();
void insert(Germline *germline); void insert(Germline *germline);
......
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