37 if (k > (n / 2)) k = n - k;
38 if (k <= 0)
return k == 0;
39 for (i = 2; i <= k; n--, a *= n, b *= i, i++) ;
76 const char *
result = strrchr(str,
'#');
83 result += strspn(result,
" \t");
89 bool firsttime =
true;
96 char *
probe, *new_qual, *ecol_pos;
99 if (!selected || !selected[0])
103 if (!probe || !probe[0])
110 new_qual =
new char[5 + 7 + strlen(probe)];
125 char *com1, *com2, *com3, *probes, temp[120];
139 if (!probes || !probes[0])
174 char *
probe, *new_sing;
177 if (!selected || !selected[0])
183 new_sing =
new char[5 + 7 + strlen(probe)];
204 delete [] system3_tab[j];
211 system3_tab[j] =
new int[3];
212 memset(system3_tab[j], 0,
sizeof(
int) * 3);
216 for (k=0; k<3; k++) {
217 if (!j) system3_tab[j][k] = k;
218 else system3_tab[j][k] = system3_tab[j-1][k] * 3;
228 hamming_tab =
new unsigned char*[size_hamming_tab];
229 dummy_int =
new int*[size_hamming_tab];
231 for (i=0; i<size_hamming_tab; i++) {
232 hamming_tab[i] =
new unsigned char[size_hamming_tab];
233 memset(
hamming_tab[i], 0,
sizeof(
unsigned char) * size_hamming_tab);
241 for (j=0; j<size_hamming_tab; j++) {
242 for (wert = 0; wert < 3; wert++) {
243 for (k=0; k<counter; k++) {
244 dummy_int[j++][i] = wert;
252 for (i=0; i<size_hamming_tab; i++) {
253 for (j=0; j<size_hamming_tab; j++) {
256 if ((dummy_int[i][k] == 2 && dummy_int[j][k] == 0) ||
257 (dummy_int[i][k] == 0 && dummy_int[j][k] == 2))
264 for (i=0; i<size_hamming_tab; i++) {
265 delete [] dummy_int[i];
282 sprintf(view_text,
"Evaluating first generation");
284 sprintf(view_text,
"Gen:%d Avg:%5i Min:%5i Max:%5i", gen_cnt,
int(avg_fit),
int(min_fit),
int(max_fit));
298 int *single_mismatch;
305 aw_message(
"Not enough probes selected for computation !!!");
324 probe_field =
new char*[selected_probes_count];
325 bew_array =
new int[selected_probes_count];
326 single_mismatch =
new int[selected_probes_count];
334 if (ptr && ptr[0] !=
' ' && ptr[0] !=
'\t' && ptr[0] !=
'\0') {
336 bew_array[i] = atoi(qual);
340 single_mismatch[i] = atoi(qual);
343 probe_field[i++] = ptr;
352 aw_message(
"There are species in the tree which are\nnot included in the PT-Server");
369 if (!seq2 || ! seq2[0])
373 while (*s && result) {
412 char *mism, *mism_temp;
413 char *a_probe, *another_probe, *the_probe, *mism_temp2;
414 int i, how_many_probes = 0;
419 if (! a_probe || ! a_probe[0]) {
426 mism_temp = mism_temp2;
434 probe_field[i] =
NULp;
438 another_probe = a_probe;
440 mism = strchr(mism_temp,
' ');
444 mismatches[i] = atoi(mism_temp);
448 probe_field[i] =
NULp;
449 the_probe = another_probe;
450 another_probe = strchr(another_probe,
' ');
452 *(another_probe++) = 0;
453 while (*another_probe ==
' ' || *another_probe ==
'\t') another_probe++;
461 if (the_probe && the_probe[0]) {
479 aw_message(
"There are species in the tree which are\nnot included in the PT-Server");
489 if (probe_field[i]) {
501 free(probe_field[i]);
503 delete [] probe_field;
504 delete [] mismatches;
509 char *mism, *mism_temp;
510 char *a_probe, *another_probe, *the_probe, *mism_temp2;
511 int i, how_many_probes = 0;
518 if (! a_probe || ! a_probe[0]) {
525 mism_temp = mism_temp2;
533 probe_field[i] =
NULp;
537 another_probe = a_probe;
539 mism = strchr(mism_temp,
' ');
540 if (mism) *(mism++) = 0;
542 mismatches[i] = atoi(mism_temp);
545 probe_field[i] =
NULp;
546 the_probe = another_probe;
547 another_probe = strchr(another_probe,
' ');
549 *(another_probe++) = 0;
550 while (*another_probe ==
' ' || *another_probe ==
'\t')
559 if (the_probe && the_probe[0]) {
578 aw_message(
"There are species in the tree which are not included in the PT-Server");
588 if (probe_field[i]) {
607 free(probe_field[i]);
609 delete [] probe_field;
610 delete [] mismatches;
622 if (new_val && new_val[0]) {
623 char *new_list_string;
625 char *edited_comment =
NULp;
626 const char *comment = new_comment;
630 for (
int i = 0; edited_comment[i]; ++i) {
632 edited_comment[i] =
'|';
641 comment, misms, ecol, new_val);
644 free(edited_comment);
658 free(new_list_string);
667 if (selected && selected[0]) {
733 const char *numsign = strchr(str,
'#');
768 MAIN_LOCS, PT_LOCS, mp_pd_gl.
locs,
782 #define MP_GET_COMMENT_EQUAL(which, str, expect) \
784 char *got = MP_get_comment(which, str); \
785 TEST_EXPECT_EQUAL(got, expect); \
789 #define MP_GET_PROBES_EQUAL(str, expect) \
791 char *got = MP_get_probes(str); \
792 TEST_EXPECT_EQUAL(got, expect); \
796 void TEST_MP_get_comment_and_probes() {
797 char *probes_only =
ARB_strdup(
"ACGT TGCA ATCG");
798 char *probes_comment =
ARB_strdup(
"val1#val2#val3#ACGT TGCA ATCG");
799 char *probes_1 =
ARB_strdup(
"one# \t ACGT TGCA ATCG");
800 char *probes_2 =
ARB_strdup(
"one#two#\tACGT TGCA ATCG");
802 MP_GET_PROBES_EQUAL(probes_only,
"ACGT TGCA ATCG");
803 MP_GET_PROBES_EQUAL(probes_comment,
"ACGT TGCA ATCG");
804 MP_GET_PROBES_EQUAL(probes_1,
"ACGT TGCA ATCG");
805 MP_GET_PROBES_EQUAL(probes_2,
"ACGT TGCA ATCG");
807 MP_GET_COMMENT_EQUAL(1, probes_comment,
"val1");
808 MP_GET_COMMENT_EQUAL(2, probes_comment,
"val2");
809 MP_GET_COMMENT_EQUAL(3, probes_comment,
"val3");
811 MP_GET_COMMENT_EQUAL(1, probes_only, (
const char *)
NULp);
812 MP_GET_COMMENT_EQUAL(2, probes_only, (
const char *)
NULp);
813 MP_GET_COMMENT_EQUAL(3, probes_only, (
const char *)
NULp);
815 MP_GET_COMMENT_EQUAL(1, probes_1,
"one");
816 MP_GET_COMMENT_EQUAL(2, probes_1, (
const char *)
NULp);
817 MP_GET_COMMENT_EQUAL(3, probes_1, (
const char *)
NULp);
819 MP_GET_COMMENT_EQUAL(1, probes_2,
"one");
820 MP_GET_COMMENT_EQUAL(2, probes_2,
"two");
821 MP_GET_COMMENT_EQUAL(3, probes_2, (
const char *)
NULp);
825 free(probes_comment);
void MP_gen_quality(AW_root *awr)
void sort(bool backward, bool case_sensitive)
AW_window_simple * get_result_window()
positiontype insert_as_last(Type *object)
long k_chosenFrom_n(int k, int n)
#define MP_AWAR_RESULTPROBES
char * MP_get_comment(int which, const char *str)
void set_p_eval(ProbeValuation *y)
void select_element_at(int wanted_index)
void insert_default(const char *displayed, const AW_scalar &value)
void MP_new_sequence(AW_window *aww)
void MP_compute(AW_window *, GBDATA *gb_main)
void MP_show_probes_in_tree_move(AW_window *aww, bool backward, AW_selection_list *resultProbesList)
unsigned char ** hamming_tab
GB_HASH * get_color_hash()
static void set_gb_main(GBDATA *gb_main_)
#define MP_AWAR_RESULTPROBESCOMMENT
char * ARB_strdup(const char *str)
void delete_element_at(int index)
int MP_init_local_com_struct(mp_gl_struct &mp_pd_gl)
const char * GBS_global_string(const char *templat,...)
static int system3_tab_size
void MP_normal_colors_in_tree(AW_window *)
void AW_POPDOWN(AW_window *window)
bool default_is_selected() const
int get_index_of_selected()
char * ARB_strpartdup(const char *start, const char *end)
void MP_show_probes_in_tree(AW_window *)
ProbeValuation * get_p_eval()
GB_ERROR GB_push_transaction(GBDATA *gbd)
void MP_gen_singleprobe(AW_root *awr)
struct Unfixed_cb_parameter * UNFIXED
void insert(const char *displayed, const AW_scalar &value)
const char * get_string() const
const char * read_char_pntr() const
void MP_selected_chosen(AW_root *aw_root)
int remembered_mismatches
#define MP_AWAR_SELECTEDPROBES
AW_selection_list * result_probes_list
static bool MP_is_probe(char *seq)
ProbeValuation * new_probe_eval(char **field, int size, int *array, int *mismatches)
static char * MP_get_probes(const char *str)
static void refresh_without_dbsync(AWT_canvas *scr)
void MP_Comment(AW_window *, const char *new_comment)
void destroy_probe_eval()
void NT_expand_marked_cb(UNFIXED, TREE_canvas *ntw)
void put_Sonde(const char *name, int allowed_mis, double outside_mis)
TREE_canvas * get_canvas()
AW_selection_list * selected_list
void MP_mark_probes_in_tree(AW_window *aww)
virtual void notify_synchronized(GBDATA *gb_main)=0
char * read_string() const
void set_stc(ST_Container *stopfC)
void MP_popup_result_window(AW_window *)
AW_awar * awar(const char *awar)
GB_ERROR GB_pop_transaction(GBDATA *gbd)
void MP_group_all_except_marked(AW_window *)
float outside_mismatches_difference
#define MP_AWAR_AUTOADVANCE
void GB_write_flag(GBDATA *gbd, long flag)
static void init_system3_tab()
const AW_scalar * get_value() const
GB_CSTR GB_getenvUSER(void)
void move_selection(int offset)
AP_tree * get_root_node()
#define MAXSONDENHASHSIZE
void subtitle(const char *stitle)
AWT_graphic_exports exports
void MP_result_combination_chosen(AW_root *aw_root)
GBDATA * GBT_first_species(GBDATA *gb_main)
void MP_delete_selected(UNFIXED, AW_selection_list *sellist)
void aw_message(const char *msg)
MO_Liste * Bakterienliste
void gen_color_hash(positiontype anz_sonden)
GBDATA * GBT_next_species(GBDATA *gb_species)
int & get_modifying_flag_ref()
void MP_close_main(AW_window *aww)
void MP_cache_sonden(AW_window *)
int get_random(int min, int max)
GB_ERROR write_string(const char *aw_string)
MP_Window * get_mp_window()
void MP_modify_selected(AW_root *awr)
GB_transaction ta(gb_var)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
void MP_cache_sonden2(AW_root *)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
bool MP_aborted(int gen_cnt, double avg_fit, double min_fit, double max_fit, arb_progress &progress)
#define MP_AWAR_SINGLEMISMATCHES
GB_ERROR write_int(long aw_int)
long GBS_read_hash(const GB_HASH *hs, const char *key)
AW_window_simple * create_result_window(AW_root *aw_root)
int aisc_create(aisc_com *link, int father_type, const AISC_Object &father, int attribute, int object_type, AISC_Object &object,...)
void delete_value(const AW_scalar &value)
char * GBS_global_string_copy(const char *templat,...)
GB_write_int const char s