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() {
index->finish_building();
}
void Germline::new_index()
void Germline::new_index(IndexTypes type)
{
assert(! seed.empty());
bool rc = true ;
index = new PointerACAutomaton<KmerAffect>(seed, rc);
index = KmerStoreFactory<KmerAffect>::createIndex(type, seed, rc);
index->refs = 1;
update_index();
......@@ -192,7 +192,6 @@ void Germline::mark_as_ambiguous(Germline *other)
index->insert(other->rep_3, AFFECT_AMBIGUOUS_SYMBOL, -max_indexing, seed);
}
void Germline::override_rep5_rep3_from_labels(KmerAffect left, KmerAffect right)
{
rep_5 = index->getLabel(left);
......@@ -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;
one_index_per_germline = _one_index_per_germline;
......@@ -251,7 +250,7 @@ void MultiGermline::insert(Germline *germline)
void MultiGermline::add_germline(Germline *germline)
{
if (one_index_per_germline)
germline->new_index();
germline->new_index(indexType);
germlines.push_back(germline);
}
......@@ -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 */
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
void MultiGermline::build_with_one_index(string seed, bool set_index)
{
bool rc = true ;
index = new PointerACAutomaton<KmerAffect>(seed, rc);
index = KmerStoreFactory<KmerAffect>::createIndex(indexType, seed, rc);
insert_in_one_index(index, set_index);
}
......
......@@ -6,9 +6,11 @@
#include <list>
#include "kmeraffect.h"
#include "kmerstore.h"
#include "automaton.hpp"
#include "stats.h"
#include "tools.h"
#include "../lib/json.hpp"
#include "kmerstorefactory.hpp"
enum SEGMENTATION_METHODS {
SEG_METHOD_53, // Regular or incomplete germlines, 5'-3'
......@@ -80,7 +82,7 @@ class Germline {
*/
void finish();
void new_index();
void new_index(IndexTypes type);
void set_index(IKmerStore<KmerAffect> *index);
void update_index(IKmerStore<KmerAffect> *_index = NULL);
......@@ -114,7 +116,6 @@ class Germline {
int delta_min;
};
ostream &operator<<(ostream &out, const Germline &germline);
......@@ -125,7 +126,7 @@ enum GERMLINES_FILTER { GERMLINES_ALL,
class MultiGermline {
private:
IndexTypes indexType;
public:
bool one_index_per_germline;
list <Germline*> germlines;
......@@ -133,7 +134,7 @@ class MultiGermline {
// A unique index can be used
IKmerStore<KmerAffect> *index;
MultiGermline(bool one_index_per_germline = true);
MultiGermline(IndexTypes indexType, bool one_index_per_germline = true);
~MultiGermline();
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