Commit 142e66c7 authored by Mikaël Salson's avatar Mikaël Salson

Germline: Add the possibility to finish() them.

As indexes can be finish()-ed, we must add that possibility for germlines too
parent 46538a57
......@@ -150,6 +150,11 @@ Germline::Germline(string code, char shortcut, string path, json json_recom,
seg_method = SEG_METHOD_543 ;
}
void Germline::finish() {
if (index)
index->finish_building();
}
void Germline::new_index()
{
assert(! seed.empty());
......@@ -315,6 +320,16 @@ void MultiGermline::build_with_one_index(string seed, bool set_index)
insert_in_one_index(index, set_index);
}
void MultiGermline::finish() {
if (index) {
index->finish_building();
} else {
for (auto germline: germlines) {
germline->finish();
}
}
}
/* Mark k-mers common to several germlines as ambiguous */
void MultiGermline::mark_cross_germlines_as_ambiguous()
{
......
......@@ -75,6 +75,11 @@ class Germline {
*/
string seed;
/**
* Finishes the construction of the germline so that it can be used
*/
void finish();
void new_index();
void set_index(IKmerStore<KmerAffect> *index);
......@@ -135,6 +140,10 @@ class MultiGermline {
void add_germline(Germline *germline);
void build_from_json(string path, string json_filename, int filter, int max_indexing);
/**
* Finishes the construction of the multi germline so that it can be used
*/
void finish();
// Creates and update an unique index for all the germlines
// If 'set_index' is set, set this index as the index for all germlines
void insert_in_one_index(IKmerStore<KmerAffect> *_index, bool set_index);
......
......@@ -99,7 +99,7 @@ public:
* that function, we are not supposed to insert any other sequence.
* No query function should be called before calling that function.
*/
void finish_building();
virtual void finish_building();
/**
* @param word: a k-mer
......
......@@ -15,6 +15,7 @@ void testSegmentationBug1(int delta_min, int delta_max) {
Germline *germline ;
germline = new Germline("custom", 'x', seqV, seqV, seqJ, delta_min, "##############");
germline->new_index();
germline->finish();
OnlineFasta input(buggy_sequences);
......
......@@ -54,6 +54,7 @@ void testFineSegment()
Germline *germline ;
germline = new Germline("IGH", 'G', seqV, seqD, seqJ, 0, "########");
germline->new_index();
germline->finish();
Sequence seq = data.getSequence();
......@@ -110,6 +111,9 @@ void testSegmentOverlap()
germline2 = new Germline("TRG2", 'G', seqV, Fasta(), seqJ, -50, "##########");
germline2->new_index();
germline1->finish();
germline2->finish();
for (int i = 0; i < data.size(); i++) {
KmerSegmenter ks(data.read(i), germline1);
......@@ -138,6 +142,7 @@ void testSegmentationCause() {
Germline *germline ;
germline = new Germline("TRG", 'G', seqV, Fasta(), seqJ, 0, "##########");
germline->new_index();
germline->finish();
int nb_checked = 0;
......@@ -254,6 +259,7 @@ void testExtractor() {
MultiGermline *multi ;
multi = new MultiGermline();
multi->insert(germline);
multi->finish();
WindowExtractor we(multi);
map<string, string> labels;
......@@ -330,6 +336,7 @@ void testProbability() {
}
Germline germline("Test", 'T', V, Fasta(), J, 0, "####");
germline.new_index();
germline.finish();
TAP_TEST(germline.index->getIndexLoad() == .75, TEST_GET_INDEX_LOAD, "");
......
......@@ -921,7 +921,8 @@ int main (int argc, char **argv)
if (multi_germline_mark)
multigermline->mark_cross_germlines_as_ambiguous();
multigermline->finish();
cout << "Germlines loaded" << endl ;
cout << *multigermline ;
cout << endl ;
......
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