54 #define AWAR_COLUMNSTAT_BASE "tmp/pars/colstat"
55 #define AWAR_COLUMNSTAT_NAME AWAR_COLUMNSTAT_BASE "/name"
57 #define AWT_TREE_PARS(ntw) DOWNCAST(AWT_graphic_parsimony*, (ntw)->gfx)
150 quick_add_flag(quick)
158 abort_flag = progress.
aborted();
166 AP_tree_nlen *leaf0 = (AP_tree_nlen*)leaf0_ptr;
167 AP_tree_nlen *leaf1 = (AP_tree_nlen*)leaf1_ptr;
169 AP_FLOAT len0 = leaf0->get_seq()->weighted_base_count();
170 AP_FLOAT len1 = leaf1->get_seq()->weighted_base_count();
173 if (len0<len1)
return 1;
174 if (len0>len1)
return -1;
177 int cmp = strcmp(leaf1->name, leaf0->name);
183 if (!val)
return val;
189 AP_tree_nlen *leaf =
DOWNCAST(AP_tree_nlen*, troot->makeNode());
191 leaf->forget_origin();
193 leaf->gb_node = gb_node;
197 leaf->set_seq(troot->get_seqTemplate()->dup());
201 error =
GBS_global_string(
"Species %s has too short sequence (%f, minimum is %i)",
203 leaf->get_seq()->weighted_base_count(),
216 static long toInserted(
const char *,
long val,
void *cd_toInsert) {
218 AP_tree_nlen *
node = (AP_tree_nlen*)val;
220 toInsert->push_back(node);
236 if (!toInsert)
return 0;
237 if (!inTree)
return 1 +
calc_steps(toInsert-2, 2);
242 return (edges+1)*insertNow +
calc_steps(toInsert-insertNow, inTree+insertNow);
246 AP_tree_nlen *subNode;
247 AP_tree_nlen *upNode;
249 bool valid()
const {
return subNode && upNode; }
255 upNode(e->otherNode(subNode))
263 subNode = new_subtree;
287 bool operator() (AP_tree_nlen *i, AP_tree_nlen *j) {
return strcmp(i->name, j->name)<0; }
293 typedef map<AP_tree_nlen*, BestEdge> BestEdge4Node;
294 BestEdge4Node bestpos;
304 bool speciesInserted =
false;
313 AP_tree_nlen *species = *curr++;
315 if (speciesInserted) {
316 species->moveTo(edge);
319 species->insert(edge->
sonNode());
320 speciesInserted =
true;
326 BestEdge4Node::iterator found = bestpos.find(species);
327 if (found == bestpos.end() || pars<found->second.pars) {
328 bestpos[species] =
BestEdge(betweenNodes, pars);
332 AP_tree_nlen *rot_node =
rootNode()->get_leftson();
333 if (rot_node == species) {
334 rot_node = rot_node->get_brother();
336 ap_assert(rot_node->get_brother() == species);
339 Mutations rot_costs = rot_node->stored_costs();
344 if (curr == end)
break;
346 AP_tree_nlen *nextSpec = *curr++;
350 found = bestpos.find(nextSpec);
351 if (found == bestpos.end() || pars<found->second.pars) {
352 bestpos[nextSpec] =
BestEdge(betweenNodes, pars);
362 typedef list<AP_tree_nlen*> NodeList;
363 typedef map<AP_tree_edge*, NodeList> NodesAtEdge;
372 NodesAtEdge::iterator at = atEdge.find(edge);
373 if (at == atEdge.end()) {
374 atEdge[edge] = NodeList(1, *
s);
377 at->second.push_back(*
s);
381 #if defined(DEVEL_RALF)
385 set<AP_tree_edge*> edgeInTree;
390 edgeInTree.insert(edge);
393 for (BestEdge4Node::iterator b = bestpos.begin(); b != bestpos.end(); ++b) {
396 if (edgeInTree.find(e) == edgeInTree.end()) {
405 typedef list<NodesAtEdge::iterator> InsertOrder;
406 InsertOrder insertOrder;
412 NodesAtEdge::iterator at = atEdge.find(edge);
413 if (at != atEdge.end()) {
414 insertOrder.push_back(at);
419 typedef list<AP_subtree> OptiList;
423 for (InsertOrder::iterator o = insertOrder.begin(); o != insertOrder.end(); ++o) {
424 NodesAtEdge::iterator e = *o;
426 NodeList& nodes = e->second;
430 AP_tree_nlen *brother = edge->
sonNode();
431 size_t nodes_size = nodes.size();
433 #if defined(ASSERTION_USED)
434 ap_assert(bestpos[nodes.front()].edge() == edge);
437 if (nodes_size == 1) {
438 nodes.front()->insert(brother);
442 bool atLeaf = brother->is_leaf();
449 #if defined(UNIT_TESTS)
453 typedef vector<AP_tree_nlen*> NodeVector;
455 NodeVector toSort(nodes.begin(), nodes.end());
457 nodes = NodeList(toSort.begin(), toSort.end());
461 AP_tree_nlen *at = brother;
462 for (NodeList::iterator n = nodes.begin(); n != nodes.end(); ++n) {
469 AP_tree_nlen *ourFather = brother->get_father();
470 AP_tree_nlen *addedSubtree = brother->get_brother();
471 ap_assert(addedSubtree->is_ancestor_of(at));
476 for (
int i = 0; i<2; ++i) {
477 AP_tree_nlen *rest = toRest->
otherNode(ourFather);
478 if (rest != brother && rest != addedSubtree) {
481 toRest = ourFather->nextEdge(toRest);
484 optiPos.push_back(
AP_subtree(toRest, ourFather));
485 ap_assert(optiPos.back().subtreeRoot() == ourFather);
490 AP_tree_edge *subEdge = ourFather->edgeTo(addedSubtree);
491 optiPos.push_back(
AP_subtree(subEdge, addedSubtree));
492 ap_assert(optiPos.back().subtreeRoot() == addedSubtree);
496 progress.
inc_by(nodes_size);
510 prev_pars = curr_pars;
511 for (OptiList::iterator op = optiPos.begin(); op != optiPos.end(); ++op) {
513 AP_tree_nlen *subtreeRoot = op->subtreeRoot();
523 if (!(this_pars<curr_pars)) {
527 curr_pars = this_pars;
531 AP_tree_nlen *newSubtreeRoot = subtreeEdge->
otherNode(father);
532 if (newSubtreeRoot != subtreeRoot) {
533 op->setSubtreeRoot(newSubtreeRoot);
537 while (curr_pars<prev_pars);
546 int inTree = tree ? tree->count_leafs() : 0;
556 speciesToInsert.reserve(toInsert);
578 AP_tree_nlen *s1 = *curr++;
579 AP_tree_nlen *s2 = *curr++;
581 s1->initial_insert(s2, troot);
597 if (insertNow == toInsert)
break;
601 advance(partEnd, insertNow);
607 toInsert -= insertNow;
613 if (oldRootEdge) oldRootEdge->
set_root();
629 root->reset_subtree_layout();
630 oldrootleft = root->get_leftson();
631 oldrootright = root->get_rightson();
642 if (name && strlen(name)) {
650 else error =
"Please select a species";
664 arb_progress progress(quick ?
"Quick add" :
"Add + NNI");
685 GBT_message(gb_main,
"No species (left) to insert");
703 progress.
subtitle(
"local optimize (repeated NNI)");
707 if (pars_curr == pars_prev)
break;
709 pars_prev = pars_curr;
722 error =
"Tree lost (no leafs left)";
725 insertPerf.
dump(stdout);
740 mutable AP_tree_nlen *
self;
741 const AP_tree_nlen *best_full_match;
748 AP_tree_nlen *get_self()
const {
760 gb_species(gb_species_),
762 best_full_match(
NULp),
769 : gb_species(other.gb_species),
771 best_full_match(other.best_full_match),
772 overlap(other.overlap),
773 penalty(other.penalty),
774 released(other.released),
775 multi_match(other.multi_match),
776 multi_list(other.multi_list)
786 void test_match(
const AP_tree_nlen *leaf_full);
790 const char *name = get_self()->name;
797 return string(best_full_match->name)+multi_list;
801 AP_tree_nlen *
s =
self;
807 void dump(
const char *whichMatch)
const {
809 printf(
"%s match for '%s' is '%s' (overlap=%li penalty=%li)\n",
810 whichMatch, get_name(), best_full_match->name,
820 leaf_full->get_seq()->partial_match(get_self()->get_seq(), &curr_overlap, &curr_penalty);
824 if (curr_overlap > overlap) {
827 else if (curr_overlap == overlap) {
828 if (curr_penalty<penalty) {
831 else if (curr_penalty == penalty) {
834 if (!multi_match) dump(
"better");
835 printf(
"Another equal match is against '%s' (overlap=%li penalty=%li)\n", leaf_full->name, curr_overlap, curr_penalty);
839 multi_list.append(1,
'/');
840 multi_list.append(leaf_full->name);
845 overlap = curr_overlap;
846 penalty = curr_penalty;
847 best_full_match = leaf_full;
856 else if (!multi_match) {
857 printf(
"Worse match against '%s' (overlap=%li penalty=%li)\n", leaf_full->name, curr_overlap, curr_penalty);
866 if (tree->is_leaf() && tree->name) {
869 if (is_partial == 0) {
870 list<PartialSequence>::iterator i = partial.begin();
871 list<PartialSequence>::iterator e = partial.end();
872 for (; i != e; ++i) {
876 else if (is_partial == -1) {
889 static void count_partial_and_full(
const AP_tree_nlen *at,
int *partial,
int *full,
int *zombies,
int default_value,
bool define_if_undef) {
892 int is_partial =
GBT_is_partial(at->gb_node, default_value, define_if_undef);
893 if (is_partial) ++(*partial);
907 if (depth >= *min_depth) {
922 return right ? right : left;
925 return const_cast<AP_tree_nlen*
>(
find_least_deep_leaf(const_cast<const AP_tree_nlen*>(at), depth, min_depth));
929 list<PartialSequence> *partial =
reinterpret_cast<list<PartialSequence> *
>(cd_partial);
942 int full_marked_sequences = 0;
944 arb_progress part_add_progress(
"Adding partial sequences");
947 list<PartialSequence> partial;
951 int marked_found = 0;
952 int partial_marked_sequences = 0;
967 ++full_marked_sequences;
971 ++partial_marked_sequences;
987 if (!error && !marked_found) error =
"There are no marked species";
993 int partials_already_in_tree = partial_marked_sequences - partial.size();
996 if (full_marked_sequences>0)
GBT_message(gb_main,
GBS_global_string(
"%i marked species are declared full sequences", full_marked_sequences));
997 if (partials_already_in_tree>0)
GBT_message(gb_main,
GBS_global_string(
"%i marked species are already in tree", partials_already_in_tree));
999 if (partial.empty()) error =
"No species left to add";
1008 rootNode()->reset_subtree_layout();
1013 list<PartialSequence>::iterator i = partial.begin();
1014 list<PartialSequence>::iterator e = partial.end();
1020 for (; i != e; ++i) i->dump(
"best");
1021 i = partial.begin();
1024 for (; i != e && !
error; ++i) {
1025 const char *name = i->get_name();
1027 if (i->is_multi_match()) {
1029 "(took first of equal scored insertion points: %s)",
1030 name, i->get_multilist().c_str()));
1033 AP_tree_nlen *part_leaf = i->release();
1034 AP_tree_nlen *full_seq =
const_cast<AP_tree_nlen*
>(i->get_best_match());
1035 AP_tree_nlen *brother = full_seq->get_brother();
1037 AP_tree_nlen *target =
NULp;
1039 if (brother->is_leaf()) {
1040 if (brother->gb_node) {
1051 error =
"There are zombies in your tree - please remove them";
1055 int partial_count = 0;
1057 int zombie_count = 0;
1062 error =
"There are zombies in your tree - please remove them";
1064 else if (full_count) {
1071 int depth = INT_MAX;
1080 printf(
"inserting '%s'\n", name);
1082 part_leaf->insert(target);
1089 if (father->rightson == target) {
1090 father->swap_sons();
1095 GBT_LEN orglen = father->get_branchlength()+target->get_branchlength();
1098 target->set_branchlength(orglen);
1099 father->set_branchlength(0);
1104 father->set_branchlength(orglen);
1105 full_seq->set_branchlength(0);
1107 part_leaf->set_branchlength(i->get_branchlength());
1108 printf(
"Adding with branchlength=%f\n", i->get_branchlength());
1115 part_insert_progress.inc_and_check_user_abort(error);
1120 if (full_marked_sequences) {
1157 nt_add(agt, what, quick);
1215 if (currPars == prevPars)
break;
1217 prevPars = currPars;
1230 double balanced_depth = log10(leafs) / log10(2);
1231 int repeat =
int(balanced_depth*2.0 + .5);
1232 if (repeat<1) repeat = 1;
1243 double allBranchProbability = double(repeat)*percent/100.0;
1244 double phase1_weight = 1.0 - 1.0/(30.0 * allBranchProbability);
1248 rootEdge()->mixTree(repeat, percent, whichEdges);
1251 progress.
subtitle(
"calculating branchlengths");
1298 "*minimum_static_reduction",
1299 "Sets paths allowed by static reduction to maximum\n(causing the minimal reduction)",
1300 "s_depth1='8';s_depth2='6';s_depth3='6';s_depth4='6';s_depth5='6';static='1'"
1303 "*whole_tree_level8",
1304 "Level-8-optimization of whole tree\n(no path reduction)",
1305 "dynamic='0';incdepth='0';marked_only='0';maxdepth='8';skip_folded='0';static='0'"
1311 AW_window_simple *aws =
new AW_window_simple;
1312 aws->init(aw_root,
"TREE_OPTIMIZE",
"Tree optimization");
1317 aws->create_button(
"CLOSE",
"CLOSE",
"C");
1321 aws->create_button(
"HELP",
"HELP",
"H");
1324 aws->label(
"Only subtrees containing marked species");
1328 aws->label(
"Do not modify folded subtrees");
1331 aws->button_length(18);
1335 aws->create_button(
"REC_NNI",
"Recursive NNI",
"N");
1337 aws->at(
"heuristic");
1338 aws->callback(makeWindowCallback(
NT_optimize, ntw));
1339 aws->create_button(
"HEURISTIC",
"Heuristic\noptimizer",
"H");
1344 aws->at(
"settings");
1346 aws->create_button(
"SETTINGS",
"Settings",
"S");
1348 aws->at(
"randomize");
1350 aws->create_button(
"RANDOMIZE",
"Randomize tree",
"R");
1352 aws->button_length(5);
1363 #if defined(TESTMENU)
1370 static void setBranchlens(AP_tree_nlen *
node,
double newLen) {
1371 node->setBranchlen(newLen, newLen);
1373 if (!node->is_leaf()) {
1374 setBranchlens(node->get_leftson(), newLen);
1375 setBranchlens(node->get_rightson(), newLen);
1382 setBranchlens(root, 1.0);
1386 static void TESTMENU_treeStats(
AW_window *) {
1393 root->calcTreeInfo(tinfo);
1396 puts(
"Tree stats:");
1398 printf(
"nodes =%6zu\n", tinfo.
nodes());
1400 printf(
" groups =%6zu\n", tinfo.
groups);
1401 printf(
" leafs =%6zu\n", tinfo.
leafs);
1402 printf(
" unlinked =%6zu (zombies?)\n", tinfo.
unlinked);
1403 printf(
" linked =%6zu\n", tinfo.
linked());
1404 printf(
" marked =%6zu\n", tinfo.
marked);
1422 awm->
insert_menu_topic(
"setlens",
"Set branchlens",
"b",
"",
AWM_ALL, makeWindowCallback(TESTMENU_setBranchlen, ntw));
1423 awm->
insert_menu_topic(
"sorttreebyname",
"Sort tree by name",
"o",
"",
AWM_ALL, makeWindowCallback(TESTMENU_sortTreeByName, ntw));
1435 if (strlen(filter)) {
1437 for (i=0; filter[i]; i++) {
1438 if (filter[i] !=
'0') ali_len++;
1445 error =
"Please select a valid alignment";
1453 if (tree_size == -1) {
1454 error =
"Please select an existing tree";
1457 size_t expected_memuse = (ali_len * tree_size * 4 / 1024);
1459 warning =
GBS_global_string(
"Estimated memory usage (%s) exceeds physical memory (will swap)\n"
1460 "(did you specify a filter?)",
1485 void count(AP_tree_nlen *node);
1495 if (node->is_leaf()) {
1501 count(node->get_leftson());
1502 count(node->get_rightson());
1521 if (warning && !error) {
1523 bool cont =
aw_ask_sure(
"swap_warning", question);
1526 if (!cont) error =
"User abort";
1545 awm->
init(awr,
"ARB_PARSIMONY",
"ARB_PARSIMONY", 400, 200);
1562 error =
"Failed to load the selected tree";
1574 "Tree vanished", aliname);
1582 progress.
subtitle(
"Calculating inner nodes");
1583 GLOBAL_PARS->get_root_node()->costs();
1585 progress.
subtitle(
"Checking amount of data");
1587 lowData.
count(GLOBAL_PARS->get_root_node());
1589 bool warned =
false;
1615 AWT_create_debug_menu(awm);
1668 awm->
insert_menu_topic(
"calc_upper_bootstrap_indep",
"Calculate Upper Bootstrap Limit (dependent NNI)",
"U",
"pa_bootstrap.hlp",
AWM_ALL, makeWindowCallback(
NT_bootstrap, ntw,
false));
1669 awm->
insert_menu_topic(
"calc_upper_bootstrap_dep",
"Calculate Upper Bootstrap Limit (independent NNI)",
"i",
"pa_bootstrap.hlp",
AWM_ALL, makeWindowCallback(
NT_bootstrap, ntw,
true));
1673 #if defined(TESTMENU)
1674 init_TEST_menu(awm, ntw);
1728 int db_treex, db_treey;
1736 int db_stackx, db_stacky;
1738 awm->
label(
"Stored");
1745 int db_parsx, db_parsy;
1747 awm->
label(
"Current Pars:");
1766 awm->
at_x(db_stackx);
1776 awm->
at_x(db_parsx);
1778 awm->
label(
"Optimal Pars:");
1786 awm->
at_x(db_treex);
1823 AW_window_simple *aws =
new AW_window_simple;
1824 aws->init(awr,
"PARS_PROPS",
"SET PARSIMONY OPTIONS");
1827 aws->button_length(10);
1828 aws->label_length(10);
1832 aws->create_button(
"ABORT",
"ABORT",
"A");
1836 aws->create_button(
"HELP",
"HELP",
"H");
1849 aws->create_button(
"SELECT_CSP", AWAR_COLUMNSTAT_NAME);
1852 aws->at(
"alignment");
1858 aws->callback(makeWindowCallback(
pars_start_cb, weighted_filter, cmds));
1860 aws->create_button(
"GO",
"GO",
"G");
1870 Static.depth[0] = 2;
1887 #if defined(UNIT_TESTS)
1892 Static.enabled =
true;
1893 Static.depth[0] = 2;
1894 Static.depth[1] = 8;
1895 Static.depth[2] = 6;
1896 Static.depth[3] = 6;
1897 Static.depth[4] = 6;
1898 Static.depth[5] = 6;
1900 Dynamic.enabled =
true;
1901 Dynamic.start = 100;
1982 AWT_create_db_browser_awars(awr, aw_def);
1994 if (AD_map_viewer_aw_root &&
2007 AD_map_viewer_aw_root = aw_root;
2012 const char *db_server =
":";
2016 while (argc>=2 && argv[1][0] ==
'-') {
2019 if (!strcmp(argv[0],
"-quit")) cmds.
quit = 1;
2020 else if (!strcmp(argv[0],
"-add_marked")) cmds.
add_marked = 1;
2021 else if (!strcmp(argv[0],
"-add_selected")) cmds.
add_selected = 1;
2023 else if (!strcmp(argv[0],
"-calc_bootstrap")) cmds.
calc_bootstrap = 1;
2025 fprintf(stderr,
"Unknown option '%s'\n", argv[0]);
2027 printf(
" Options: Meaning:\n"
2029 " -add_marked add marked species (without changing topology)\n"
2030 " -add_selected add selected species (without changing topology)\n"
2031 " -calc_branchlengths calculate branch lengths only\n"
2032 " -calc_bootstrap estimate bootstrap values\n"
2033 " -quit quit after performing operations\n"
2041 if (argc==2) db_server = argv[1];
2050 AWT_announce_db_to_browser(gb_main,
GBS_global_string(
"ARB-database (%s)", db_server));
2086 bool update =
false;
2089 FILE *out = fopen(outfile,
"wt");
2099 #if defined(AUTO_UPDATE_IF_CHANGED)
2100 if (!match_exp_topo) update =
true;
2108 if (update) TEST_COPY_FILE(outfile, expected);
2114 return all().ofgroup(fulfilled);
2122 long combines_b4_costCalc = env.combines_performed();
2125 AP_FLOAT new_pars = env.root_node()->costs();
2126 long combines_by_costCalc = env.combines_performed();
2131 return all().ofgroup(fulfilled);
2134 #define TEST_EXPECT_SAVED_TOPOLOGY(env,exp_topo) TEST_EXPECTATION(topologyEquals(env.root_node(), exp_topo))
2135 #define TEST_EXPECT_SAVED_TOPOLOGY__BROKEN(env,exp_topo,got_topo) TEST_EXPECTATION__BROKEN(topologyEquals(env.root_node(), exp_topo), topologyEquals(env.root_node(), got_topo))
2137 #define TEST_EXPECT_PARSVAL(env,exp_pars) TEST_EXPECT_EQUAL(env.root_node()->costs(), exp_pars);
2138 #define TEST_EXPECT_ONLY_PARSVAL_COMBINES(env,exp_pars,exp_combines) TEST_EXPECTATION(calcCostsCausesCombines(env, exp_pars, exp_combines))
2142 #define TEST_EXPECT_KNOWN_PARSVAL(env,exp_pars) TEST_EXPECT_ONLY_PARSVAL_COMBINES(env,exp_pars,0)
2160 template <
typename SEQ>
2163 case MOD_REMOVE_MARKED:
2167 case MOD_QUICK_READD:
2179 case MOD_ADD_PARTIAL:
2191 case MOD_OPTI_GLOBAL:
2195 case MOD_MIX_TREE: {
2196 long leafs =
rootNode()->count_leafs();
2203 template <
typename SEQ>
2220 modifyTopology(env, mod);
2223 if (mod != MOD_REMOVE_MARKED) {
2230 if (pars_expected != -1) {
2247 return all().ofgroup(fulfilled);
2254 long pars_min = LONG_MAX;
2255 long pars_max = LONG_MIN;
2257 for (
int depth_first = 0; depth_first<=1; ++depth_first) {
2258 for (
int push_local = 0; push_local<=1; ++push_local) {
2261 if (!push_local) ap_main->
remember();
2265 if (push_local) ap_main->
remember();
2268 pars_min =
std::min(pars, pars_min);
2269 pars_max =
std::max(pars, pars_max);
2270 if (push_local) ap_main->
revert();
2272 if (!push_local) ap_main->
revert();
2279 return all().ofgroup(fulfilled);
2282 static GBDATA *copy_to(
GBDATA *gb_species,
const char *newShortname) {
2287 if (!gb_new_species) {
2292 if (!error) error =
GBT_write_string(gb_new_species,
"name", newShortname);
2295 ap_assert(contradicted(gb_new_species, error));
2296 return gb_new_species;
2299 inline void mark_only(
GBDATA *gb_species) {
2305 inline void mark(
GBDATA *gb_species) {
2315 inline int is_partial(
GBDATA *gb_species) {
2320 template <
typename SEQ>
2325 AP_tree_nlen *node_in_tree = env.
root_node()->findLeafNamed(name);
2329 const char *brother = node_in_tree->get_brother()->
name;
2333 return all().ofgroup(fulfilled);
2336 template <
typename SEQ>
2341 mark_only(gb_added_species);
2343 fulfilled.
add(modifyingTopoResultsIn(MOD_ADD_PARTIAL, topo, pars_expected, env,
false));
2347 fulfilled.
add(addedAsBrotherOf(name, allowedBrothers, env));
2349 return all().ofgroup(fulfilled);
2352 static int seqDiff(
GBDATA *
gb_main,
const char *aliname,
const char *species1,
const char *species2,
int startPos,
int endPos) {
2359 if (gb_species1 && gb_species2) {
2363 if (gb_seq1 && gb_seq2) {
2367 int maxPos1 = strlen(seq1)-1;
2368 #if defined(ASSERTION_USED)
2369 int maxPos2 = strlen(seq2)-1;
2373 if (endPos>maxPos1) endPos = maxPos1;
2376 for (
int p = startPos; p<=endPos; ++p) {
2377 diffs += seq1[p] != seq2[p];
2388 static GBDATA *createPartialSeqFrom(
GBDATA *gb_main,
const char *aliname,
const char *dest_species,
const char *source_species,
int startPos,
int endPos) {
2394 if (gb_source_species) {
2395 GBDATA *gb_dest_species = copy_to(gb_source_species, dest_species);
2400 int maxPos = strlen(seq)-1;
2402 startPos =
std::min(startPos, maxPos);
2405 if (startPos>0) memset(seq,
'.', startPos);
2406 if (endPos<maxPos) memset(seq+endPos+1,
'.', maxPos-endPos);
2411 gb_result = gb_dest_species;
2413 fprintf(stderr,
"created partial '%s' from '%s' (seq='%s')\n", dest_species, source_species, seq);
2424 static GB_ERROR modifyOneBase(
GBDATA *gb_species,
const char *aliname,
char cOld,
char cNew) {
2426 GB_ERROR error =
"failed to modifyOneBase";
2432 char *B = strchr(seq, cOld);
2434 error =
"does not contain base in modifyOneBase";
2447 static long unmark_unwanted(
const char *,
long cd_gbd,
void*) {
2453 void TEST_SLOW_nucl_tree_modifications() {
2454 const char *aliname =
"ali_5s";
2458 TEST_EXPECT_SAVED_TOPOLOGY(env,
"nucl-initial");
2460 const int PARSIMONY_ORG = 302;
2461 TEST_EXPECT_ONLY_PARSVAL_COMBINES(env, PARSIMONY_ORG, 14);
2470 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_REMOVE_MARKED,
"nucl-removed", PARSIMONY_ORG-94, env,
true));
2473 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_READD,
"nucl-add-quick", PARSIMONY_ORG-18, env,
true));
2476 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_READD_NNI,
"nucl-add-NNI", PARSIMONY_ORG-20, env,
true));
2484 const int SPLIT = 55;
2485 GBDATA *CorGlutP = createPartialSeqFrom(gb_main, aliname,
"CorGlutP",
"CorGluta", 0, SPLIT);
2486 GBDATA *CloButyP = createPartialSeqFrom(gb_main, aliname,
"CloButyP",
"CloButyr", SPLIT+1, INT_MAX);
2487 GBDATA *CloButyM = createPartialSeqFrom(gb_main, aliname,
"CloButyM",
"CloButyr", SPLIT+1, INT_MAX);
2493 TEST_REJECT_ZERO(seqDiff(gb_main, aliname,
"CorGlutP",
"CorGluta", 0, INT_MAX));
2494 TEST_REJECT_ZERO(seqDiff(gb_main, aliname,
"CloButyP",
"CloButyr", 0, INT_MAX));
2495 TEST_REJECT_ZERO(seqDiff(gb_main, aliname,
"CloButyM",
"CloButyr", 0, INT_MAX));
2497 TEST_REJECT_ZERO(seqDiff(gb_main, aliname,
"CloButyM",
"CloButyP", SPLIT+1, INT_MAX));
2500 TEST_EXPECT_ZERO(seqDiff(gb_main, aliname,
"CloButyr",
"CloButy2", SPLIT+1, INT_MAX));
2503 TEST_REJECT_ZERO(seqDiff(gb_main, aliname,
"CloButyr",
"CloButy2", 0, INT_MAX));
2511 TEST_EXPECTATION(addingPartialResultsIn(CloButyP,
"CloButyr;CloButy2",
"nucl-addPart-CloButyP", PARSIMONY_ORG, env));
2518 TEST_EXPECTATION(addingPartialResultsIn(CorGlutP,
"CorGluta",
"nucl-addPart-CorGlutP", PARSIMONY_ORG, env));
2520 TEST_EXPECTATION(addingPartialResultsIn(CloButyP,
"CloButyr;CloButy2",
"nucl-addPart-CorGlutP-CloButyP", PARSIMONY_ORG, env));
2529 mark_only(CorGlutP);
2536 const int PARSIMONY_ADDED = PARSIMONY_ORG;
2538 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_READD,
"nucl-addPartialAsFull-CorGlutP", PARSIMONY_ADDED, env,
false));
2545 TEST_EXPECTATION(addingPartialResultsIn(CloButyP,
"CloButyr;CloButy2",
NULp, PARSIMONY_ADDED, env));
2550 TEST_EXPECTATION(addingPartialResultsIn(CloButyM,
"CloButyP",
"nucl-addPart-bug609",
2558 TEST_EXPECT_SAVED_TOPOLOGY(env,
"nucl-initial");
2560 const int PARSIMONY_NNI_MARKED = PARSIMONY_ORG-18;
2561 const int PARSIMONY_NNI_ALL = PARSIMONY_ORG-18;
2562 const int PARSIMONY_OPTI_MARKED = PARSIMONY_ORG-25;
2563 const int PARSIMONY_OPTI_VISIBLE = PARSIMONY_ORG-26;
2564 const int PARSIMONY_OPTI_ALL = PARSIMONY_ORG-36;
2583 TEST_EXPECT_KNOWN_PARSVAL(env, PARSIMONY_ORG);
2587 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_CALC_LENS,
"nucl-calclength", PARSIMONY_ORG, env,
false));
2596 const char *tested_roots[] = {
2603 for (
size_t r = 0; r<
ARRAY_ELEMS(tested_roots); ++r) {
2604 const char *leafName = tested_roots[r];
2605 env.
root_node()->findLeafNamed(leafName)->set_root();
2610 TEST_EXPECT_SAVED_TOPOLOGY(env,
"nucl-calclength");
2618 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_NNI,
"nucl-opti-NNI", PARSIMONY_NNI_MARKED, env,
true));
2621 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_GLOBAL,
"nucl-opti-marked-global", PARSIMONY_OPTI_MARKED, env,
true));
2628 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_GLOBAL,
"nucl-opti-visible-global", PARSIMONY_OPTI_VISIBLE, env,
true));
2633 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_GLOBAL,
"nucl-opti-global", PARSIMONY_OPTI_ALL, env,
true));
2653 TEST_EXPECT_KNOWN_PARSVAL(env, PARSIMONY_ORG);
2657 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_CALC_LENS,
"nucl-calclength", PARSIMONY_ORG, env,
false));
2660 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_NNI,
"nucl-opti-all-NNI", PARSIMONY_NNI_ALL, env,
true));
2665 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_GLOBAL,
"nucl-opti-visible-global", PARSIMONY_OPTI_VISIBLE, env,
false));
2675 AP_tree_nlen *CloTyrob = env.
root_node()->findLeafNamed(
"CloTyrob");
2676 AP_tree_nlen *
group = CloTyrob->get_father();
2678 group->gr.grouped =
false;
2680 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_GLOBAL,
"nucl-opti-global", PARSIMONY_OPTI_ALL, env,
true));
2688 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_READD,
"nucl-readdall-quick", PARSIMONY_ORG-7, env,
true));
2692 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_READD_NNI,
"nucl-readdall-NNI", PARSIMONY_ORG-8, env,
true));
2700 AP_tree_nlen *CloTyrob = env.
root_node()->findLeafNamed(
"CloTyrob");
2701 mark_only(CloTyrob->gb_node);
2712 for (
int i = 0; seq[i]; ++i) {
2714 if (keep_bases) --keep_bases;
2725 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_REMOVE_MARKED,
NULp, PARSIMONY_ORG-1, env,
false));
2746 void TEST_SLOW_prot_tree_modifications() {
2747 const char *aliname =
"ali_tuf_pro";
2751 TEST_EXPECT_SAVED_TOPOLOGY(env,
"prot-initial");
2753 const int PARSIMONY_ORG = 1081;
2754 TEST_EXPECT_ONLY_PARSVAL_COMBINES(env, PARSIMONY_ORG, 10);
2764 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_REMOVE_MARKED,
"prot-removed", PARSIMONY_ORG-146, env,
true));
2767 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_READD,
"prot-add-quick", PARSIMONY_ORG, env,
true));
2770 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_READD_NNI,
"prot-add-NNI", PARSIMONY_ORG, env,
true));
2778 GBDATA *MucRaceP = createPartialSeqFrom(gb_main, aliname,
"MucRaceP",
"MucRacem", 0, 60+4);
2779 GBDATA *StrCoelP = createPartialSeqFrom(gb_main, aliname,
"StrCoelP",
"StrCoel9", 66-1+4, 184-1+4);
2780 GBDATA *StrCoelM = createPartialSeqFrom(gb_main, aliname,
"StrCoelM",
"StrCoel9", 66-1+4, 184-1+4);
2788 TEST_EXPECTATION(addingPartialResultsIn(StrCoelP,
"StrCoel9;StrRamo3",
"prot-addPart-StrCoelP", PARSIMONY_ORG, env));
2795 TEST_EXPECTATION(addingPartialResultsIn(MucRaceP,
"MucRacem",
"prot-addPart-MucRaceP", PARSIMONY_ORG, env));
2797 TEST_EXPECTATION(addingPartialResultsIn(StrCoelP,
"StrCoel9;StrRamo3",
"prot-addPart-MucRaceP-StrCoelP", PARSIMONY_ORG, env));
2806 mark_only(MucRaceP);
2813 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_READD,
"prot-addPartialAsFull-MucRaceP", PARSIMONY_ORG, env,
false));
2821 TEST_EXPECTATION(addingPartialResultsIn(StrCoelP,
"StrCoel9;StrRamo3",
NULp, PARSIMONY_ORG, env));
2826 TEST_EXPECTATION(addingPartialResultsIn(StrCoelM,
"StrCoelP",
"prot-addPart-bug609",
2834 TEST_EXPECT_SAVED_TOPOLOGY(env,
"prot-initial");
2836 const unsigned mixseed = 8164724;
2838 const long PARSIMONY_MIXED = PARSIMONY_ORG + 1519;
2839 const long PARSIMONY_NNI_MARKED = PARSIMONY_ORG + 1053;
2840 const long PARSIMONY_NNI_ALL = PARSIMONY_ORG;
2841 const long PARSIMONY_OPTI_MARKED = PARSIMONY_ORG;
2842 const long PARSIMONY_OPTI_ALL = PARSIMONY_ORG;
2848 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_MIX_TREE,
"prot-mixed", PARSIMONY_MIXED, env,
false));
2869 TEST_EXPECT_KNOWN_PARSVAL(env, PARSIMONY_MIXED);
2873 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_CALC_LENS,
"prot-calclength", PARSIMONY_MIXED, env,
false));
2882 const char *tested_roots[] = {
2889 for (
size_t r = 0; r<
ARRAY_ELEMS(tested_roots); ++r) {
2890 TEST_ANNOTATE(tested_roots[r]);
2891 const char *leafName = tested_roots[r];
2892 env.
root_node()->findLeafNamed(leafName)->set_root();
2897 TEST_EXPECT_SAVED_TOPOLOGY(env,
"prot-calclength");
2904 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_NNI,
"prot-opti-NNI", PARSIMONY_NNI_MARKED, env,
true));
2907 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_GLOBAL,
"prot-opti-marked-global", PARSIMONY_OPTI_MARKED, env,
true));
2918 TEST_EXPECT_KNOWN_PARSVAL(env, PARSIMONY_MIXED);
2922 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_CALC_LENS,
"prot-calclength", PARSIMONY_MIXED, env,
false));
2925 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_NNI,
"prot-opti-all-NNI", PARSIMONY_NNI_ALL, env,
true));
2930 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_OPTI_GLOBAL,
"prot-opti-global", PARSIMONY_OPTI_ALL, env,
false));
2939 void TEST_node_stack() {
2942 const char *aliname =
"ali_5s";
2945 TEST_EXPECT_SAVED_TOPOLOGY(env,
"nucl-initial");
2947 const int PARSIMONY_ORG = 302;
2948 TEST_EXPECT_ONLY_PARSVAL_COMBINES(env, PARSIMONY_ORG, 14);
2956 env.
root_node()->findLeafNamed(
"CytAquat")->set_root();
2967 env.
root_node()->findLeafNamed(
"CloButyr")->set_root();
2980 env.
root_node()->findLeafNamed(
"CloBifer")->set_root();
2981 env.
root_node()->findLeafNamed(
"CloTyrob")->set_root();
2992 for (
int calcCostsBetween = 0; calcCostsBetween<2; ++calcCostsBetween) {
2995 TEST_EXPECT_PARSVAL(env, PARSIMONY_ORG);
2999 env.
root_node()->findLeafNamed(
"CytAquat")->set_root();
3001 if (calcCostsBetween) {
3002 TEST_EXPECT_ONLY_PARSVAL_COMBINES(env, PARSIMONY_ORG, 2);
3005 env.
root_node()->findLeafNamed(
"CloButyr")->set_root();
3008 TEST_EXPECT_ONLY_PARSVAL_COMBINES(env, PARSIMONY_ORG, 6);
3013 TEST_EXPECT_KNOWN_PARSVAL(env, PARSIMONY_ORG);
3022 env.
root_node()->findLeafNamed(
"CloInnoc")->moveNextTo(env.
root_node()->findLeafNamed(
"CytAquat"), 0.5);
3024 env.
root_node()->findLeafNamed(
"CloInnoc")->set_root();
3026 env.
root_node()->findLeafNamed(
"CytAquat")->moveNextTo(env.
root_node()->findLeafNamed(
"CloPaste"), 0.5);
3028 env.
root_node()->findLeafNamed(
"CloPaste")->set_root();
3030 env.
root_node()->findLeafNamed(
"CloPaste")->moveNextTo(env.
root_node()->findLeafNamed(
"CloInnoc"), 0.5);
3034 AP_tree_nlen *son_of_brother;
3035 AP_tree_nlen *brother_of_father;
3039 AP_tree_nlen *son_of_root = env.
root_node()->get_leftson();
3042 son_of_brother = son_of_root->get_brother()->get_leftson();
3043 son_of_root->moveNextTo(son_of_brother, 0.5);
3049 AP_tree_nlen *son_of_root = env.
root_node()->get_leftson();
3050 AP_tree_nlen *grandson_of_root = son_of_root->get_brother()->get_rightson();
3053 son_of_brother = grandson_of_root->get_brother()->get_leftson();
3054 grandson_of_root->moveNextTo(son_of_brother, 0.5);
3058 AP_tree_nlen *some_leaf = env.
root_node()->findLeafNamed(
"CloBifer");
3062 son_of_brother = some_leaf->get_brother()->get_leftson();
3063 some_leaf->moveNextTo(son_of_brother, 0.5);
3067 brother_of_father = some_leaf->get_father()->get_brother();
3068 some_leaf->moveNextTo(brother_of_father, 0.5);
3076 TEST_EXPECT_ONLY_PARSVAL_COMBINES(env, PARSIMONY_ORG+5, 6);
3083 TEST_EXPECT_KNOWN_PARSVAL(env, PARSIMONY_ORG);
3088 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_READD,
"nucl-add-quick", PARSIMONY_ORG-18, env,
true));
3120 const char *testSingle[] = {
3129 for (
int i = 0; testSingle[i]; ++i) {
3130 for (
int swapped = 0; swapped<2; ++swapped) {
3131 TEST_ANNOTATE(
GBS_global_string(
"single=%s swapped=%i", testSingle[i], swapped));
3136 AP_tree_nlen *old_rightson = env.
root_node()->get_rightson();
3137 env.
root_node()->get_leftson()->get_rightson()->set_root();
3138 old_rightson->get_leftson()->set_root();
3139 old_rightson->set_root();
3145 mark_only(env.
root_node()->findLeafNamed(testSingle[i])->gb_node);
3174 for (
int remove_from_lower_subtree = 0; remove_from_lower_subtree<2; ++remove_from_lower_subtree) {
3175 TEST_ANNOTATE(
GBS_global_string(
"remove_from_lower_subtree=%i", remove_from_lower_subtree));
3178 mark_only(env.
root_node()->findLeafNamed(
"CloButy2")->gb_node);
3179 mark(env.
root_node()->findLeafNamed(
"CloButyr")->gb_node);
3180 mark(env.
root_node()->findLeafNamed(
"CloCarni")->gb_node);
3181 mark(env.
root_node()->findLeafNamed(
"CloPaste")->gb_node);
3185 if (remove_from_lower_subtree) {
3206 void TEST_node_edge_resources() {
3207 const char *aliname =
"ali_5s";
3211 #define STATE_STACK_SIZE sizeof(StateStack) // 8 (Cxx11) or 16 (older C++); maybe 4/8 in 32bit
3218 #else // !defined(ARB_64)
3228 #else // !defined(ARB_64)
3235 const int PARSIMONY_ORG = 302;
3236 TEST_EXPECT_ONLY_PARSVAL_COMBINES(env, PARSIMONY_ORG, 14);
3238 AP_tree_nlen *CloButyr = env.
root_node()->findLeafNamed(
"CloButyr");
3239 AP_tree_nlen *CloButy2 = env.
root_node()->findLeafNamed(
"CloButy2");
3242 AP_tree_nlen *CorAquat = env.
root_node()->findLeafNamed(
"CorAquat");
3243 AP_tree_nlen *CurCitre = env.
root_node()->findLeafNamed(
"CurCitre");
3248 for (
int test = 1; test<=8; ++test) {
3254 for (
int mode = 0; mode<=3; ++mode) {
3255 bool accept_outer = mode&2;
3256 bool accept_inner = mode&1;
3258 TEST_ANNOTATE(
GBS_global_string(
"accept_outer=%i accept_inner=%i (mode=%i, test=%i)", accept_outer, accept_inner, mode, test));
3267 case 1: CorAquat->insert(CurCitre);
break;
3268 case 2: CorAquat->insert(CurCitre);
break;
3270 case 4: CloButyr->REMOVE();
break;
3271 case 5: CloButyr->REMOVE();
break;
3273 case 7: CloButyr->moveNextTo(CurCitre, 0.5);
break;
3283 case 1: CorAquat->REMOVE();
break;
3285 case 3: CorAquat->insert(CurCitre);
break;
3286 case 4: CloButyr->insert(CloButy2);
break;
3288 case 6: CloButyr->REMOVE();
break;
3289 case 7: CloButyr->moveNextTo(CloButy2, 0.5);
break;
3290 case 8: CorAquat->insert(CurCitre); CorAquat->REMOVE();
break;
3300 case 2: CorAquat->REMOVE();
break;
3301 case 3:
if (CorAquat->father) CorAquat->REMOVE();
break;
3303 case 5: CloButyr->insert(CloButy2);
break;
3304 case 6:
if (!CloButyr->father) CloButyr->insert(CloButy2);
break;
3305 case 7: CloButyr->REMOVE();
break;
3314 if (CorAquat->father) CorAquat->REMOVE();
3315 if (!CloButyr->father) CloButyr->insert(CloButy2);
3319 CorAquat->insert(CurCitre);
3321 TEST_EXPECT_PARSVAL(env, PARSIMONY_ORG);
3325 #endif // UNIT_TESTS
bool isConnectedTo(const AP_tree_nlen *n) const
GB_ERROR GB_begin_transaction(GBDATA *gbd)
void reorderTree(TreeOrder mode)
static void recursiveNNI(AWT_graphic_parsimony *agt, EdgeSpec whichEdges)
#define TEST_EXPECT_COMBINES_PERFORMED(env, expComb)
GB_HASH * GBT_create_marked_species_hash(GBDATA *gb_main)
GB_ERROR GB_copy_dropProtectMarksAndTempstate(GBDATA *dest, GBDATA *source)
void set_aborted(bool aborted_)
void awt_create_filter_awars(AW_root *aw_root, AW_default aw_def, const char *awar_filtername, const char *awar_mapto_alignment)
bool allBranchlengthsAreDefined(AP_tree_nlen *tree)
void get_at_position(int *x, int *y) const
ColumnStat * get_column_stat()
BestEdge(const EdgeBetween &betw, Mutations p)
GB_ERROR GB_commit_transaction(GBDATA *gbd)
void AWT_popup_tree_export_window(AW_window *parent_win, AWT_canvas *scr)
adfiltercbstruct * get_adfiltercbstruct()
void button_length(int length)
AP_subtree(AP_tree_edge *e, AP_tree_nlen *sub_node)
#define AWAR_KL_DYNAMIC_MAXY
GBDATA * GBT_first_marked_species(GBDATA *gb_main)
void NT_remove_leafs(UNFIXED, TREE_canvas *ntw, AWT_RemoveType mode)
static void mixtree_and_calclengths(AWT_graphic_parsimony *agt, int repeat, int percent, EdgeSpec whichEdges)
static void pars_reset_optimal_parsimony(AW_window *aww)
static void nt_reAdd_and_update(AWT_canvas *ntw, AddWhat what, bool quick)
void nt_mode_event(UNFIXED, TREE_canvas *ntw, AWT_COMMAND_MODE mode)
__ATTR__USERESULT_TODO GB_ERROR ARB_init_global_awars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
return string(buffer, length)
static AW_window * createOptimizeWindow(AW_root *aw_root, TREE_canvas *ntw)
void insert_menu_topic(const char *id, const char *name, const char *mnemonic, const char *help_text_, AW_active mask, const WindowCallback &wcb)
void set_tree(AWT_graphic_parsimony *tree_)
const char * name() const OVERRIDE
void NT_remove_species_in_tree_from_hash(AP_tree *tree, GB_HASH *hash)
GB_ERROR GBT_restore_marked_species(GBDATA *gb_main, const char *stored_marked)
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
void load_xfig(const char *file, bool resize=true)
const char * get_window_id() const
void set_logical_root_to(AP_tree *node)
#define AWAR_COLUMNSTAT_NAME
#define AWAR_KL_DYNAMIC_MAXX
#define TEST_REJECT_ZERO(cond)
#define ASSERT_NO_ERROR(errorExpr)
long GBT_mark_all(GBDATA *gb_main, int flag)
static AWT_config_mapping_def optimizer_config_mapping[]
void accept_if(bool cond)
bool is_multi_match() const
#define AWT_TREE_PARS(ntw)
#define AWAR_KL_STATIC_DEPTH4
static void AP_user_pop_cb(AW_window *aww, TREE_canvas *ntw)
AW_window * COLSTAT_create_selection_window(AW_root *aw_root, ColumnStat *column_stat)
Mutations nni_rec(EdgeSpec whichEdges, AP_BL_MODE mode, AP_tree_nlen *skipNode, bool includeStartEdge)
static void pars_create_all_awars(AW_root *awr, AW_default aw_def, GBDATA *gb_main)
void NT_remove_bootstrap(UNFIXED, TREE_canvas *ntw)
char * GBT_tree_2_newick(const TreeNode *tree, NewickFormat format, bool compact)
GB_ERROR GB_end_transaction(GBDATA *gbd, GB_ERROR error)
void clear_save_request()
POS_TREE1 * get_father() const
void PARS_map_viewer(GBDATA *gb_species, AD_MAP_VIEWER_TYPE vtype)
void NT_reset_pzoom_cb(UNFIXED, TREE_canvas *ntw)
static void nt_add(AWT_graphic_parsimony *agt, AddWhat what, bool quick)
static void insert_all_species_into_tree(GB_HASH *&hash)
AWT_graphic_parsimony * graphic_tree()
GB_ERROR save_to_DB(GBDATA *gb_main, const char *name) FINAL_OVERRIDE __ATTR__USERESULT
long combines_performed()
char * ARB_strdup(const char *str)
void AWT_insert_config_manager(AW_window *aww, AW_default default_file_, const char *id, const StoreConfigCallback &store_cb, const RestoreConfigCallback &load_or_reset_cb, const char *macro_id, const AWT_predefined_config *predef)
void remember_user_state()
AP_tree_nlen * get_root_node()
AW_awar * set_minmax(float min, float max)
Validity all_available_pops_will_produce_valid_trees()
AP_tree_nlen * sonNode() const
const char * GBS_global_string(const char *templat,...)
void warning(int warning_num, const char *warning_message)
long GBT_get_alignment_len(GBDATA *gb_main, const char *aliname)
static void insert_species_into_tree(const InsertSpeciesIterator begin, const InsertSpeciesIterator end, arb_progress &progress)
AW_DB_selection * awt_create_TREE_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname)
GBDATA * get_gb_main() const
void AW_POPDOWN(AW_window *window)
static void NT_add_quick(UNFIXED, TREE_canvas *ntw, AddWhat what)
void AW_insert_common_property_menu_entries(AW_window_menu_modes *awmm)
const AP_tree_nlen * get_best_match() const
static long calc_steps(int toInsert, int inTree)
void GBS_free_hash(GB_HASH *hs)
int GBT_is_partial(GBDATA *gb_species, int default_value, bool define_if_undef)
static GB_ERROR nt_best_partial_match_rec(list< PartialSequence > &partial, const AP_tree_nlen *tree)
GBDATA * get_gbmain() const
int GB_unlink(const char *path)
PartialSequence(const PartialSequence &other)
__ATTR__USERESULT GB_ERROR configure_macro_recording(AW_root *aw_root, const char *client_id, GBDATA *gb_main)
#define AWAR_FOOTER_MAX_LEN
ARB_edge rootEdge(TreeRoot *root)
void dump(FILE *out) const
static long transform_gbd_to_leaf(const char *key, long val, void *)
size_t get_user_push_counter() const
#define ARRAY_ELEMS(array)
GBDATA * GB_get_father(GBDATA *gbd)
static void delete_kept_ghostnodes()
#define DOWNCAST(totype, expr)
GB_ERROR GB_delete(GBDATA *&source)
struct Unfixed_cb_parameter * UNFIXED
KL_DYNAMIC_THRESHOLD_TYPE
AP_FLOAT get_branchlength() const
AP_tree_nlen * root_node()
void setSubtreeRoot(AP_tree_nlen *new_subtree)
void set_tree_style(AP_tree_display_style style, AWT_canvas *ntw)
const char * read_char_pntr() const
static void count_partial_and_full(const AP_tree_nlen *at, int *partial, int *full, int *zombies, int default_value, bool define_if_undef)
GB_ERROR GB_export_error(const char *error)
GB_ERROR GBT_add_new_species_changekey(GBDATA *gb_main, const char *name, GB_TYPES type)
int create_mode(const char *pixmap, const char *help_text_, AW_active mask, const WindowCallback &cb)
GB_ERROR GB_await_error()
static ArbParsimony * GLOBAL_PARS
GBDATA * GB_create_container(GBDATA *father, const char *key)
WindowCallback makeHelpCallback(const char *helpfile)
#define TEST_EXPECT(cond)
static void NT_add_and_NNI(UNFIXED, TREE_canvas *ntw, AddWhat what)
void GB_random_seed(unsigned seed)
void NT_insert_collapse_submenu(AW_window_menu_modes *awm, TREE_canvas *ntw)
#define MIN_SEQUENCE_LENGTH
void GBS_hash_do_const_loop(const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
static SearchSettings * settings[SEARCH_PATTERNS]
void GBK_terminate(const char *error) __ATTR__NORETURN
static void calc_branchlengths_and_reorder(AWT_graphic_parsimony *agt)
static void nt_reAdd(AWT_graphic_parsimony *agt, AddWhat what, bool quick)
GB_ERROR load_tree(const char *tree_name)
CONSTEXPR_INLINE int leafs_2_edges(int leafs, TreeModel model)
void AW_save_properties(AW_window *aw)
AWT_graphic_parsimony * get_tree() const
static void nt_add_and_update(AWT_canvas *ntw, AddWhat what, bool quick)
Level get_user_push_counter()
bool is_leaf_edge() const
void generate_tree(WeightedFilter *pars_weighted_filter)
void create_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
const char * GBS_readable_size(unsigned long long size, const char *unit_suffix)
GBDATA * GBT_expect_species(GBDATA *gb_main, const char *name)
int ARB_main(int argc, char *argv[])
AW_window * AW_create_gc_window(AW_root *aw_root, AW_gc_manager *gcman)
void help_text(const char *id)
#define TEST_REJECT_NULL(n)
void NT_jump_cb(UNFIXED, TREE_canvas *ntw, AP_tree_jump_type jumpType)
static void error(const char *msg)
GBDATA * GB_get_root(GBDATA *gbd)
GB_ERROR GB_abort_transaction(GBDATA *gbd)
char * GBT_readOrCreate_string(GBDATA *gb_container, const char *fieldpath, const char *default_value)
void restore_at_from(const AW_at_storage &stored)
AW_window * AW_preset_window(AW_root *root)
expectation_group & add(const expectation &e)
AP_tree_edge * edgeToSubtree() const
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
GBDATA * GB_searchOrCreate_int(GBDATA *gb_container, const char *fieldpath, long default_value)
void label(const char *label)
void GBS_hash_do_sorted_loop(GB_HASH *hs, gb_hash_loop_type func, gbs_hash_compare_function sorter, void *client_data)
void insert_help_topic(const char *labeli, const char *mnemonic, const char *helpText, AW_active mask, const WindowCallback &cb)
size_t GBS_hash_elements(const GB_HASH *hs)
#define TEST_EXPECT_VALID_TREE(tree)
#define AWAR_KL_STATIC_DEPTH1
static void nt_add_partial(AWT_graphic_parsimony *agt)
AP_tree_nlen * subtreeRoot() const
#define AWAR_SPECIES_NAME
AW_window * awt_create_select_filter_win(AW_root *aw_root, adfiltercbstruct *acbs)
#define TEST_EXPECT_ZERO_OR_SHOW_ERRNO(iocond)
const char * get_name() const
static int calculate_default_random_repeat(long leafs)
void optimize_tree(AP_tree_nlen *at, const KL_Settings &settings, arb_progress &progress)
static void pars_start_cb(AW_window *aw_parent, WeightedFilter *wfilt, const PARS_commands *cmds)
static AW_root * AD_map_viewer_aw_root
void count(AP_tree_nlen *node)
static void push_partial(const char *, long val, void *cd_partial)
AP_tree_display_style get_tree_style() const
static const AP_tree_nlen * find_least_deep_leaf(const AP_tree_nlen *at, int depth, int *min_depth)
AWT_graphic_parsimony * get_graphic_tree()
long GBT_size_of_tree(GBDATA *gb_main, const char *tree_name)
UserActionTracker * need_macro_ability()
char * read_string() const
static void NT_reAdd_quick(UNFIXED, TREE_canvas *ntw, AddWhat what)
AP_tree_nlen * rootNode()
CONSTEXPR_INLINE bool valid(SpeciesCreationMode m)
AP_tree_edge * edge() const
AW_awar * awar(const char *awar)
void insert_sub_menu(const char *name, const char *mnemonic, AW_active mask=AWM_ALL)
#define does_differ_from_NULL()
static long toInserted(const char *, long val, void *cd_toInsert)
GB_ERROR open(const char *db_server)
AP_pars_root * get_tree_root()
InsertedSpecies::const_iterator InsertSpeciesIterator
void NT_set_tree_style(UNFIXED, TREE_canvas *ntw, AP_tree_display_style style)
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
void test_match(const AP_tree_nlen *leaf_full)
static __ATTR__NORETURN void pars_exit(AW_window *aww)
static AW_window_menu_modes_opengl * awm
void GBS_hash_do_loop(GB_HASH *hs, gb_hash_loop_type func, void *client_data)
#define AWAR_KL_DYNAMIC_START
long GBT_count_marked_species(GBDATA *gb_main)
#define TEST_EXPECT_ZERO(cond)
void NT_insert_mark_submenus(AW_window_menu_modes *awm, TREE_canvas *ntw, int insert_as_submenu)
static AW_at_storage * make(AW_window *aww, AW_at_storage_type type)
void unlink_awars_from_DB(GBDATA *gb_main)
#define AWAR_OPTI_SKIP_FOLDED
#define stringize_pscan(s)
AP_tree_edge * find() const
void awt_set_awar_to_valid_filter_good_for_tree_methods(GBDATA *gb_main, AW_root *awr, const char *awar_name)
AW_DB_selection * awt_create_ALI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match)
#define TEST_EXPECTATION(EXPCTN)
GB_ERROR GB_set_temporary(GBDATA *gbd) __ATTR__USERESULT
#define does_contain(val)
bool aw_ask_sure(const char *unique_id, const char *msg)
AW_root * AWT_create_root(const char *properties, const char *program, UserActionTracker *user_tracker)
void set_info_area_height(int height)
fputs(TRACE_PREFIX, stderr)
GB_ULONG GB_get_usable_memory(void)
string get_multilist() const
#define textfiles_have_difflines(f1, f2, ed)
static void create_optimize_vars(AW_root *aw_root, AW_default props)
void AWT_trigger_remote_action(UNFIXED, GBDATA *gb_main, const char *remote_action_spec)
void set_bottom_area_height(int height)
AWT_graphic_parsimony * global_tree()
static void AP_user_push_cb(AW_window *aww)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
void NT_resort_tree_cb(UNFIXED, TREE_canvas *ntw, TreeOrder order)
AW_window * create_kernighan_properties_window(AW_root *aw_root)
static void randomMixTree(AW_window *aww, TREE_canvas *ntw)
void request_save_and_zoom_reset()
KL_Settings & get_KL_settings()
void auto_space(int xspace, int yspace)
#define TEST_EXPECT_NULL(n)
#define AWAR_KL_STATIC_DEPTH2
void GB_write_flag(GBDATA *gbd, long flag)
AW_window * NDS_create_window(AW_root *aw_root, GBDATA *gb_main)
int maxAllowedInsertions(int inTree)
static void NT_add_partial_and_update(UNFIXED, TREE_canvas *ntw)
#define AWAR_RAND_PERCENT
#define fulfills(pred, arg)
KL_Settings(AW_root *aw_root)
#define AWAR_BEST_PARSIMONY
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
AW_gc_manager * gc_manager
static void NT_reAdd_and_NNI(UNFIXED, TREE_canvas *ntw, AddWhat what)
static void NT_bootstrap(AW_window *, TREE_canvas *ntw, bool limit_only)
AP_pars_root * get_tree_root() const
vector< AP_tree_nlen * > InsertedSpecies
#define AWAR_OPTI_MARKED_ONLY
static AW_window * create_pars_init_window(AW_root *awr, const PARS_commands *cmds)
AP_tree * get_root_node()
void subtitle(const char *stitle)
void AWT_popup_print_window(AW_window *parent_win, AWT_canvas *scr)
char * GB_read_string(GBDATA *gbd)
AWT_graphic_exports exports
int calcInsertNow(int toInsert, int inTree)
AP_tree_nlen * otherNode(const AP_tree_nlen *n) const
void PARS_tree_init(AWT_graphic_parsimony *agt)
void GBT_message(GBDATA *gb_main, const char *msg)
AW_window * TREE_create_settings_window(AW_root *aw_root)
#define TREEDISP_STACKSIZE
#define TEST_EXPECT_NO_ERROR(call)
#define AWAR_KL_STATIC_DEPTH5
void aw_message(const char *msg)
AP_FLOAT weighted_base_count() const
void insert_macro_menu_entry(AW_window *awm, bool prepend_separator)
static void initialize(AP_tree_nlen *root)
#define AWAR_STACKPOINTER
__ATTR__NORETURN void aw_popup_exit(const char *msg)
bool is_std_gap(const char c)
void shutdown_macro_recording(AW_root *aw_root)
bool GB_is_regularfile(const char *path)
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
#define TEST_EXPECT_ERROR_CONTAINS(call, part)
Validity pop_will_produce_valid_tree()
InsertData(bool quick, long spec_count)
GB_ERROR GBT_set_startup_alignment(GBDATA *gb_main, const char *alignment_name)
static AWT_predefined_config optimizer_predefined_configs[]
#define AWAR_KL_FUNCTION_TYPE
#define TEST_VALIDITY(valid)
GB_ERROR write_string(const char *aw_string)
ArbParsimony & get_parsimony()
char * GBT_get_default_alignment(GBDATA *gb_main)
static void optimizeTree(AWT_graphic_parsimony *agt, const KL_Settings &settings)
const char * GBT_get_name(GBDATA *gb_item)
static void set_keep_ghostnodes()
arb_progress & get_progress()
void AWT_install_cb_guards()
PartialSequence(GBDATA *gb_species_)
static int sort_sequences_by_length(const char *, long leaf0_ptr, const char *, long leaf1_ptr)
long GBT_get_species_count(GBDATA *gb_main)
GB_transaction ta(gb_var)
GB_ERROR GBT_write_int(GBDATA *gb_container, const char *fieldpath, long content)
void callback(const WindowCallback &cb)
void set_tree_root(AWT_graphic_parsimony *agt_)
void destroy(TreeNode *that)
AP_pars_root * global_tree_root()
int get_at_yposition() const
const char * get_aliname() const
#define ASSERT_VALID_TREE(tree)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
static GB_ERROR pars_check_size(AW_root *awr, GB_ERROR &warning, const adfiltercbstruct *filterDef)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
void shadow_width(int shadow_thickness)
void label_length(int length)
void dump(const char *whichMatch) const
static void PARS_infomode_cb(UNFIXED, TREE_canvas *canvas, AWT_COMMAND_MODE mode)
void TREE_create_awars(AW_root *aw_root, AW_default db)
virtual Mutations mutations_if_combined_with(const AP_combinableSeq *other)=0
static void NT_calc_branchlengths_reorder_and_update(AW_window *, TREE_canvas *ntw)
void NDS_create_vars(AW_root *aw_root, AW_default awdef, GBDATA *gb_main)
GBDATA * get_species() const
#define TEST_EXPECT_EQUAL(expr, want)
GB_ERROR write_int(long aw_int)
void NT_reset_lzoom_cb(UNFIXED, TREE_canvas *ntw)
EdgeBetween(AP_tree_edge *e)
static void NT_recursiveNNI(AW_window *, TREE_canvas *ntw)
static void update_random_repeat(AW_root *awr, AWT_graphic_parsimony *agt)
GBDATA * GB_entry(GBDATA *father, const char *key)
static void NT_optimize(AW_window *, TREE_canvas *ntw)
void TREE_install_update_callbacks(TREE_canvas *ntw)
#define AWAR_KL_DYNAMIC_ENABLED
char * GBS_global_string_copy(const char *templat,...)
AP_tree_nlen * notSonNode() const
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
void create_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, const char *color=NULp)
#define AWAR_KL_STATIC_ENABLED
#define AWAR_KL_STATIC_DEPTH3
void NT_reload_tree_event(AW_root *, TREE_canvas *ntw, bool unzoom_and_expose)
GB_write_int const char s