source: branches/profile/SL/ALIVIEW/AliView.cxx

Last change on this file was 12138, checked in by westram, 11 years ago
File size: 2.0 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : AliView.cxx                                       //
4//   Purpose   : Defines a filtered view onto an alignment         //
5//                                                                 //
6//   Coded by Ralf Westram (coder@reallysoft.de) in October 2009   //
7//   Institute of Microbiology (Technical University Munich)       //
8//   http://www.arb-home.de/                                       //
9//                                                                 //
10// =============================================================== //
11
12#include "AliView.hxx"
13
14#include <AP_filter.hxx>
15
16#define av_assert(cond) arb_assert(cond)
17
18using namespace std;
19
20void AliView::create_real_view(const AP_filter *filter_, const AP_weights *weights_, const char *aliname_) {
21    av_assert(!filter && !weights && !aliname);
22    av_assert(filter_ && weights_ && aliname_);
23
24    filter  = new AP_filter(*filter_);
25    weights = new AP_weights(*weights_);
26    aliname = strdup(aliname_);
27
28    av_assert(filter->get_filtered_length() == weights->length());
29    av_assert(filter->was_checked_for_validity());
30}
31
32
33AliView::AliView(GBDATA *gb_main_)
34    : gb_main(gb_main_)
35    , filter(NULL),  weights(NULL),  aliname(NULL)
36{
37    // this creates a fake-AliView (used for AP_tree w/o sequence)
38}
39
40AliView::AliView(GBDATA *gb_main_, const AP_filter& filter_, const AP_weights& weights_, const char *aliname_)
41    : gb_main(gb_main_)
42    , filter(NULL),  weights(NULL),  aliname(NULL)
43{
44    create_real_view(&filter_, &weights_, aliname_);
45}
46
47AliView::AliView(const AliView& other)
48    : gb_main(other.gb_main)
49    , filter(NULL),  weights(NULL),  aliname(NULL)
50{
51    create_real_view(other.filter, other.weights, other.aliname);
52}
53
54AliView::~AliView() {
55    delete filter;
56    delete weights;
57    free(aliname);
58}
59
60size_t AliView::get_length() const {
61    return filter->get_filtered_length();
62}
63
Note: See TracBrowser for help on using the repository browser.