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 #if defined(WARN_TODO)
23 #warning let awt_create_select_filter create filter awars and automatically map it to awar_default_alignment \
24  // (see [6476] for changes done for ColumnStat)
25 #endif
26  adfilter = awt_create_select_filter(aw_root, gb_main, awar_filter_name);
27  column_stat = awar_columnStat_name ? new ColumnStat(gb_main, aw_root, awar_columnStat_name, awar_default_alignment) : NULp;
28 }
29 
31  delete column_stat;
32  // @@@ leak: adfilter (no destruction implemented)
33 }
34 
36  return awt_get_filter(adfilter);
37 }
38 
40  ga_assert(!error);
41 
43  bool haveRates = false;
44 
45  if (column_stat) {
46  error = column_stat->calculate(NULp);
47  if (error) error = GBS_global_string("Failed to calculate weights (Reason: %s)", error);
48 
49  haveRates = column_stat->has_rates();
50  }
51 
52  if (!error) {
53  if (haveRates) {
54  column_stat->weight_by_inverseRates();
55  weights = new AP_weights(column_stat->get_weights(), column_stat->get_length(), filter);
56  }
57  else {
58  weights = new AP_weights(filter);
59  }
60  }
61  if (column_stat) column_stat->forget();
62 
63  ga_assert(contradicted(error, weights));
64  return weights;
65 }
66 
67 AliView *WeightedFilter::create_aliview(const char *aliname, GB_ERROR& error) const {
68  ga_assert(!error);
70 
71  AliView *aliview = NULp;
72  {
73  AP_filter *filter = create_filter();
74  error = filter->is_invalid();
75 
76  if (!error) {
77  AP_weights *weights = create_weights(filter, error);
78  aliview = error ? NULp : new AliView(adfilter->gb_main, *filter, *weights, aliname);
79  delete weights;
80  }
81  delete filter;
82  }
83  ga_assert(contradicted(error, aliview));
84  ga_assert(!GB_have_error()); // @@@ should be returned via 'error'
85  return aliview;
86 }
87 
89  return adfilter->gb_main;
90 }
91 
93  return adfilter->awr;
94 }
95 
AW_root * get_aw_root() const
Definition: GUI_aliview.cxx:92
bool has_rates() const
Definition: ColumnStat.hxx:84
AP_filter * create_filter() const
Definition: GUI_aliview.cxx:35
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
bool GB_have_error()
Definition: arb_msg.cxx:349
GBDATA * gb_main
Definition: awt_filter.hxx:27
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:224
GBDATA * get_gb_main() const
Definition: GUI_aliview.cxx:88
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
#define ga_assert(cond)
Definition: ga_local.h:15
AP_filter * awt_get_filter(adfiltercbstruct *acbs)
Definition: AWT_filter.cxx:430
AliView * create_aliview(const char *aliname, GB_ERROR &error) const
Definition: GUI_aliview.cxx:67
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:97
AP_weights * create_weights(const AP_filter *filter, GB_ERROR &error) const
Definition: GUI_aliview.cxx:39
void weight_by_inverseRates() const
Definition: ColumnStat.cxx:303
GBDATA * gb_main
Definition: adname.cxx:33