ARB
MultiProbe.hxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : MultiProbe.hxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #ifndef MULTIPROBE_HXX
12 #define MULTIPROBE_HXX
13 
14 #ifndef SOTL_HXX
15 #include "SoTl.hxx"
16 #endif
17 #ifndef MPDEFS_H
18 #include "mpdefs.h"
19 #endif
20 #ifndef AW_AWAR_HXX
21 #include <aw_awar.hxx>
22 #endif
23 #ifndef AW_BASE_HXX
24 #include <aw_base.hxx>
25 #endif
26 #ifndef ARB_STRING_H
27 #include <arb_string.h>
28 #endif
29 
30 #define mp_assert(x) arb_assert(x)
31 
32 class MP_Main;
33 class MP_Window;
34 class AW_window;
35 class AW_root;
36 class AW_window_simple;
37 class TREE_canvas;
38 class ProbeValuation;
39 
40 struct ST_Container;
41 class Bitvector;
42 class Sonde;
43 
44 #define MP_AWAR_SEQIN "tmp/mp/seqin"
45 #define MP_AWAR_SELECTEDPROBES "mp/selectedprobes"
46 #define MP_AWAR_PROBELIST "mp/probelist"
47 #define MP_AWAR_WEIGHTEDMISMATCHES "mp/weightedmismatches"
48 #define MP_AWAR_COMPLEMENT "mp/complement"
49 #define MP_AWAR_MISMATCHES "mp/mismatches"
50 #define MP_AWAR_PTSERVER AWAR_PT_SERVER
51 #define MP_AWAR_LOADLIST "mp/loadlist"
52 #define MP_AWAR_RESULTPROBES "mp/resultprobes"
53 #define MP_AWAR_RESULTPROBESCOMMENT "mp/resultprobescomment"
54 #define MP_AWAR_NOOFPROBES "mp/noofprobes"
55 #define MP_AWAR_QUALITY "mp/quality"
56 #define MP_AWAR_SINGLEMISMATCHES "mp/singlemismatches"
57 #define MP_AWAR_OUTSIDEMISMATCHES "mp/outsidemismatches"
58 #define MP_AWAR_QUALITYBORDER1 "mp/qualityborder1"
59 #define MP_AWAR_GREYZONE "mp/greyzone"
60 #define MP_AWAR_EMPHASIS "mp/emphasis"
61 #define MP_AWAR_ECOLIPOS "mp/ecolipos"
62 #define MP_AWAR_AUTOADVANCE "mp/auto_advance"
63 
64 #define QUALITYDEFAULT 3
65 #define MAXPROBECOMBIS 6 // Maximale Anzahl der Sondenkombinationen
66 #define MAXMISMATCHES 6 // von 0 bis 5 !!!!
67 #define FITNESSSCALEFACTOR 10 // wird benutzt um intern die hammingtabelle feiner zu granulieren
68 // siehe probe_combi_statistic::calc_fitness
69 
70 #define MULTROULETTEFACTOR 10 // macht aus z.B. 4,231 42
71 #define MAXINITPOPULATION 50 // Ausgangsgroesse der Population
72 #define MAXPOPULATION MAXINITPOPULATION
73 #define CROSSOVER_WS 60 // Crossoverwahrscheinlichkeit liegt bei CROSSOVER_WS Prozent !!!
74 #define MUTATION_WS 33 // Mutationswahrscheinlichkeit liegt bei 1/MUTATION_WS Prozent!!!
75 #define SIGMATRUNCATION_CONST 2 // die Standardwerte liegen zwischen 1 und 3
76 #define C_MULT 1.4 // Werte zwischen 1.2 und 2.0
77 
78 // #define USE_SIGMATRUNCATION // definieren, wenn sigma_truncation in der linearen Skal. (=fitness skalierung) verwendet werden soll
79 // #define USE_LINEARSCALING // definieren, wenn lineare_skalierung (=fitness skalierung) verwendet werden soll
80 // #define USE_DUP_TREE // definieren, wenn eine Sondenkombination nur einmal pro generation vorkommen soll
81 
82 #define LIST(TYP) ((List<Sonde>*) TYP)
83 
84 #define MAXSONDENHASHSIZE 1000 // max 1000 Sonden koennen gecached werden, bei Bedarf aendern !!!!
85 
86 
87 struct awar_vars {
89  char *probelist;
94  long complement;
98  long ptserver;
101  long emphasis;
102  long ecolipos;
103  float min_weight;
104  float max_weight;
105  float greyzone;
106 };
107 
108 class AW_selection_list;
109 
111 extern char MP_probe_tab[256];
113 extern int remembered_mismatches;
114 extern int anz_elem_marked;
115 extern int anz_elem_unmarked;
116 extern unsigned char **hamming_tab;
117 extern int **system3_tab;
118 extern bool pt_server_different;
119 extern bool new_pt_server;
120 
121 long k_chosenFrom_n(int k, int n); // binomial coefficient
122 extern int get_random(int min, int max); // gibt eine Zufallszahl x mit der Eigenschaft : min <= x <= max
123 
124 // ********************************************************
125 
126 extern MP_Main *mp_main;
127 extern awar_vars mp_gl_awars; // globale Variable, die manuell eingegebene Sequenz enthaelt
128 
129 // ********************************************************
130 
131 
132 
133 class MP_Main : virtual Noncopyable {
134  MP_Window *mp_window;
135  AW_root *aw_root;
136  TREE_canvas *scr;
137  ST_Container *stc;
138  ProbeValuation *p_eval;
139 
140  void create_awars();
141 
142 public:
143  MP_Window *get_mp_window() { return mp_window; };
144  AW_root *get_aw_root() { return aw_root; };
145  TREE_canvas *get_canvas() { return scr; };
146  ProbeValuation *get_p_eval() { return p_eval; };
147  ST_Container *get_stc() { return stc; };
148  void set_stc(ST_Container *stopfC) { stc = stopfC; }
149  void set_p_eval (ProbeValuation *y) { p_eval = y; };
150  ProbeValuation *new_probe_eval(char **field, int size, int* array, int *mismatches);
151  void destroy_probe_eval();
152 
153  MP_Main(AW_root *awr, TREE_canvas *canvas);
154  ~MP_Main();
155 };
156 
157 
158 
159 class MP_Window : virtual Noncopyable {
160  AW_window_simple *aws;
161  AW_window_simple *result_window;
162 
163 public:
164  AW_window_simple *get_window() { return aws; };
165  AW_window_simple *get_result_window() { return result_window; };
166 
167  AW_window_simple *create_result_window(AW_root *aw_root);
168 
169  MP_Window(AW_root *aw_root, GBDATA *gb_main);
170  ~MP_Window();
171 };
172 
173 
174 
175 // *****************************************************
176 // Globale Klassenlose Funktionen
177 // *****************************************************
179 
180 
181 class Bakt_Info : virtual Noncopyable {
182  char* name;
183  long hit_flag;
184 
185 public:
186  char* get_name() { return name; };
187  long inc_hit_flag() { return ++hit_flag; };
188  long get_hit_flag() { return hit_flag; };
189  void kill_flag() { hit_flag = 0; };
190 
191  Bakt_Info(const char* n);
192  ~Bakt_Info();
193 };
194 
195 class Hit : virtual Noncopyable {
196  double *mismatch;
197  long baktid;
198 
199 public:
200  double* get_mismatch() { return mismatch; };
201  long get_baktid() { return baktid; };
202  void set_mismatch_at_pos(int pos, double mm) { mismatch[pos] = mm; };
203  double get_mismatch_at_pos(int pos) { return mismatch[pos]; };
204 
205  Hit(long baktnummer);
206  ~Hit();
207 };
208 
209 
210 class probe_tabs;
211 
212 class Sondentopf : virtual Noncopyable {
213  List<void*> *Listenliste; // @@@ change type to List<Sonde> ?
214  GB_HASH *color_hash;
215  MO_Liste *BaktList;
216  MO_Liste *Auswahllist;
217 
218 public:
220  double** gen_Mergefeld();
221  void put_Sonde(char *name, int allowed_mis, double outside_mis);
222  long get_length_hitliste();
223  void gen_color_hash(positiontype anz_sonden);
224  GB_HASH *get_color_hash() { return color_hash; };
225 
226  Sondentopf(MO_Liste *BL, MO_Liste *AL);
227  ~Sondentopf();
228 };
229 
230 class Sonde : virtual Noncopyable {
231  char* kennung; // Nukleinsaeuren, z.B. "atgatgatg"
232  Bitvector* bitkennung; // Sonde 1 Platz eins, ...zwei..., ... Analog zum Aufbau der Listenliste
233  Hit **hitliste; // start bei index 0, letztes element enthaelt NULp
234  long length_hitliste;
235  long minelem;
236  long maxelem;
237  positiontype kombi_far, kombi_mor;
238  long *Allowed_Mismatch;
239  double *Outside_Mismatch;
240 
241 public:
242  double get_Allowed_Mismatch_no(int no) { return (Allowed_Mismatch) ? Allowed_Mismatch[no] : 100; };
243  double get_Outside_Mismatch_no(int no) { return (Outside_Mismatch) ? Outside_Mismatch[no] : 100; };
244  char* get_name() { return kennung; };
245  Hit* get_hitdata_by_number(long index);
246  Hit** get_Hitliste() { return hitliste; };
247  long get_length_hitliste() { return length_hitliste; };
248  long get_minelem() { return minelem; };
249  long get_maxelem() { return maxelem; };
250  positiontype get_far() { return kombi_far; };
251  positiontype get_mor() { return kombi_mor; };
252  Bitvector* get_bitkennung() { return bitkennung; };
253 
254  void set_Allowed_Mismatch_no(int pos, int no) { Allowed_Mismatch[pos] = no; };
255  void set_Outside_Mismatch_no(int pos, int no) { Outside_Mismatch[pos] = no; };
256  void set_bitkennung(Bitvector* bv); // Setzt eine Leere Bitkennung der laenge bits
257  void set_name(char* name) { kennung = ARB_strdup(name); };
258  void set_Hitliste(Hit** hitptr) { hitliste = hitptr; };
259  void set_length_hitliste(long lhl) { length_hitliste = lhl; };
260  void set_minelem(long min) { minelem = min; };
261  void set_maxelem(long max) { maxelem = max; };
262  void set_far(positiontype far) { kombi_far = far; };
263  void set_mor(positiontype mor) { kombi_mor = mor; };
264 
265  void print();
266  void sink(long i, long t, MO_Mismatch** A);
267  void heapsort(long feldlaenge, MO_Mismatch** Nr_Mm_Feld);
268  double check_for_min(long k, MO_Mismatch** probebacts, long laenge);
269 
270  MO_Mismatch** get_matching_species(bool match_also_revcompl,
271  int match_weight,
272  int match_mis,
273  char *match_seq,
274  MO_Liste *convert,
275  long *number_of_species);
276  int gen_Hitliste(MO_Liste *Bakterienliste);
277 
278  Sonde(char* bezeichner, int allowed_mis, double outside_mis);
279  ~Sonde();
280 };
281 // ##################################### Sondentopf Container ###########################
282 
283 struct ST_Container : virtual Noncopyable {
286  Sondentopf *sondentopf; // Wird einmal eine Sondentopfliste
291 
292  Sonde* cache_Sonde(char *name, int allowed_mis, double outside_mis);
293  Sonde* get_cached_sonde(char* name);
294  ST_Container(int anz_sonden);
295  ~ST_Container();
296 };
297 
298 // ##################################### MO_Liste #####################################
299 /* Die Namen werden in die Hashtabelle mit fortlaufender Nummer abgespeichert
300  * Die Nummer bezeichnet das Feld in einem Array, indem momentan der B.-Name steht,
301  * spaeter
302  * aber auch z.B. ein Pointer auf eine Klasse mit mehr Informationen stehen kann
303  ACHTUNG:: Es kann passieren, dass eine Sonde mehrmals an einen Bakter bindet. Dann wird der Bakter nur einmal in die
304  Liste eingetragen, und damit ist die laenge nicht mehr aussagekraeftig. current-1 enthaelt das letzte element der liste, die
305  Liste beginnt bei 1
306 */
307 
308 class MO_Liste : virtual Noncopyable {
309  Bakt_Info** mo_liste;
310  long laenge;
311  long current; // zeigt auf den ersten freien eintrag
312  GB_HASH* hashptr;
313 
314  static GBDATA *gb_main;
315 
316 public:
318  void get_all_species();
319  long debug_get_current();
320  long get_laenge();
321  long put_entry(const char* name);
322  char* get_entry_by_index(long index);
323  long get_index_by_entry(const char* key);
324  Bakt_Info* get_bakt_info_by_index(long index);
325 
326  Bakt_Info** get_mo_liste() { return mo_liste; }
327 
328  static void set_gb_main(GBDATA *gb_main_) {
329  mp_assert(implicated(gb_main, gb_main == gb_main_));
330  gb_main = gb_main_;
331  }
332 
333  MO_Liste();
334  ~MO_Liste();
335 };
336 
337 
338 class Bitvector : virtual Noncopyable {
339  // Bitpositionen sind 0 bis 7
340  char* vector;
341  int len;
342  int num_of_bits;
343 public:
344  int gen_id();
346  int subset(Bitvector* Obermenge);
347  int readbit(int pos);
348  int setbit(int pos);
349  int delbit(int pos);
350  void rshift();
351  void print();
352 
353  char* get_vector() { return vector; };
354  int get_num_of_bits() { return num_of_bits; };
355  int get_len() { return len; };
356 
357  void set_vector(char* back) { vector = back; };
358 
359  Bitvector(int bits);
360  ~Bitvector();
361 };
362 
363 #else
364 #error MultiProbe.hxx included twice
365 #endif // MULTIPROBE_HXX
Hit * get_hitdata_by_number(long index)
Definition: MP_sonde.cxx:263
long singlemismatches
Definition: MultiProbe.hxx:97
char * probelist
Definition: MultiProbe.hxx:89
AW_window_simple * get_window()
Definition: MultiProbe.hxx:164
AW_window_simple * get_result_window()
Definition: MultiProbe.hxx:165
long debug_get_current()
void set_bitkennung(Bitvector *bv)
Definition: MP_sonde.cxx:309
GB_HASH * cachehash
Definition: MultiProbe.hxx:289
bool pt_server_different
Definition: MP_main.cxx:29
#define implicated(hypothesis, conclusion)
Definition: arb_assert.h:289
long no_of_mismatches
Definition: MultiProbe.hxx:95
static char * y[maxsp+1]
char * get_name()
Definition: MultiProbe.hxx:244
long emphasis
Definition: MultiProbe.hxx:101
void print()
Definition: MP_permute.cxx:80
void set_p_eval(ProbeValuation *y)
Definition: MultiProbe.hxx:149
Bakt_Info * get_bakt_info_by_index(long index)
int get_len()
Definition: MultiProbe.hxx:355
long get_length_hitliste()
Definition: MultiProbe.hxx:247
int delbit(int pos)
Definition: MP_permute.cxx:99
positiontype get_mor()
Definition: MultiProbe.hxx:251
char * get_name()
Definition: MultiProbe.hxx:186
GB_HASH * get_color_hash()
Definition: MultiProbe.hxx:224
float min_weight
Definition: MultiProbe.hxx:103
static void set_gb_main(GBDATA *gb_main_)
Definition: MultiProbe.hxx:328
long get_laenge()
void set_Hitliste(Hit **hitptr)
Definition: MultiProbe.hxx:258
AW_root * get_aw_root()
Definition: MultiProbe.hxx:144
Definition: trnsprob.h:20
List< Sondentopf > * ST_Liste
Definition: MultiProbe.hxx:287
#define mp_assert(x)
Definition: MultiProbe.hxx:30
double get_mismatch_at_pos(int pos)
Definition: MultiProbe.hxx:203
AW_selection_list * selected_list
Definition: MP_Window.cxx:34
char * ARB_strdup(const char *str)
Definition: arb_string.h:27
int gen_id()
Definition: MP_permute.cxx:31
int get_random(int min, int max)
Definition: MP_noclass.cxx:44
void set_vector(char *back)
Definition: MultiProbe.hxx:357
bool new_pt_server
Definition: MP_noclass.cxx:33
void convert(const FormattedFile &in, const FormattedFile &out)
Definition: convert.cxx:156
int anz_elem_unmarked
Definition: MP_main.cxx:28
int subset(Bitvector *Obermenge)
Definition: MP_permute.cxx:54
ProbeValuation * get_p_eval()
Definition: MultiProbe.hxx:146
void print()
Definition: MP_sonde.cxx:58
long ecolipos
Definition: MultiProbe.hxx:102
Bakt_Info(const char *n)
Definition: MP_sonde.cxx:320
char * result_probes
Definition: MultiProbe.hxx:90
Sonde * get_cached_sonde(char *name)
void MP_compute(AW_window *, GBDATA *gb_main)
Definition: MP_noclass.cxx:292
void heapsort(long feldlaenge, MO_Mismatch **Nr_Mm_Feld)
Definition: MP_sonde.cxx:274
positiontype fill_marked_bakts()
Bitvector * get_bitkennung()
Definition: MultiProbe.hxx:252
positiontype get_far()
Definition: MultiProbe.hxx:250
Sonde(char *bezeichner, int allowed_mis, double outside_mis)
Definition: MP_sonde.cxx:20
void sink(long i, long t, MO_Mismatch **A)
Definition: MP_sonde.cxx:291
Sondentopf * sondentopf
Definition: MultiProbe.hxx:286
void kill_flag()
Definition: MultiProbe.hxx:189
void set_mismatch_at_pos(int pos, double mm)
Definition: MultiProbe.hxx:202
MO_Liste * Auswahlliste
Definition: MultiProbe.hxx:285
MO_Mismatch ** get_matching_species(bool match_also_revcompl, int match_weight, int match_mis, char *match_seq, MO_Liste *convert, long *number_of_species)
Definition: MP_sonde.cxx:66
probe_tabs * fill_Stat_Arrays()
double * get_mismatch()
Definition: MultiProbe.hxx:200
ProbeValuation * new_probe_eval(char **field, int size, int *array, int *mismatches)
Definition: MP_main.cxx:57
double get_Allowed_Mismatch_no(int no)
Definition: MultiProbe.hxx:242
awar_vars mp_gl_awars
Definition: MP_main.cxx:23
long k_chosenFrom_n(int k, int n)
Definition: MP_noclass.cxx:35
unsigned char ** hamming_tab
Definition: MP_noclass.cxx:32
long get_index_by_entry(const char *key)
void destroy_probe_eval()
Definition: MP_main.cxx:52
long get_length_hitliste()
void set_minelem(long min)
Definition: MultiProbe.hxx:260
long complement
Definition: MultiProbe.hxx:94
unsigned long positiontype
Definition: SoTl.hxx:42
Hit ** get_Hitliste()
Definition: MultiProbe.hxx:246
void set_name(char *name)
Definition: MultiProbe.hxx:257
TREE_canvas * get_canvas()
Definition: MultiProbe.hxx:145
int setbit(int pos)
Definition: MP_permute.cxx:88
~Hit()
Definition: MP_sonde.cxx:345
Sonde * cache_Sonde(char *name, int allowed_mis, double outside_mis)
void put_Sonde(char *name, int allowed_mis, double outside_mis)
char * get_entry_by_index(long index)
void set_mor(positiontype mor)
Definition: MultiProbe.hxx:263
int gen_Hitliste(MO_Liste *Bakterienliste)
Definition: MP_sonde.cxx:175
Sondentopf(MO_Liste *BL, MO_Liste *AL)
void set_stc(ST_Container *stopfC)
Definition: MultiProbe.hxx:148
int get_num_of_bits()
Definition: MultiProbe.hxx:354
char * result_probes_comment
Definition: MultiProbe.hxx:91
ST_Container(int anz_sonden)
long get_minelem()
Definition: MultiProbe.hxx:248
long ptserver
Definition: MultiProbe.hxx:98
double ** gen_Mergefeld()
float max_weight
Definition: MultiProbe.hxx:104
float outside_mismatches_difference
Definition: MultiProbe.hxx:92
float greyzone
Definition: MultiProbe.hxx:105
double check_for_min(long k, MO_Mismatch **probebacts, long laenge)
Definition: MP_sonde.cxx:158
MP_Window(AW_root *aw_root, GBDATA *gb_main)
Definition: MP_Window.cxx:342
int remembered_mismatches
Definition: MP_main.cxx:26
List< char > * Sondennamen
Definition: MultiProbe.hxx:290
double get_Outside_Mismatch_no(int no)
Definition: MultiProbe.hxx:243
MP_Main * mp_main
Definition: MP_main.cxx:24
void set_Outside_Mismatch_no(int pos, int no)
Definition: MultiProbe.hxx:255
int anz_elem_marked
Definition: MP_main.cxx:27
long weightedmismatches
Definition: MultiProbe.hxx:93
long get_hit_flag()
Definition: MultiProbe.hxx:188
void set_Allowed_Mismatch_no(int pos, int no)
Definition: MultiProbe.hxx:254
long inc_hit_flag()
Definition: MultiProbe.hxx:187
Bakt_Info ** get_mo_liste()
Definition: MultiProbe.hxx:326
char(& no)[2]
Definition: downcast.h:31
MP_Main(AW_root *awr, TREE_canvas *canvas)
Definition: MP_main.cxx:31
void rshift()
Definition: MP_permute.cxx:66
char * selected_probes
Definition: MultiProbe.hxx:88
void set_maxelem(long max)
Definition: MultiProbe.hxx:261
MO_Liste * Bakterienliste
Definition: MultiProbe.hxx:284
void gen_color_hash(positiontype anz_sonden)
long put_entry(const char *name)
Bitvector * merge(Bitvector *x)
Definition: MP_permute.cxx:38
long no_of_probes
Definition: MultiProbe.hxx:96
char MP_probe_tab[256]
Definition: MP_main.cxx:25
long get_baktid()
Definition: MultiProbe.hxx:201
void set_far(positiontype far)
Definition: MultiProbe.hxx:262
void set_length_hitliste(long lhl)
Definition: MultiProbe.hxx:259
int ** system3_tab
Definition: MP_noclass.cxx:29
MP_Window * get_mp_window()
Definition: MultiProbe.hxx:143
Hit(long baktnummer)
Definition: MP_sonde.cxx:335
AW_selection_list * result_probes_list
Definition: MP_Window.cxx:35
Bitvector(int bits)
Definition: MP_permute.cxx:15
GBDATA * gb_main
Definition: adname.cxx:33
long get_maxelem()
Definition: MultiProbe.hxx:249
~MP_Main()
Definition: MP_main.cxx:40
#define min(a, b)
Definition: f2c.h:153
ST_Container * get_stc()
Definition: MultiProbe.hxx:147
long qualityborder_best
Definition: MultiProbe.hxx:100
long probe_quality
Definition: MultiProbe.hxx:99
void get_all_species()
Definition: MP_mo_liste.cxx:42
AW_window_simple * create_result_window(AW_root *aw_root)
Definition: MP_Window.cxx:40
char * get_vector()
Definition: MultiProbe.hxx:353
int readbit(int pos)
Definition: MP_permute.cxx:111
int anzahl_basissonden
Definition: MultiProbe.hxx:288
~Sonde()
Definition: MP_sonde.cxx:43
#define max(a, b)
Definition: f2c.h:154