ARB
AP_pos_var_pars.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : AP_pos_var_pars.cxx //
4 // Purpose : window interface for PVP calculation //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #include "NT_local.h"
12 
13 #include <pvp.h>
14 #include <TreeNode.h>
15 
16 #include <awt_sel_boxes.hxx>
17 #include <awt_TreeAwars.hxx>
18 
19 #include <aw_root.hxx>
20 #include <aw_awar.hxx>
21 #include <aw_msg.hxx>
22 
23 #include <arb_progress.h>
24 #include <arb_global_defs.h>
25 
26 #define AWAR_PVP_SAI "tmp/pos_var_pars/sai"
27 #define AWAR_PVP_TREE "tmp/pos_var_pars/tree"
28 
29 static void AP_calc_pos_var_pars(AW_window *aww) {
30  AW_root *root = aww->get_root();
31 
32  char *ali_name = GBT_get_default_alignment(GLOBAL.gb_main);
33  char *tree_name = root->awar(AWAR_PVP_TREE)->read_string();
34  char *sai_name = root->awar(AWAR_PVP_SAI)->read_string();
35 
36  GB_ERROR error = PVP_calculate(GLOBAL.gb_main, ali_name, tree_name, sai_name);
37 
38  free(sai_name);
39  free(tree_name);
40  free(ali_name);
41 
42  aw_message_if(error);
43 }
44 
47 
48  AW_window_simple *aws = new AW_window_simple;
49  aws->init(root, "CSP_BY_PARSIMONY", "Conservation Profile: Parsimony Method");
50  aws->load_xfig("cpro/parsimony.fig");
51 
52  root->awar_string(AWAR_PVP_SAI, "POS_VAR_BY_PARSIMONY", AW_ROOT_DEFAULT);
53  const char *largest_tree = GBT_name_of_largest_tree(GLOBAL.gb_main);
54 
56  AWT_registerTreeAwarSimple(tree_awar);
57 
58  root->awar(AWAR_PVP_TREE)->write_string(largest_tree);
59 
60  aws->at("close");
61  aws->callback(AW_POPDOWN);
62  aws->create_button("CLOSE", "CLOSE", "C");
63 
64  aws->at("help"); aws->callback(makeHelpCallback("pos_var_pars.hlp"));
65  aws->create_button("HELP", "HELP", "H");
66 
67  aws->at("name");
68  aws->create_input_field(AWAR_PVP_SAI);
69 
70  aws->at("box");
72 
73  aws->at("trees");
75 
76  aws->at("go");
77  aws->highlight();
78  aws->callback(AP_calc_pos_var_pars);
79  aws->create_button("GO", "GO");
80 
81  return aws;
82 }
const char * GB_ERROR
Definition: arb_core.h:25
void AWT_registerTreeAwarSimple(AW_awar *awar)
const char * GBT_name_of_largest_tree(GBDATA *gb_main)
Definition: adtree.cxx:1057
#define NO_TREE_SELECTED
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
WindowCallback makeHelpCallback(const char *helpfile)
Definition: aw_window.hxx:106
static void error(const char *msg)
Definition: mkptypes.cxx:96
#define AWAR_PVP_TREE
GB_ERROR PVP_calculate(GBDATA *gb_main, const char *ali_name, const char *tree_name, const char *target_SAI_name)
Definition: pvp.cxx:17
char * read_string() const
Definition: AW_awar.cxx:201
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
#define AWAR_PVP_SAI
static void AP_calc_pos_var_pars(AW_window *aww)
AW_DB_selection * awt_create_TREE_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default)
AW_root * get_root()
Definition: aw_window.hxx:348
AW_window * AP_create_pos_var_pars_window(AW_root *root)
GBDATA * gb_main
Definition: NT_local.h:36
GB_ERROR write_string(const char *aw_string)
char * GBT_get_default_alignment(GBDATA *gb_main)
Definition: adali.cxx:675
AW_DB_selection * awt_create_SAI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default, const SaiSelectionlistFilterCallback &fcb)
GB_transaction ta(gb_var)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:570
#define AW_ROOT_DEFAULT
Definition: aw_base.hxx:106
void aw_message_if(GB_ERROR error)
Definition: aw_msg.hxx:21
NT_global GLOBAL
Definition: NT_main.cxx:44