ARB
ali.h
Go to the documentation of this file.
1 #ifndef ALI_H
2 #define ALI_H
3 
4 #ifndef SEQ_H
5 #include "seq.h"
6 #endif
7 #ifndef _GLIBCXX_VECTOR
8 #include <vector>
9 #endif
10 
11 class Alignment {
12  std::vector<SeqPtr> seq;
13 
14 public:
15  int get_count() const { return seq.size(); }
16  bool valid(int idx) const { return idx >= 0 && idx<get_count(); }
17 
18  int get_len(int idx) const { ca_assert(valid(idx)); return seq[idx]->get_len(); }
19  const Seq& get(int idx) const { ca_assert(valid(idx)); return *(seq[idx]); }
20  SeqPtr getSeqPtr(int idx) { ca_assert(valid(idx)); return seq[idx]; }
21 
22  int get_max_len() const {
23  int maxlen = -1;
24  for (int i = 0; i<get_count(); ++i) maxlen = max(maxlen, get_len(i));
25  return maxlen;
26  }
27 
28  void add(SeqPtr sequence) { seq.push_back(sequence); }
29  void add(const char *name, const char *sequence, size_t seq_len) { add(new Seq(name, sequence, seq_len)); }
30  void add(const char *name, const char *sequence) { add(name, sequence, strlen(sequence)); }
31 };
32 
33 #else
34 #error ali.h included twice
35 #endif // ALI_H
size_t get_len() const
Definition: insdel.cxx:920
int get_count() const
Definition: ali.h:15
Definition: ali.h:11
#define ca_assert(cond)
Definition: global.h:33
int get_len(int idx) const
Definition: ali.h:18
void add(const char *name, const char *sequence)
Definition: ali.h:30
int get_max_len() const
Definition: ali.h:22
SeqPtr getSeqPtr(int idx)
Definition: ali.h:20
Generic smart pointer.
Definition: smartptr.h:149
bool valid(int idx) const
Definition: ali.h:16
Definition: seq.h:43
void add(SeqPtr sequence)
Definition: ali.h:28
void add(const char *name, const char *sequence, size_t seq_len)
Definition: ali.h:29
#define max(a, b)
Definition: f2c.h:154