source: branches/tree/NTREE/AP_pos_var_pars.cxx

Last change on this file was 16904, checked in by westram, 7 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
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
29static 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
45AW_window *AP_create_pos_var_pars_window(AW_root *root) {
46    GB_transaction ta(GLOBAL.gb_main);
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
55    AW_awar *tree_awar = root->awar_string(AWAR_PVP_TREE, NO_TREE_SELECTED, AW_ROOT_DEFAULT);
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");
71    awt_create_SAI_selection_list(GLOBAL.gb_main, aws, AWAR_PVP_SAI, false);
72
73    aws->at("trees");
74    awt_create_TREE_selection_list(GLOBAL.gb_main, aws, AWAR_PVP_TREE, true);
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}
Note: See TracBrowser for help on using the repository browser.