Commit d43c6c96 authored by Mathieu Giraud's avatar Mathieu Giraud

core/germlines.{h,cpp}: put index handling into Germline.new_index() and Germline.use_index()

We can now create a Germline object without any index.
parent 89f07621
......@@ -3,11 +3,14 @@
Germline::Germline(string _code, char _shortcut,
string f_rep_5, string f_rep_4, string f_rep_3,
string seed,
int _delta_min, int _delta_max)
{
code = _code ;
shortcut = _shortcut ;
index = 0 ;
affect_5 = "V" ;
affect_3 = "J" ;
rep_5 = Fasta(f_rep_5, 2, "|", cout);
rep_4 = Fasta(f_rep_4, 2, "|", cout);
......@@ -16,22 +19,22 @@ Germline::Germline(string _code, char _shortcut,
delta_min = _delta_min ;
delta_max = _delta_max ;
build_index(seed);
stats.setLabel(code);
}
Germline::Germline(string _code, char _shortcut,
Fasta _rep_5, Fasta _rep_4, Fasta _rep_3,
string seed,
int _delta_min, int _delta_max)
{
code = _code ;
shortcut = _shortcut ;
index = 0 ;
// affect_5 = KmerAffect("", "V", 0) ;
// affect_3 = KmerAffect("", "J", 0) ;
affect_5 = "V" ;
affect_3 = "J" ;
rep_5 = _rep_5 ;
rep_4 = _rep_4 ;
......@@ -40,23 +43,36 @@ Germline::Germline(string _code, char _shortcut,
delta_min = _delta_min ;
delta_max = _delta_max ;
build_index(seed);
stats.setLabel(code);
}
void Germline::build_index(string seed)
void Germline::new_index(string seed)
{
bool rc = true ;
index = KmerStoreFactory::createIndex<KmerAffect>(seed, rc);
index->insert(rep_5, "V"); // affect_5);
index->insert(rep_3, "J"); // affect_3);
update_index();
}
void Germline::use_index(IKmerStore<KmerAffect> *_index)
{
index = _index;
update_index();
}
void Germline::update_index()
{
index->insert(rep_5, affect_5);
index->insert(rep_3, affect_3);
cout << " index " << index << " updated " << affect_5 << "/" << affect_3 << endl;
}
Germline::~Germline()
{
delete index;
if (index)
delete index;
}
ostream &operator<<(ostream &out, const Germline &germline)
......@@ -91,7 +107,6 @@ MultiGermline::MultiGermline(string f_germlines_json)
Germline *germline;
germline = new Germline("TRG", 'G',
rep_5, rep_4, rep_3,
seed,
delta_min, delta_max);
germlines.push_back(germline);
......@@ -111,8 +126,16 @@ void MultiGermline::insert(Germline *germline)
void MultiGermline::load_default_set(string path)
{
germlines.push_back(new Germline("TRG", 'G', path + "/TRGV.fa", "", path + "/TRGJ.fa", "#####-#####", -10, 20));
germlines.push_back(new Germline("IGH", 'H', path + "/IGHV.fa", path + "/IGHD.fa", path + "/IGHJ.fa", "######-######", 0, 80));
Germline *germline;
germline = new Germline("TRG", 'G', path + "/TRGV.fa", "", path + "/TRGJ.fa", -10, 20);
germline->new_index("#####-#####");
germlines.push_back(germline);
germline = new Germline("IGH", 'H', path + "/IGHV.fa", path + "/IGHD.fa", path + "/IGHJ.fa", 0, 80);
germline->new_index("######-######");
germlines.push_back(germline);
}
......
......@@ -12,7 +12,7 @@ using namespace std;
class Germline {
private:
void build_index(string seed);
void update_index();
public:
/*
......@@ -26,12 +26,10 @@ class Germline {
Germline(string _code, char _shortcut,
string f_rep_5, string f_rep_4, string f_rep_3,
string seed,
int _delta_min, int _delta_max);
Germline(string _code, char _shortcut,
Fasta _rep_5, Fasta _rep_4, Fasta _rep_3,
string seed,
int _delta_min, int _delta_max);
~Germline();
......@@ -39,9 +37,14 @@ class Germline {
string code ;
char shortcut ;
void new_index(string seed);
void use_index(IKmerStore<KmerAffect> *index);
// KmerAffect affect_5 ;
// KmerAffect affect_3 ;
string affect_5 ;
string affect_3 ;
Fasta rep_5 ;
Fasta rep_4 ;
Fasta rep_3 ;
......
......@@ -795,8 +795,9 @@ int main (int argc, char **argv)
Germline *germline;
germline = new Germline(germline_system, 'X',
rep_V, rep_D, rep_J, seed,
rep_V, rep_D, rep_J,
delta_min, delta_max);
germline->new_index(seed);
multigermline->insert(germline);
}
......@@ -1324,9 +1325,8 @@ int main (int argc, char **argv)
Germline *germline;
// Here, it could be run without building the index
germline = new Germline(germline_system, 'X',
rep_V, rep_D, rep_J, seed,
rep_V, rep_D, rep_J,
delta_min, delta_max);
while (reads->hasNext())
......
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