30 #define TREE_COMPARE_PREFIX "ad_tree/compare/"
32 #define AWAR_TREE_COMPARE_ACTION TREE_COMPARE_PREFIX "action"
33 #define AWAR_TREE_COMPARE_MIN_TAX_LEVELS TREE_COMPARE_PREFIX "taxdist"
34 #define AWAR_TREE_COMPARE_WRITE_FIELD TREE_COMPARE_PREFIX "field"
53 while (!parent_group && node->
father) {
66 while (parent_group) {
96 if (pdiff || strcmp(g1->
name, g2->
name) != 0) {
114 if (strcmp(g1->
name, g2->
name) != 0) {
171 typedef std::set<const char *, charpLess>
NameSet;
172 typedef std::map<const char *, SpeciesInTwoTrees, charpLess>
TwoTreeMap;
177 tmap[node->
name].setSpecies(node, first);
195 progress.subtitle(
"Loading trees");
218 size_t targetted = 0;
219 bool had_error =
false;
223 had_error = load_error;
231 mapTree(tree_left, tmap,
true);
232 mapTree(tree_right, tmap,
false);
234 size_t commonSpeciesCount = 0;
235 for (TwoTreeMap::iterator
s = tmap.begin();
s != tmap.end(); ++
s) {
236 if (
s->second.occursInBothTrees()) commonSpeciesCount++;
240 bool writeToField = fieldName;
244 arb_progress subprogress(
"Comparing taxonomy info", commonSpeciesCount);
245 for (TwoTreeMap::iterator
s = tmap.begin();
s != tmap.end() && !
error; ++
s) {
250 if (taxDiffLevel>min_tax_levels) {
277 progress.subtitle(
"Intersecting tree members");
282 size_t count_left, count_right;
286 for(
size_t i= 0; i<count_left; ++i) in_left .insert(names_left[i]);
287 for(
size_t i= 0; i<count_right; ++i) in_right.insert(names_right[i]);
297 for (NameSet::const_iterator i = in_one.begin(); i != in_one.end(); ++i) {
298 bool is_in_other = in_other.find(*i) != in_other.end();
299 bool is_target = is_in_other == (target ==
COMMON);
326 "(might be caused by zombies in your trees)", missing));
346 AW_window_simple *aws =
new AW_window_simple;
347 aws->init(aw_root,
"COMPARE_TAXONOMY",
"Compare taxonomy");
352 aws->create_button(
"CLOSE",
"CLOSE",
"C");
356 aws->create_button(
"HELP",
"HELP",
"H");
360 aws->insert_default_toggle(
"mark",
"m",
MARK);
361 aws->insert_toggle (
"unmark",
"u",
UNMARK);
362 aws->insert_toggle (
"invert",
"i",
INVERT);
363 aws->update_toggle_field();
365 aws->at(
"all"); aws->callback(makeWindowCallback(
mark_action, ntw,
ALL)); aws->create_autosize_button(
"all",
"all species");
366 aws->at(
"tax"); aws->callback(makeWindowCallback(
mark_action, ntw,
TAX)); aws->create_autosize_button(
"tax",
"species with taxonomy changed");
367 aws->at(
"common"); aws->callback(makeWindowCallback(
mark_action, ntw,
COMMON)); aws->create_autosize_button(
"common",
"common species");
368 aws->at(
"missleft"); aws->callback(makeWindowCallback(
mark_action, ntw,
MISSING_LEFT)); aws->create_autosize_button(
"missleft",
"species missing in left tree");
369 aws->at(
"missright"); aws->callback(makeWindowCallback(
mark_action, ntw,
MISSING_RIGHT)); aws->create_autosize_button(
"missright",
"species missing in right tree");
static void mapTree(TreeNode *node, TwoTreeMap &tmap, bool first)
AW_window * NT_create_compare_taxonomy_window(AW_root *aw_root, TREE_canvas *ntw)
GB_ERROR GB_incur_error()
void load_xfig(const char *file, bool resize=true)
void NT_mark_all_cb(UNFIXED, TREE_canvas *ntw, int mark_mode)
TreeNode * GBT_read_tree(GBDATA *gb_main, const char *tree_name, TreeRoot *troot)
const char * GBS_global_string(const char *templat,...)
void AW_POPDOWN(AW_window *window)
int calcTaxDiffLevel() const
void setSpecies(TreeNode *species, bool first)
#define NO_FIELD_SELECTED
bool occursInBothTrees() const
void create_itemfield_selection_button(AW_window *aws, const FieldSelDef &selDef, const char *at)
const char * read_char_pntr() const
GB_ERROR GB_await_error()
WindowCallback makeHelpCallback(const char *helpfile)
#define AWAR_TREE_COMPARE_ACTION
AW_awar * dest_tree_awar(AW_root *root)
static int calcTaxDifference(TreeNode *g1, TreeNode *g2)
static void error(const char *msg)
static TreeNode * findParentGroup(TreeNode *node)
void NT_create_twoTreeSelection(AW_window *aws)
#define AWAR_TREE_COMPARE_WRITE_FIELD
GB_ERROR GB_write_lossless_int(GBDATA *gbd, int32_t i)
const char * prepare_and_get_selected_itemfield(AW_root *awr, const char *awar_name, GBDATA *gb_main, const ItemSelector &itemtype, FailIfField failIf)
int GB_read_flag(GBDATA *gbd)
GBDATA * GBT_find_species_rel_species_data(GBDATA *gb_species_data, const char *name)
char * read_string() const
void NT_create_compare_taxonomy_awars(AW_root *aw_root, AW_default props)
AW_awar * awar(const char *awar)
std::map< const char *, SpeciesInTwoTrees, charpLess > TwoTreeMap
#define AWAR_TREE_COMPARE_MIN_TAX_LEVELS
GBDATA * GBT_searchOrCreate_itemfield_according_to_changekey(GBDATA *gb_item, const char *field_name, const char *change_key_path)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
void GB_write_flag(GBDATA *gbd, long flag)
AW_awar * source_tree_awar(AW_root *root)
ItemSelector & SPECIES_get_selector()
void aw_message(const char *msg)
static void mark_action(AW_window *aws, TREE_canvas *ntw, Target target)
GB_CSTR * GBT_get_names_of_species_in_tree(const TreeNode *tree, size_t *count)
static int countTaxLevel(TreeNode *node)
CONSTEXPR long FIELD_FILTER_INT_WRITEABLE
GB_transaction ta(gb_var)
void destroy(TreeNode *that)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
std::set< const char *, charpLess > NameSet
bool is_normal_group() const
void inc_and_check_user_abort(GB_ERROR &error)
void aw_message_if(GB_ERROR error)
GBDATA * GBT_get_species_data(GBDATA *gb_main)
GB_write_int const char s