ARB
MP_GenerationDuplicates.cxx
Go to the documentation of this file.
1 // ============================================================= //
2 // //
3 // File : MP_GenerationDuplicates.cxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // ============================================================= //
10 
11 #include "MP_probe.hxx"
12 #include "MultiProbe.hxx"
13 
14 bool GenerationDuplicates::insert(probe_combi_statistic *sondenkombi, bool &result, int depth) { // initial muss result true sein
15  int max_depth = mp_gl_awars.no_of_probes;
16 
17  if (depth == max_depth) {
18  result = false;
19  return false;
20  }
21 
22  if (! next[sondenkombi->get_probe_combi(depth)->probe_index]) { // sonde muss auf alle Faelle bis zuletzt eingetragen werden
23  if (depth == max_depth-1) {
24  next[sondenkombi->get_probe_combi(depth)->probe_index] = new GenerationDuplicates(1);
25  next_mism[sondenkombi->get_probe_combi(depth)->allowed_mismatches] = 1;
26  return true;
27  }
28  else {
29  next[sondenkombi->get_probe_combi(depth)->probe_index] = new GenerationDuplicates(intern_size);
30  next_mism[sondenkombi->get_probe_combi(depth)->allowed_mismatches] = 1;
31  return next[sondenkombi->get_probe_combi(depth)->probe_index]->insert(sondenkombi, result, depth+1);
32  }
33  }
34 
35  result = result && next_mism[sondenkombi->get_probe_combi(depth)->allowed_mismatches];
36  next[sondenkombi->get_probe_combi(depth)->probe_index]->insert(sondenkombi, result, depth+1); // man kann erst ganz unten entscheiden, ob doppelt oder nicht
37  return result;
38 }
39 
40 GenerationDuplicates::GenerationDuplicates(int size) { // size muss die Groesse des Sondenarrays in ProbeValuation enthalten
41  intern_size = size;
42  next = new GenerationDuplicates*[size];
43  next_mism = new int[MAXMISMATCHES];
44  memset(next_mism, 0, MAXMISMATCHES * sizeof(int));
45  memset(next, 0, size * sizeof(GenerationDuplicates*));
46 }
47 
49  for (int i=0; i<intern_size; i++)
50  delete next[i];
51 
52  delete [] next_mism;
53  delete next;
54 }
string result
int probe_index
Definition: MP_probe.hxx:16
int allowed_mismatches
Definition: MP_probe.hxx:17
bool insert(probe_combi_statistic *sondenkombi, bool &result, int depth=0)
#define MAXMISMATCHES
Definition: MultiProbe.hxx:66
probe * get_probe_combi(int j)
Definition: MP_probe.hxx:64
long no_of_probes
Definition: MultiProbe.hxx:96
awar_vars mp_gl_awars
Definition: MP_main.cxx:23