ARB
GUI_aliview.cxx
Go to the documentation of this file.
1 // ================================================================ //
2 // //
3 // File : GUI_aliview.cxx //
4 // Purpose : //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in November 2009 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // ================================================================ //
11 
12 #include "gui_aliview.hxx"
13 #include "awt_filter.hxx"
14 #include "ColumnStat.hxx"
15 #include "ga_local.h"
16 
17 #include <AliView.hxx>
18 #include <AP_filter.hxx>
19 #include <arb_msg.h>
20 
21 WeightedFilter::WeightedFilter(GBDATA *gb_main, AW_root *aw_root, const char *awar_filter_name, const char *awar_columnStat_name, AW_awar *awar_default_alignment) {
22  // @@@ let awt_create_select_filter create filter awars and automatically map it to awar_default_alignment
23  // (see [6476] for changes done for ColumnStat)
24 
25  adfilter = awt_create_select_filter(aw_root, gb_main, awar_filter_name);
26  column_stat = awar_columnStat_name ? new ColumnStat(gb_main, aw_root, awar_columnStat_name, awar_default_alignment) : NULp;
27 }
28 
30  delete column_stat;
31  // @@@ leak: adfilter (no destruction implemented)
32 }
33 
35  return awt_get_filter(adfilter);
36 }
37 
39  ga_assert(!error);
40 
42  bool haveRates = false;
43 
44  if (column_stat) {
45  error = column_stat->calculate(NULp);
46  if (error) error = GBS_global_string("Failed to calculate weights (Reason: %s)", error);
47 
48  haveRates = column_stat->has_rates();
49  }
50 
51  if (!error) {
52  if (haveRates) {
53  column_stat->weight_by_inverseRates();
54  weights = new AP_weights(column_stat->get_weights(), column_stat->get_length(), filter);
55  }
56  else {
57  weights = new AP_weights(filter);
58  }
59  }
60  if (column_stat) column_stat->forget();
61 
62  ga_assert(contradicted(error, weights));
63  return weights;
64 }
65 
66 AliView *WeightedFilter::create_aliview(const char *aliname, GB_ERROR& error) const {
67  ga_assert(!error);
69 
70  AliView *aliview = NULp;
71  {
72  AP_filter *filter = create_filter();
73  error = filter->is_invalid();
74 
75  if (!error) {
76  AP_weights *weights = create_weights(filter, error);
77  aliview = error ? NULp : new AliView(adfilter->gb_main, *filter, *weights, aliname);
78  delete weights;
79  }
80  delete filter;
81  }
82  ga_assert(contradicted(error, aliview));
83  ga_assert(!GB_have_error()); // @@@ should be returned via 'error'
84  return aliview;
85 }
86 
88  return adfilter->gb_main;
89 }
90 
92  return adfilter->awr;
93 }
94 
AW_root * get_aw_root() const
Definition: GUI_aliview.cxx:91
bool has_rates() const
Definition: ColumnStat.hxx:84
AP_filter * create_filter() const
Definition: GUI_aliview.cxx:34
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:203
bool GB_have_error()
Definition: arb_msg.cxx:338
GBDATA * gb_main
Definition: awt_filter.hxx:27
#define ga_assert(cond)
static int weights[MAX_BASETYPES][MAX_BASETYPES]
Definition: ClustalV.cxx:71
static void error(const char *msg)
Definition: mkptypes.cxx:96
__ATTR__USERESULT GB_ERROR calculate(AP_filter *filter)
Definition: ColumnStat.cxx:107
adfiltercbstruct * awt_create_select_filter(AW_root *aw_root, GBDATA *gb_main, const char *def_name)
Definition: AWT_filter.cxx:225
GBDATA * get_gb_main() const
Definition: GUI_aliview.cxx:87
WeightedFilter(GBDATA *gb_main, AW_root *aw_root, const char *awar_filter_name, const char *awar_columnStat_name, AW_awar *awar_default_alignment)
Definition: GUI_aliview.cxx:21
void forget()
Definition: ColumnStat.cxx:83
AP_filter * awt_get_filter(adfiltercbstruct *acbs)
Definition: AWT_filter.cxx:431
AliView * create_aliview(const char *aliname, GB_ERROR &error) const
Definition: GUI_aliview.cxx:66
const GB_UINT4 * get_weights() const
Definition: ColumnStat.hxx:89
GB_ERROR is_invalid() const
Definition: AP_filter.hxx:123
size_t get_length() const
Definition: ColumnStat.hxx:87
#define NULp
Definition: cxxforward.h:114
AP_weights * create_weights(const AP_filter *filter, GB_ERROR &error) const
Definition: GUI_aliview.cxx:38
void weight_by_inverseRates() const
Definition: ColumnStat.cxx:303
GBDATA * gb_main
Definition: adname.cxx:32