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  const 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(const 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  const 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_bitkennung(Bitvector* bv); // Setzt eine Leere Bitkennung der laenge bits
255  void set_far(positiontype far) { kombi_far = far; };
256  void set_mor(positiontype mor) { kombi_mor = mor; };
257 
258  void print();
259  void sink(long i, long t, MO_Mismatch** A);
260  void heapsort(long feldlaenge, MO_Mismatch** Nr_Mm_Feld);
261  double check_for_min(long k, MO_Mismatch** probebacts, long laenge);
262 
263  MO_Mismatch** get_matching_species(int ptserver_id,
264  bool match_also_revcompl,
265  int match_weight,
266  int match_mis,
267  const char *match_seq,
268  MO_Liste *convert,
269  long *number_of_species,
270  GB_ERROR& error);
271 
272  int gen_Hitliste(MO_Liste *Bakterienliste);
273 
274  Sonde(const char* bezeichner, int num_probes, int allowed_mis, double outside_mis);
275  ~Sonde();
276 };
277 // ##################################### Sondentopf Container ###########################
278 
279 struct ST_Container : virtual Noncopyable {
282  Sondentopf *sondentopf; // Wird einmal eine Sondentopfliste
287 
288  Sonde* cache_Sonde(const char *name, int allowed_mis, double outside_mis);
289  Sonde* get_cached_sonde(const char* name);
290  ST_Container(int anz_sonden);
291  ~ST_Container();
292 };
293 
294 // ##################################### MO_Liste #####################################
295 /* Die Namen werden in die Hashtabelle mit fortlaufender Nummer abgespeichert
296  * Die Nummer bezeichnet das Feld in einem Array, indem momentan der B.-Name steht,
297  * spaeter
298  * aber auch z.B. ein Pointer auf eine Klasse mit mehr Informationen stehen kann
299  ACHTUNG:: Es kann passieren, dass eine Sonde mehrmals an einen Bakter bindet. Dann wird der Bakter nur einmal in die
300  Liste eingetragen, und damit ist die laenge nicht mehr aussagekraeftig. current-1 enthaelt das letzte element der liste, die
301  Liste beginnt bei 1
302 */
303 
304 class MO_Liste : virtual Noncopyable {
305  Bakt_Info** mo_liste;
306  long laenge;
307  long current; // zeigt auf den ersten freien eintrag
308  GB_HASH* hashptr;
309 
310  static GBDATA *gb_main;
311 
312 public:
314  GB_ERROR get_all_species(int ptserver_id);
315  long debug_get_current();
316  long get_laenge() const;
317  long put_entry(const char* name);
318  const char* get_entry_by_index(long index) const;
319  long get_index_by_entry(const char* key);
320  Bakt_Info* get_bakt_info_by_index(long index);
321 
322  Bakt_Info** get_mo_liste() { return mo_liste; }
323 
324  static void set_gb_main(GBDATA *gb_main_) {
325  mp_assert(implicated(gb_main, gb_main == gb_main_));
326  gb_main = gb_main_;
327  }
328 
329  MO_Liste();
330  ~MO_Liste();
331 };
332 
333 
334 class Bitvector : virtual Noncopyable {
335  // Bitpositionen sind 0 bis 7
336  char* vector;
337  int len;
338  int num_of_bits;
339 public:
340  int gen_id();
342  int subset(Bitvector* Obermenge);
343  int readbit(int pos);
344  int setbit(int pos);
345  int delbit(int pos);
346  void rshift();
347  void print();
348 
349  const char* get_vector() { return vector; };
350  int get_num_of_bits() { return num_of_bits; };
351  int get_len() { return len; };
352 
353  void set_vector(char* back) { vector = back; }; // @@@ pass char*& and use reassign?
354 
355  Bitvector(int bits);
356  ~Bitvector();
357 };
358 
359 #else
360 #error MultiProbe.hxx included twice
361 #endif // MULTIPROBE_HXX
Hit * get_hitdata_by_number(long index)
Definition: MP_sonde.cxx:279
long singlemismatches
Definition: MultiProbe.hxx:97
const char * GB_ERROR
Definition: arb_core.h:25
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:325
GB_HASH * cachehash
Definition: MultiProbe.hxx:285
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]
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:351
long get_length_hitliste()
Definition: MultiProbe.hxx:247
int delbit(int pos)
Definition: MP_permute.cxx:99
positiontype get_mor()
Definition: MultiProbe.hxx:251
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:324
AW_root * get_aw_root()
Definition: MultiProbe.hxx:144
Definition: trnsprob.h:20
List< Sondentopf > * ST_Liste
Definition: MultiProbe.hxx:283
#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:32
int gen_id()
Definition: MP_permute.cxx:31
int get_random(int min, int max)
Definition: MP_noclass.cxx:43
void set_vector(char *back)
Definition: MultiProbe.hxx:353
bool new_pt_server
Definition: MP_noclass.cxx:32
void convert(const FormattedFile &in, const FormattedFile &out)
Definition: convert.cxx:154
int anz_elem_unmarked
Definition: MP_main.cxx:28
int subset(Bitvector *Obermenge)
Definition: MP_permute.cxx:54
Sonde * get_cached_sonde(const char *name)
ProbeValuation * get_p_eval()
Definition: MultiProbe.hxx:146
void print()
Definition: MP_sonde.cxx:60
long ecolipos
Definition: MultiProbe.hxx:102
Bakt_Info(const char *n)
Definition: MP_sonde.cxx:336
char * result_probes
Definition: MultiProbe.hxx:90
void MP_compute(AW_window *, GBDATA *gb_main)
Definition: MP_noclass.cxx:291
void heapsort(long feldlaenge, MO_Mismatch **Nr_Mm_Feld)
Definition: MP_sonde.cxx:290
positiontype fill_marked_bakts()
Bitvector * get_bitkennung()
Definition: MultiProbe.hxx:252
positiontype get_far()
Definition: MultiProbe.hxx:250
void sink(long i, long t, MO_Mismatch **A)
Definition: MP_sonde.cxx:307
Sondentopf * sondentopf
Definition: MultiProbe.hxx:282
MO_Mismatch ** get_matching_species(int ptserver_id, bool match_also_revcompl, int match_weight, int match_mis, const char *match_seq, MO_Liste *convert, long *number_of_species, GB_ERROR &error)
Definition: MP_sonde.cxx:68
GB_ERROR get_all_species(int ptserver_id)
Definition: MP_mo_liste.cxx:44
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:281
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:34
unsigned char ** hamming_tab
Definition: MP_noclass.cxx:31
static void error(const char *msg)
Definition: mkptypes.cxx:96
long get_index_by_entry(const char *key)
void destroy_probe_eval()
Definition: MP_main.cxx:52
long get_length_hitliste()
Sonde * cache_Sonde(const char *name, int allowed_mis, double outside_mis)
long complement
Definition: MultiProbe.hxx:94
unsigned long positiontype
Definition: SoTl.hxx:42
const char * get_name()
Definition: MultiProbe.hxx:244
void put_Sonde(const char *name, int allowed_mis, double outside_mis)
Hit ** get_Hitliste()
Definition: MultiProbe.hxx:246
const char * get_entry_by_index(long index) const
TREE_canvas * get_canvas()
Definition: MultiProbe.hxx:145
int setbit(int pos)
Definition: MP_permute.cxx:88
~Hit()
Definition: MP_sonde.cxx:361
long get_laenge() const
void set_mor(positiontype mor)
Definition: MultiProbe.hxx:256
int gen_Hitliste(MO_Liste *Bakterienliste)
Definition: MP_sonde.cxx:183
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:350
char * result_probes_comment
Definition: MultiProbe.hxx:91
ST_Container(int anz_sonden)
long get_minelem()
Definition: MultiProbe.hxx:248
const char * get_vector()
Definition: MultiProbe.hxx:349
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:166
MP_Window(AW_root *aw_root, GBDATA *gb_main)
Definition: MP_Window.cxx:344
int remembered_mismatches
Definition: MP_main.cxx:26
List< char > * Sondennamen
Definition: MultiProbe.hxx:286
double get_Outside_Mismatch_no(int no)
Definition: MultiProbe.hxx:243
MP_Main * mp_main
Definition: MP_main.cxx:24
int anz_elem_marked
Definition: MP_main.cxx:27
long weightedmismatches
Definition: MultiProbe.hxx:93
long get_hit_flag()
Definition: MultiProbe.hxx:188
long inc_hit_flag()
Definition: MultiProbe.hxx:187
Bakt_Info ** get_mo_liste()
Definition: MultiProbe.hxx:322
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
MO_Liste * Bakterienliste
Definition: MultiProbe.hxx:280
const char * get_name()
Definition: MultiProbe.hxx:186
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:255
Sonde(const char *bezeichner, int num_probes, int allowed_mis, double outside_mis)
Definition: MP_sonde.cxx:21
int ** system3_tab
Definition: MP_noclass.cxx:28
MP_Window * get_mp_window()
Definition: MultiProbe.hxx:143
Hit(long baktnummer)
Definition: MP_sonde.cxx:351
AW_selection_list * result_probes_list
Definition: MP_Window.cxx:33
Bitvector(int bits)
Definition: MP_permute.cxx:15
GBDATA * gb_main
Definition: adname.cxx:32
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
AW_window_simple * create_result_window(AW_root *aw_root)
Definition: MP_Window.cxx:38
int readbit(int pos)
Definition: MP_permute.cxx:111
int anzahl_basissonden
Definition: MultiProbe.hxx:284
~Sonde()
Definition: MP_sonde.cxx:45
#define max(a, b)
Definition: f2c.h:154