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) {
31  char *ali_name = GBT_get_default_alignment(GLOBAL.gb_main);
32 
33  if (!ali_name) {
34  error = GB_await_error();
35  }
36  else {
37  AW_root *root = aww->get_root();
38  const char *tree_name = root->awar(AWAR_PVP_TREE)->read_char_pntr();
39  const char *sai_name = root->awar(AWAR_PVP_SAI)->read_char_pntr();
40 
41  error = PVP_calculate(GLOBAL.gb_main, ali_name, tree_name, sai_name);
42 
43  free(ali_name);
44  }
45  aw_message_if(error);
46 }
47 
50 
51  AW_window_simple *aws = new AW_window_simple;
52  aws->init(root, "CSP_BY_PARSIMONY", "Conservation Profile: Parsimony Method");
53  aws->load_xfig("cpro/parsimony.fig");
54 
55  root->awar_string(AWAR_PVP_SAI, "POS_VAR_BY_PARSIMONY", AW_ROOT_DEFAULT);
56  const char *largest_tree = GBT_name_of_largest_tree(GLOBAL.gb_main);
57 
59  AWT_registerTreeAwarSimple(tree_awar);
60 
61  root->awar(AWAR_PVP_TREE)->write_string(largest_tree);
62 
63  aws->at("close");
64  aws->callback(AW_POPDOWN);
65  aws->create_button("CLOSE", "CLOSE", "C");
66 
67  aws->at("help"); aws->callback(makeHelpCallback("pos_var_pars.hlp"));
68  aws->create_button("HELP", "HELP", "H");
69 
70  aws->at("name");
71  aws->create_input_field(AWAR_PVP_SAI);
72 
73  aws->at("box");
75 
76  aws->at("trees");
78 
79  aws->at("go");
80  aws->highlight();
81  aws->callback(AP_calc_pos_var_pars);
82  aws->create_button("GO", "GO");
83 
84  return aws;
85 }
const char * GB_ERROR
Definition: arb_core.h:25
AW_DB_selection * awt_create_SAI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, const SaiSelectionlistFilterCallback &fcb)
void AWT_registerTreeAwarSimple(AW_awar *awar)
const char * GBT_name_of_largest_tree(GBDATA *gb_main)
Definition: adtree.cxx:1103
#define NO_TREE_SELECTED
AW_DB_selection * awt_create_TREE_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname)
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
const char * read_char_pntr() const
Definition: AW_awar.cxx:168
GB_ERROR GB_await_error()
Definition: arb_msg.cxx:342
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
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_root * get_root()
Definition: aw_window.hxx:359
AW_window * AP_create_pos_var_pars_window(AW_root *root)
GBDATA * gb_main
Definition: NT_local.h:37
GB_ERROR write_string(const char *aw_string)
char * GBT_get_default_alignment(GBDATA *gb_main)
Definition: adali.cxx:747
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:46