source: trunk/NTREE/AP_pos_var_pars.cxx

Last change on this file was 19206, checked in by westram, 2 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 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    GB_ERROR  error;
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
48AW_window *AP_create_pos_var_pars_window(AW_root *root) {
49    GB_transaction ta(GLOBAL.gb_main);
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
58    AW_awar *tree_awar = root->awar_string(AWAR_PVP_TREE, NO_TREE_SELECTED, AW_ROOT_DEFAULT);
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");
74    awt_create_SAI_selection_list(GLOBAL.gb_main, aws, AWAR_PVP_SAI);
75
76    aws->at("trees");
77    awt_create_TREE_selection_list(GLOBAL.gb_main, aws, AWAR_PVP_TREE);
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}
Note: See TracBrowser for help on using the repository browser.