source: trunk/SL/SEQUENCE/AP_sequence.cxx

Last change on this file was 18159, checked in by westram, 5 years ago
  • full update from child 'fix' into 'trunk'
    • fix item name accessors (GBT_get_name + GBT_get_name_or_description)
    • add null2empty
  • adds: log:branches/fix@18140:18158
File size: 2.1 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : AP_sequence.cxx                                   //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#include "AP_sequence.hxx"
12#include <arbdbt.h>
13
14long AP_combinableSeq::global_combineCount = 0;
15
16AP_sequence::AP_sequence(const AliView *aliview) :
17    ali(aliview),
18    gb_sequence(NULp),
19    has_sequence(false),
20    update(0),
21    cached_wbc(-1.0)
22{}
23
24GB_ERROR AP_sequence::bind_to_species(GBDATA *gb_species) {
25    GB_ERROR error = NULp;
26
27    ap_assert(!gb_sequence); // already bound to species!
28    if (!gb_sequence) {
29        GB_transaction ta(ali->get_gb_main());
30        gb_sequence = GBT_find_sequence(gb_species, ali->get_aliname());
31        if (!gb_sequence) {
32            error = GBS_global_string("Species '%s' has no data in alignment '%s'",
33                                      GBT_get_name_or_description(gb_species), ali->get_aliname());
34        }
35        unset();
36    }
37    return error;
38}
39
40void AP_sequence::unbind_from_species() {
41    ap_assert(gb_sequence);
42    gb_sequence = NULp;
43    unset();
44}
45
46void AP_sequence::do_lazy_load() const {
47    ap_assert(gb_sequence);
48    ap_assert(!has_sequence);
49
50    GB_transaction ta(gb_sequence);
51    const char *seq = GB_read_char_pntr(gb_sequence);
52    if (!seq) {
53        GB_ERROR  error      = GB_await_error();
54        GBDATA   *gb_species = GB_get_grandfather(gb_sequence);
55
56        GB_warningf("Failed to load sequence of '%s'\n(Reason: %s)",
57                    GBT_get_name_or_description(gb_species), error);
58        seq = "";                                   // fake empty sequence
59    }
60
61    // this is no modification, this is lazy initialization
62    const_cast<AP_sequence*>(this)->set(seq);
63}
64
65
Note: See TracBrowser for help on using the repository browser.