47 #define AWAR_DIST_BOOTSTRAP_COUNT AWAR_DIST_PREFIX "bootstrap/count"
48 #define AWAR_DIST_CANCEL_CHARS AWAR_DIST_PREFIX "cancel/chars"
49 #define AWAR_DIST_MATRIX_AUTO_RECALC AWAR_DIST_PREFIX "recalc"
51 #define AWAR_DIST_COLUMN_STAT_NAME AWAR_DIST_COLUMN_STAT_PREFIX "name"
53 #define AWAR_DIST_TREE_SORT_NAME "tmp/" AWAR_DIST_TREE_PREFIX "sort_tree_name"
54 #define AWAR_DIST_TREE_COMP_NAME "tmp/" AWAR_DIST_TREE_PREFIX "compr_tree_name"
55 #define AWAR_DIST_TREE_STD_NAME AWAR_DIST_TREE_PREFIX "tree_name"
56 #define AWAR_DIST_MATRIX_AUTO_CALC_TREE AWAR_DIST_TREE_PREFIX "autocalc"
58 #define AWAR_DIST_SAVE_MATRIX_TYPE AWAR_DIST_SAVE_MATRIX_BASE "/type"
59 #define AWAR_DIST_SAVE_MATRIX_FILENAME AWAR_DIST_SAVE_MATRIX_BASE "/file_name"
118 need_recalc.
matrix =
true;
122 need_recalc.
tree =
true;
135 need_recalc.
matrix =
false;
138 if (matrix_autocalc) {
139 bool recalc_now =
true;
141 if (!tree_autocalc) recalc_now = matrixDisplay ? matrixDisplay->
willShow() :
false;
145 (*recalculate_matrix_cb)();
152 if (need_recalc.
tree) {
156 (*recalculate_tree_cb)();
157 need_recalc.
matrix =
false;
173 AW_window_simple *aws =
new AW_window_simple;
174 aws->init(aw_root,
"SET_DNA_MATRIX",
"SET MATRIX");
176 aws->button_length(10);
178 aws->create_button(
"CLOSE",
"CLOSE");
181 aws->create_button(
"HELP",
"HELP");
235 enum treetype { CURR, SORT, COMPRESS, TREEAWARCOUNT };
259 AWT_create_db_browser_awars(aw_root, def);
281 : phmatrix(phmatrix_),
291 if (phmatrix->
is_AA) {
307 : phmatrix(phmatrix_),
323 allocated_entries(0),
324 aliview(new
AliView(aliview_)),
331 memset(cancel_columns, 0,
sizeof(cancel_columns));
363 if (sort_tree_name) {
373 insert_in_hash(sort_tree);
395 size_t no_of_species = -1
U;
406 for (no_of_species = 0; species_list[no_of_species]; ++no_of_species) ;
412 return no_of_species;
425 allocated_entries = 1000;
430 size_t no_of_species =
get_load_count(what, gb_main, species_list);
431 if (no_of_species<2) {
453 for (i = 0; species_list[i]; ++i) {
463 order.
applyTo(species_to_load, no_of_species);
465 int species_not_in_sort_tree = 0;
466 for (
size_t i = 0; i<no_of_species; ++i) {
467 if (!species_to_load[i]->order_index) {
468 species_not_in_sort_tree++;
471 if (species_not_in_sort_tree) {
478 static bool shown =
false;
480 GBT_message(gb_main,
"Warning: No valid tree given to sort matrix (using default database order)");
486 if (no_of_species>allocated_entries) {
487 allocated_entries = no_of_species;
492 arb_progress progress(
"Preparing sequence data", no_of_species);
493 for (
size_t i = 0; i<no_of_species && !
error; ++i) {
502 delete species_to_load[i];
503 species_to_load[i] =
NULp;
511 char *DI_MATRIX::calculate_overall_freqs(
double rel_frequencies[
AP_MAX],
char *cancel) {
521 memset((
char *) &hits2[0], 0,
sizeof(hits2));
522 for (
size_t row = 0; row <
nentries; row++) {
524 for (pos = 0; pos < s_len; pos++) {
526 if (cancel[b])
continue;
530 for (i = 0; i <
AP_MAX; i++) {
533 for (i = 0; i <
AP_MAX; i++) {
534 rel_frequencies[i] = hits2[i] / (double) sum;
539 double DI_MATRIX::corr(
double dist,
double b,
double & sigma) {
540 const double eps = 0.01;
541 double ar = 1.0 - dist/b;
543 if (ar< eps)
return 3.0;
545 return - b * log(1-dist/b);
551 if (userdef_matrix) {
552 switch (transformation) {
558 aw_message(
"Sorry: this kind of distance correction does not support a user defined matrix - it will be ignored");
559 userdef_matrix =
NULp;
571 return "Not enough species selected to calculate matrix";
573 memset(&cancel_columns[0], 0, 256);
575 for (i=0; cancel[i]; i++) {
583 double rel_frequencies[
AP_MAX];
586 switch (transformation) {
588 this->calculate_overall_freqs(rel_frequencies, cancel_columns);
590 for (i=0; i<
AP_MAX; i++) {
591 S_square += rel_frequencies[i]*rel_frequencies[i];
599 for (
size_t row = 0; row<nentries && !
error; row++) {
600 for (
size_t col=0; col<=row && !
error; col++) {
607 switch (transformation) {
617 if (userdef_matrix) {
618 memset((
char *)hits, 0,
sizeof(
long) * AP_MAX * AP_MAX);
620 for (pos = s_len; pos >= 0; pos--) {
621 hits[*(seq1++)][*(seq2++)]++;
624 double diffsum = 0.0;
625 double all_sum = 0.001;
629 all_sum += hits[x][
y];
633 diffsum += hits[x][
y] * userdef_matrix->
get(x, y);
634 all_sum += hits[x][
y] * userdef_matrix->
get(x, y);
638 dist = diffsum / all_sum;
641 for (
int pos = s_len; pos >= 0; pos--) {
644 if (cancel_columns[b1])
continue;
645 if (cancel_columns[b2])
continue;
650 if (columns == 0) columns = 1;
658 dist = this->corr(dist, b, sigma);
671 memset((
char *)hits, 0,
sizeof(
long) * AP_MAX * AP_MAX);
672 for (pos = s_len; pos >= 0; pos--) {
673 hits[*(seq1++)][*(seq2++)]++;
675 switch (transformation) {
695 p = (double)P/(
double)
N;
696 q = (double)Q/(
double)
N;
698 (1.0-2.0*p-q)*sqrt(1.0-2.0*q)
705 memset((
char *)frequencies, 0,
706 sizeof(
long) * AP_MAX);
711 for (i=0; i<
AP_MAX; i++) {
712 if (cancel_columns[i])
continue;
714 for (j=0; j<i; j++) {
715 if (cancel_columns[j])
continue;
720 frequencies[i] += hits[i][i];
727 for (i=0; i<
AP_MAX; i++) S_square += frequencies[i]*frequencies[i];
728 b = 1.0 - S_square/((double)N*(
double)
N);
734 dist = ((double)(N-M)) / (
double)
N;
736 dist = this->corr(dist, b, sigma);
739 default:
return "Sorry: Transformation not implemented";
749 if (aborted_flag && progress.
aborted()) *aborted_flag =
true;
757 switch (transformation) {
766 return "This correction is not available for protein data";
774 typedef std::map<const char*, TreeNode*, charpLess>
NamedNodes;
779 NamedNodes::iterator found = named.find(node->
name);
780 if (found != named.end()) {
785 found->second = node;
792 if (!error) error =
link_to_tree(named, node->get_rightson());
797 #if defined(ASSERTION_USED)
800 return strcmp(node->
name, name) == 0 ? node :
NULp;
804 if (!found) found =
findNode(node->get_rightson(), name);
811 for (
size_t n = 0; n<nentries; ++n) {
817 const char *exampleName =
NULp;
819 for (
size_t n = 0; n<nentries; ++n) {
820 NamedNodes::iterator found = node.find(entries[n]->name);
821 if (found == node.end()) {
823 exampleName = entries[n]->
name;
827 if (!node[entries[n]->name]) {
829 exampleName = entries[n]->
name;
835 error =
GBS_global_string(
"Tree is missing %zu required species (e.g. '%s')", missing, exampleName);
843 if (nentries<=1) error =
"Not enough species selected to calculate matrix";
858 for (
size_t row = 0; row<nentries && !
error; row++) {
860 for (
size_t col=0; col<=row && !
error; col++) {
875 if (aborted_flag && progress.
aborted()) *aborted_flag =
true;
876 if (error) progress.
done();
891 if (GLOBAL_MATRIX.
exists()) {
902 error =
"Please select a valid alignment";
908 double phase1_fraction;
911 double O_loadData = 10*species_count;
913 phase1_fraction = O_loadData / (O_loadData+O_calcMatrix);
929 static SmartCharPtr last_sort_tree_name;
932 if (last_sort_tree_name.isNull() || !sort_tree_name || strcmp(&*last_sort_tree_name, sort_tree_name) != 0) {
933 last_sort_tree_name = nulldup(sort_tree_name);
934 last_order =
new MatrixOrder(gb_main, sort_tree_name);
937 error = phm->
load(what, *last_order, show_warnings,
NULp);
939 bool aborted = error ? progress.
aborted() :
false;
940 error = ta.
close(error);
957 if (aborted_flag) *aborted_flag =
true;
966 need_recalc.
matrix =
false;
987 if (lowerBound >= upperBound) {
988 error =
GBS_global_string(
"Lower bound (%f) has to be smaller than upper bound (%f)", lowerBound, upperBound);
990 else if (lowerBound<0.0 || lowerBound > 1.0) {
991 error =
GBS_global_string(
"Lower bound (%f) is not in allowed range [0.0 .. 1.0]", lowerBound);
993 else if (upperBound<0.0 || upperBound > 1.0) {
994 error =
GBS_global_string(
"Upper bound (%f) is not in allowed range [0.0 .. 1.0]", upperBound);
1002 error =
"Please select a species";
1019 bool markedSelected =
false;
1021 arb_progress progress(
"Mark species by distance", speciesCount);
1025 gb_species && !
error;
1030 GBDATA *species_pair[] = { gb_selected, gb_species,
NULp };
1041 double dist_value = phm->
matrix->
get(0, 1);
1042 bool mark = (lowerBound <= dist_value && dist_value <= upperBound);
1045 if (!markedSelected) {
1047 mark = (lowerBound <= dist_value && dist_value <= upperBound);
1050 markedSelected =
true;
1062 if (error) progress.
done();
1072 error = ta.
close(error);
1087 (*recalculate_matrix_cb)();
1115 GLOBAL_MATRIX.
get()->
save(filename, type);
1123 static AW_window_simple *aws =
NULp;
1125 aws =
new AW_window_simple;
1126 aws->init(aw_root,
"SAVE_MATRIX",
"Save Matrix");
1127 aws->load_xfig(
"sel_box_user.fig");
1131 aws->create_button(
"CLOSE",
"CANCEL",
"C");
1135 aws->create_button(
"HELP",
"HELP",
"H");
1139 aws->insert_default_option(
"Phylip Format (Lower Triangular Matrix)",
"P",
DI_SAVE_PHYLIP_COMP);
1142 aws->update_option_menu();
1148 aws->create_button(
"SAVE",
"SAVE",
"S");
1152 aws->create_button(
"CLOSE",
"CANCEL",
"C");
1158 AW_window_simple *aws =
new AW_window_simple;
1159 aws->init(aw_root,
"SELECT_CHARS_TO_CANCEL_COLUMN",
"CANCEL SELECT");
1164 aws->create_button(
"CLOSE",
"CLOSE",
"C");
1185 "felsenstein voigt",
1199 StrArray *all_names =
NULp;
1201 long loop_count = 0;
1215 double phase1_fraction;
1219 double O_calcMatrix = 60 * (
triangular_number(species_count) + 10*species_count);
1222 phase1_fraction = O_calcMatrix / (O_calcMatrix+O_joinTree);
1226 if (bootstrap_flag) {
1227 if (bootstrap_count) {
1228 progress =
new arb_progress(
"Calculating bootstrap trees", bootstrap_count+1);
1231 progress =
new arb_progress(
"Calculating bootstrap trees (KILL to stop)",
long(INT_MAX));
1243 if (bootstrap_flag) {
1251 error =
"unexpected error in di_calculate_matrix_cb (data missing)";
1254 all_names =
new StrArray;
1255 all_names->reserve(matr->
nentries+2);
1257 for (
size_t i=0; i<matr->
nentries; i++) {
1267 bool aborted =
false;
1274 if (bootstrap_flag) {
1279 else if (need_recalc.
matrix) {
1285 error =
di_calculate_matrix(aw_root, weighted_filter, bootstrap_flag, !bootstrap_flag, &aborted);
1286 if (error && aborted) {
1290 tree_progress->
inc();
1292 if (!GLOBAL_MATRIX.
exists()) {
1293 error =
"unexpected error in di_calculate_matrix_cb (data missing)";
1300 for (
size_t i=0; i<matr->
nentries; i++) {
1305 tree_progress->
inc();
1307 if (bootstrap_flag && !aborted) {
1317 if (!bootstrap_count) {
1318 time_t t = time(
NULp);
1319 static time_t tlast = 0;
1321 double diff_seconds = difftime(t, tlast);
1322 if (diff_seconds>3) {
1330 if (aborted || error) {
1336 }
while (bootstrap_flag && loop_count != bootstrap_count);
1338 if (aborted || error) tree_progress->
done();
1342 if (bootstrap_flag) {
1350 progress =
new arb_progress(
"Collect consensus of bootstrapped trees", 1UL);
1374 const char *comment;
1375 if (enum_trans_to_string[transr]) {
1376 comment =
GBS_global_string(
"PRG=dnadist CORR=%s FILTER=%s PKG=ARB", enum_trans_to_string[transr], filter_name);
1388 const char *log_message;
1389 if (bootstrap_flag) {
1390 log_message =
GBS_global_string(
"generated consensus tree from %li bootstrap trees%s.",
1392 aborted ?
" (aborted by user)" :
"");
1395 log_message =
"calculation finished";
1412 if (bootstrap_flag) {
1413 if (all_names)
delete all_names;
1422 if (progress.
isSet()) {
1430 need_recalc.
tree =
false;
1448 error =
"Please select a valid alignment";
1460 long flen = strlen(filter_str);
1462 if (flen == ali_len) {
1463 ap_filter =
new AP_filter(filter_str,
"0", ali_len);
1467 aw_message(
"Warning: your filter len is not equal to the alignment len\nfilter got truncated with zeros or cutted");
1468 ap_filter =
new AP_filter(filter_str,
"0", ali_len);
1478 aliview =
new AliView(gb_main, *ap_filter, ap_weights, use);
1501 progress.
subtitle(
"Search Correction");
1562 if (!error && !GLOBAL_MATRIX.
exists()) {
1563 error =
"Failed to calculate your matrix (bug?)";
1573 if (matrixDisplay) {
1607 aws->
init(aw_root,
"NEIGHBOUR JOINING",
"NEIGHBOUR JOINING [ARB_DIST]");
1611 WindowCallback close_cb = makeWindowCallback(
di_exit, gb_main);
1624 AWT_create_debug_menu(aws);
1643 aws->
at(
"which_species");
1649 aws->
at(
"which_alignment");
1658 aws->
at(
"filter_select");
1662 aws->
at(
"weights_select");
1665 aws->
create_button(
"SELECT_COL_STAT", AWAR_DIST_COLUMN_STAT_NAME);
1668 aws->
at(
"which_cancel");
1671 aws->
at(
"cancel_select");
1675 aws->
at(
"change_matrix");
1682 aws->
at(
"which_correction");
1701 aws->
at(
"autodetect");
1704 aws->
create_button(
"AUTODETECT_CORRECTION",
"AUTODETECT",
"A");
1711 aws->
at(
"mark_distance");
1715 aws->
at(
"mark_lower");
1718 aws->
at(
"mark_upper");
1725 aws->
at(
"tree_list");
1728 aws->
at(
"detect_clusters");
1736 aws->
at(
"calculate");
1738 aws->
create_button(
"CALC_FULL_MATRIX",
"Calculate\nFull Matrix",
"F");
1740 aws->
at(
"compress");
1742 aws->
create_button(
"CALC_COMPRESSED_MATRIX",
"Calculate\nCompressed Matrix",
"C");
1754 aws->
at(
"save_matrix");
1758 aws->
at(
"view_matrix");
1764 aws->
at(
"use_compr_tree");
1766 aws->
create_button(
"USE_COMPRESSION_TREE",
"Use to compress",
"");
1767 aws->
at(
"use_sort_tree");
1778 aws->
at(
"t_calculate");
1782 aws->
at(
"bootstrap");
1784 aws->
create_button(
"CALC_BOOTSTRAP_TREE",
"Calculate \nbootstrap tree");
1789 aws->
at(
"use_existing");
1793 aws->
at(
"calc_tree_name");
1802 aws->
at(
"auto_calc_tree");
1803 aws->
label(
"Auto calculate tree");
1806 aws->
at(
"auto_recalc");
1807 aws->
label(
"Auto recalculate");
1814 if (disable_autocalc) {
1839 DIST_testenv(
const char *dbname,
const char *aliName)
1842 gb_main =
GB_open(dbname,
"r");
1851 if (!filter.is_invalid()) {
1861 const AliView& aliview()
const {
return *ali_view; }
1865 void TEST_matrix() {
1871 const char *db_name[]= {
NULp,
"TEST_trees.arb",
"TEST_realign.arb",
"TEST_realign.arb", };
1872 const char *ali_name[]= {
NULp,
"ali_5s",
"ali_dna",
"ali_pro", };
1875 DIST_testenv env(db_name[at], ali_name[at]);
1887 detected_trans = matrix.detect_transformation(msg);
1903 matrix.calculate_pro(detected_trans,
NULp);
1907 matrix.calculate(
"", detected_trans,
NULp,
NULp);
1914 const char *savename =
"distance/matrix.out";
1915 matrix.save(savename, saveType);
1917 const char *suffixAT[] = {
NULp,
"rna",
"dna",
"pro" };
1918 const char *suffixST[] = {
"phylipComp",
"readable",
"tabbed" };
1919 char *expected =
GBS_global_string_copy(
"distance/matrix.%s.%s.expected", suffixAT[at], suffixST[saveType]);
1923 #if defined(TEST_AUTO_UPDATE)
1924 TEST_COPY_FILE(savename, expected);
1927 #endif // TEST_AUTO_UPDATE
1935 #endif // UNIT_TESTS
GB_ERROR GB_begin_transaction(GBDATA *gbd)
#define AWAR_DIST_SAVE_MATRIX_FILENAME
void insert_option(AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color=NULp)
BoundWindowCallback(AW_window *aww_, const WindowCallback &cb_)
GBDATA * GB_open(const char *path, const char *opent)
#define AWAR_DIST_SAVE_MATRIX_TYPE
ColumnStat * get_column_stat()
SizeAwareTree * get_consensus_tree(GB_ERROR &error)
adfiltercbstruct * get_adfiltercbstruct()
void button_length(int length)
void sens_mask(AW_active mask)
GBDATA * GBT_first_marked_species_rel_species_data(GBDATA *gb_species_data)
void matrix_needs_recalc_cb()
return string(buffer, length)
void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, const WindowCallback &wcb)
void show_warnings(const string &helpfile)
CONSTEXPR_INLINE unsigned char safeCharIndex(char c)
void load_xfig(const char *file, bool resize=true)
#define AWAR_DIST_FILTER_ALIGNMENT
void tree_needs_recalc_cb()
GB_ERROR GB_add_callback(GBDATA *gbd, GB_CB_TYPE type, const DatabaseCallback &dbcb)
GB_ERROR extract_from_tree(const char *treename, bool *aborted_flag)
void set(size_t i, size_t j, T val)
void GB_sort(void **array, size_t first, size_t behind_last, gb_compare_function compare, void *client_data)
bool has_type(DI_MATRIX_TYPE type) const
#define AWAR_DIST_MATRIX_AUTO_CALC_TREE
AW_window * COLSTAT_create_selection_window(AW_root *aw_root, ColumnStat *column_stat)
CONSTEXPR unsigned UPDATE_DELAY
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
DI_ENTRY(GBDATA *gbd, DI_MATRIX *phmatrix_)
void AW_create_standard_fileselection(AW_window *aws, const char *awar_prefix)
#define ASSERT_RESULT(Type, Expected, Expr)
GB_ERROR calculate_pro(DI_TRANSFORMATION transformation, bool *aborted_flag)
char * ARB_strdup(const char *str)
#define AWAR_DIST_WHICH_SPECIES
void create_toggle(const char *awar_name)
TreeNode * GBT_read_tree(GBDATA *gb_main, const char *tree_name, TreeRoot *troot)
AW_awar * set_minmax(float min, float max)
AW_window * DI_create_save_matrix_window(AW_root *aw_root, save_matrix_params *save_params)
#define AWAR_DIST_ALIGNMENT
static void selected_tree_changed_cb()
const char * GBS_global_string(const char *templat,...)
static GB_ERROR last_matrix_calculation_error
CONSTEXPR_INLINE long sum_of_triangular_numbers(const long L)
GB_ERROR calculate(const char *cancel, DI_TRANSFORMATION transformation, bool *aborted_flag, AP_matrix *userdef_matrix)
long GBT_get_alignment_len(GBDATA *gb_main, const char *aliname)
#define AWAR_DIST_TREE_SORT_NAME
AW_DB_selection * awt_create_TREE_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname)
AP_sequence_parsimony * get_nucl_seq()
void AW_POPDOWN(AW_window *window)
void AW_insert_common_property_menu_entries(AW_window_menu_modes *awmm)
void AWT_registerTreeAwarCallback(AW_awar *awar, const TreeAwarCallback &tacb, bool triggerIfTreeDataChanges)
void auto_subtitles(const char *prefix)
void set_changed_cb(DI_MATRIX_CB cb)
void add_timed_callback(int ms, const TimedCallback &tcb)
bool isNull() const
test if SmartPtr is NULp
#define AWAR_DIST_FILTER_SIMPLIFY
#define AWAR_DIST_TREE_COMP_NAME
int GB_unlink(const char *path)
static size_t get_load_count(LoadWhat what, GBDATA *gb_main, GBDATA **species_list)
void mark(UpdateFlag needed)
void create_input_fields(AW_window *aww)
bool GBT_is_alignment_protein(GBDATA *gb_main, const char *alignment_name)
#define ARRAY_ELEMS(array)
void setNull()
set SmartPtr to NULp
CONSTEXPR_INLINE long triangular_number(const long N)
void update_option_menu()
GB_ERROR GB_push_transaction(GBDATA *gbd)
GB_ERROR error_if_aborted()
void forget_if_not_has_type(DI_MATRIX_TYPE wanted_type)
AW_awar * add_callback(const RootCallback &cb)
#define AWAR_DIST_MATRIX_DNA_ENABLED
GBDATA * GBT_first_species_rel_species_data(GBDATA *gb_species_data)
static int TreeOrderedSpecies_cmp(const void *p1, const void *p2, void *)
GB_ERROR GBT_write_tree_remark(GBDATA *gb_main, const char *tree_name, const char *remark)
const char * read_char_pntr() const
GB_ERROR link_to_tree(NamedNodes &named, TreeNode *node)
GB_ERROR GB_await_error()
static AW_root * SINGLETON
STATIC_ASSERT(ARRAY_ELEMS(enum_trans_to_string)==DI_TRANSFORMATION_COUNT)
static void matrix_changed_cb()
void applyTo(struct TreeOrderedSpecies **gb_species_array, size_t array_size) const
WindowCallback makeHelpCallback(const char *helpfile)
char * GBT_read_string(GBDATA *gb_container, const char *fieldpath)
__ATTR__USERESULT GB_ERROR insert_tree_weighted(const TreeNode *tree, int leafs, double weight, bool provideProgress)
static void di_calculate_full_matrix_cb(AW_window *aww, const WeightedFilter *weighted_filter)
#define AWAR_DIST_COLUMN_STAT_NAME
static SmartPtr< BoundWindowCallback > recalculate_tree_cb
GB_ERROR GBT_check_tree_name(const char *tree_name)
bool isSet() const
test if SmartPtr is not NULp
AW_awar * awar_float(const char *var_name, float default_value=0.0, AW_default default_file=AW_ROOT_DEFAULT)
AW_window * DI_create_cluster_detection_window(AW_root *aw_root, WeightedFilter *weightedFilter)
void AW_save_properties(AW_window *aw)
AW_window * DI_create_matrix_window(AW_root *aw_root, GBDATA *gb_main)
static int weights[MAX_BASETYPES][MAX_BASETYPES]
const AliView * get_aliview() const
GB_ERROR GBT_write_tree(GBDATA *gb_main, const char *tree_name, TreeNode *tree)
#define AWAR_DIST_MIN_DIST
void create_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
AP_FLOAT get(int i, int j)
#define TEST_REJECT(cond)
#define TEST_REJECT_NULL(n)
TreeNode * neighbourjoining(const char *const *names, const AP_smatrix &smatrix, TreeRoot *troot, bool *aborted_flag)
static MatrixDisplay * matrixDisplay
static __ATTR__USERESULT GB_ERROR di_calculate_matrix(AW_root *aw_root, const WeightedFilter *weighted_filter, bool bootstrap_flag, bool show_warnings, bool *aborted_flag)
static void error(const char *msg)
#define AWAR_DIST_MATRIX_AUTO_RECALC
#define AWAR_DIST_MATRIX_DNA_BASE
#define AWAR_TREE_REFRESH
void AW_create_fileselection_awars(AW_root *awr, const char *awar_base, const char *directories, const char *filter, const char *file_name)
static void di_calculate_tree_cb(AW_window *aww, WeightedFilter *weighted_filter, bool bootstrap_flag)
static AW_window * create_dna_matrix_window(AW_root *aw_root)
AW_window * AW_preset_window(AW_root *root)
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
void label(const char *label)
void insert_help_topic(const char *labeli, const char *mnemonic, const char *helpText, AW_active mask, const WindowCallback &cb)
static void di_define_sort_tree_name_cb(AW_window *aww)
TreeNode * GBT_read_tree_and_size(GBDATA *gb_main, const char *tree_name, TreeRoot *troot, int *tree_size)
DI_MATRIX(const AliView &aliview)
void set_descriptions(int idx, const char *desc)
#define AWAR_SPECIES_NAME
GBDATA * get_gb_main() const
AW_window * awt_create_select_filter_win(AW_root *aw_root, adfiltercbstruct *acbs)
#define TEST_EXPECT_ZERO_OR_SHOW_ERRNO(iocond)
static TreeNode * findNode(TreeNode *node, const char *name)
#define AWAR_DIST_BOOTSTRAP_COUNT
void compressed_matrix_needs_recalc_cb()
static unsigned update_cb(AW_root *aw_root)
static SearchTree * tree[SEARCH_PATTERNS]
static GB_ERROR init(NamedNodes &node, TreeNode *tree, const DI_ENTRY *const *const entries, size_t nentries)
char * read_string() const
static void di_define_compression_tree_name_cb(AW_window *aww)
AW_awar * awar(const char *awar)
DI_MATRIX_TYPE matrix_type
GB_ERROR GB_pop_transaction(GBDATA *gbd)
GB_ERROR DI_create_matrix_variables(AW_root *aw_root, AW_default def, AW_default db)
const AP_filter * get_filter() const
static const char * enum_trans_to_string[]
#define AWAR_DIST_CANCEL_CHARS
void AW_refresh_fileselection(AW_root *awr, const char *awar_prefix)
const WeightedFilter * weighted_filter
MatrixOrder(GBDATA *gb_main, GB_CSTR sort_tree_name)
static void di_mark_by_distance(AW_window *aww, WeightedFilter *weighted_filter)
void create_autosize_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, unsigned xtraSpace=1)
GB_ERROR makedists(bool *aborted_flag)
long GBT_count_marked_species(GBDATA *gb_main)
#define AWAR_DIST_MAX_DIST
AW_window * DI_create_view_matrix_window(AW_root *awr, MatrixDisplay *disp, save_matrix_params *sparam)
static void auto_calc_changed_cb(AW_root *aw_root)
void unlink_awars_from_DB(GBDATA *gb_main)
void insert_default_option(AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color=NULp)
AW_DB_selection * awt_create_ALI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match)
DI_GLOBAL_MATRIX GLOBAL_MATRIX
void create_input_field(const char *awar_name, int columns=0)
#define AWAR_DIST_TREE_CURR_NAME
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
TYPE * ARB_calloc(size_t nelem)
#define IF_ASSERTION_USED(x)
AliView * create_aliview(const char *aliname, GB_ERROR &error) const
static SmartPtr< BoundWindowCallback > recalculate_matrix_cb
void DI_create_cluster_awars(AW_root *aw_root, AW_default def, AW_default db)
GBT_LEN intree_distance_to(const TreeNode *other) const
GB_ERROR close(GB_ERROR error)
void GB_write_flag(GBDATA *gbd, long flag)
GB_ERROR GBT_is_invalid(const TreeNode *tree)
#define AWAR_DIST_SAVE_MATRIX_BASE
void update_from_awars(AW_root *awr)
TreeOrderedSpecies(const MatrixOrder &order, GBDATA *gb_spec)
static AP_matrix * get_user_matrix()
#define __ATTR__USERESULT
CONSTEXPR_INLINE long matrix_halfsize(long entries, bool inclusive_diagonal)
static void di_save_matrix_cb(AW_window *aww)
AW_awar * map(const char *awarn)
bool ARB_in_expert_mode(AW_root *awr)
void ARB_realloc(TYPE *&tgt, size_t nelem)
void subtitle(const char *stitle)
GBDATA * GBT_first_species(GBDATA *gb_main)
GB_ERROR is_invalid() const
void GBT_message(GBDATA *gb_main, const char *msg)
static GB_ERROR di_recalc_matrix()
void replaceBy(DI_MATRIX *new_global)
void create_awars(AW_root *awr)
void auto_increment(int dx, int dy)
#define TEST_EXPECT_NO_ERROR(call)
static void di_calculate_compressed_matrix_cb(AW_window *aww, WeightedFilter *weighted_filter)
void aw_message(const char *msg)
AW_option_menu_struct * create_option_menu(const char *awar_name)
GB_ERROR GBT_log_to_named_trees_remark(GBDATA *gb_main, const char *tree_name, const char *log_entry, bool stamp)
void insert_macro_menu_entry(AW_window *awm, bool prepend_separator)
static AP_userdef_matrix userdef_DNA_matrix(AP_MAX, AWAR_DIST_MATRIX_DNA_BASE)
void shutdown_macro_recording(AW_root *aw_root)
GBDATA * GBT_next_species(GBDATA *gb_species)
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
DI_TRANSFORMATION detect_transformation(std::string &msg)
const char * get_aliname() const
GB_ERROR write_string(const char *aw_string)
#define AWAR_DIST_CORR_TRANS
void lazy_load_sequence() const
char * GBT_get_default_alignment(GBDATA *gb_main)
T get(size_t i, size_t j) const
const char * save(const char *filename, enum DI_SAVE_TYPE type)
long GBT_get_species_count(GBDATA *gb_main)
#define AWAR_DIST_TREE_STD_NAME
char * AWT_get_combined_filter_name(AW_root *aw_root, GB_CSTR prefix)
GB_transaction ta(gb_var)
static void di_view_matrix_cb(AW_window *aww, save_matrix_params *sparam)
void callback(const WindowCallback &cb)
void destroy(TreeNode *that)
GB_ERROR bind_to_species(GBDATA *gb_species)
static RecalcNeeded need_recalc
size_t get_length() const
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
char * compress(TreeNode *tree)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
void hide_or_notify(const char *error)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
#define TEST_EXPECT_TEXTFILES_EQUAL(fgot, fwant)
DI_MATRIX * swap(DI_MATRIX *other)
std::map< const char *, TreeNode *, charpLess > NamedNodes
#define AWAR_DIST_FILTER_NAME
GB_ERROR load(LoadWhat what, const MatrixOrder &order, bool show_warnings, GBDATA **species_list) __ATTR__USERESULT
#define TEST_EXPECT_EQUAL(expr, want)
GB_ERROR write_int(long aw_int)
#define AWAR_DIST_FILTER_FILTER
GBDATA * GB_entry(GBDATA *father, const char *key)
void inc_and_check_user_abort(GB_ERROR &error)
void aw_message_if(GB_ERROR error)
char * GBS_global_string_copy(const char *templat,...)
void GB_close(GBDATA *gbd)
static AW_window * awt_create_select_cancel_window(AW_root *aw_root)
static void di_autodetect_callback(AW_window *aww, GBDATA *gb_main)
static __ATTR__NORETURN void di_exit(AW_window *aww, GBDATA *gb_main)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
static void di_define_save_tree_name_cb(AW_window *aww)
void create_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, const char *color=NULp)
GBDATA * GBT_get_species_data(GBDATA *gb_main)