ARB
AP_sequence.cxx
Go to the documentation of this file.
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 
14 long AP_combinableSeq::global_combineCount = 0;
15 
17  ali(aliview),
18  gb_sequence(NULp),
19  has_sequence(false),
20  update(0),
21  cached_wbc(-1.0)
22 {}
23 
26 
27  ap_assert(!gb_sequence); // already bound to species!
28  if (!gb_sequence) {
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 
41  ap_assert(gb_sequence);
42  gb_sequence = NULp;
43  unset();
44 }
45 
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) {
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 
const char * get_aliname() const
Definition: AliView.hxx:40
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:203
GBDATA * GB_get_grandfather(GBDATA *gbd)
Definition: arbdb.cxx:1728
FILE * seq
Definition: rns.c:46
GB_ERROR GB_await_error()
Definition: arb_msg.cxx:342
AP_sequence(const AliView *aliview)
Definition: AP_sequence.cxx:16
void GB_warningf(const char *templat,...)
Definition: arb_msg.cxx:536
void do_lazy_load() const
Definition: AP_sequence.cxx:46
#define false
Definition: ureadseq.h:13
virtual void unset()=0
static void error(const char *msg)
Definition: mkptypes.cxx:96
#define ap_assert(cond)
void unbind_from_species()
Definition: AP_sequence.cxx:40
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
Definition: adali.cxx:708
#define NULp
Definition: cxxforward.h:116
GB_transaction ta(gb_var)
GB_ERROR bind_to_species(GBDATA *gb_species)
Definition: AP_sequence.cxx:24
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
Definition: arbdb.cxx:904
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
Definition: aditem.cxx:459
virtual void set(const char *sequence)=0
GBDATA * get_gb_main() const
Definition: AliView.hxx:46