source: tags/ms_r18q1/NALIGNER/ali_sequence.hxx

Last change on this file was 16766, checked in by westram, 6 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : ali_sequence.hxx                                  //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef ALI_SEQUENCE_HXX
12#define ALI_SEQUENCE_HXX
13
14#ifndef _GLIBCXX_CSTRING
15#include <cstring>
16#endif
17#ifndef ALI_MISC_HXX
18#include "ali_misc.hxx"
19#endif
20
21
22class ALI_SEQUENCE : virtual Noncopyable {
23    unsigned char *seq;
24    char *seq_name;
25    unsigned long seq_len;
26public:
27    ALI_SEQUENCE(char *Name, char *str) {
28        seq = (unsigned char *) str;
29        seq_len = strlen(str);
30        seq_name = strdup(Name);
31        ali_string_to_sequence(str);
32        ali_out_of_memory_if(!seq_name);
33    }
34    ALI_SEQUENCE(char *Name, unsigned char *str, unsigned long str_len) {
35        seq = str;
36        seq_len = str_len;
37        seq_name = strdup(Name);
38    }
39    ~ALI_SEQUENCE() {
40        if (seq)
41            free((char *) seq);
42        if (seq_name)
43            free((char *) seq_name);
44    }
45    unsigned char *sequence() {
46        return seq;
47    }
48    unsigned char base(unsigned long position) {
49        return seq[position];
50    }
51    int check();
52    char *string();
53    char *name() {
54        return seq_name;
55    }
56    unsigned long length() {
57        return seq_len;
58    }
59};
60
61
62class ALI_NORM_SEQUENCE : virtual Noncopyable {
63    unsigned char *seq;
64    char *seq_name;
65    unsigned char **dots;
66    unsigned long seq_len;
67public:
68    ALI_NORM_SEQUENCE(char *name, char *str);
69    ALI_NORM_SEQUENCE(ALI_SEQUENCE *sequence);
70    ~ALI_NORM_SEQUENCE() {
71        if (seq)
72            free((char *) seq);
73        if (seq_name)
74            free((char *) seq_name);
75        if (dots)
76            free((char *) dots);
77    }
78    unsigned char *sequence() {
79        return seq;
80    }
81    unsigned char base(unsigned long position) {
82        return seq[position];
83    }
84    char *string();
85    char *name() {
86        return seq_name;
87    }
88    unsigned long length() {
89        return seq_len;
90    }
91    int is_begin(unsigned long pos) {
92        if (!dots)
93            return 0;
94        else {
95            if (pos > seq_len)
96                return 1;
97            else
98                return ((*dots)[pos/8] & (unsigned char) (1<<(7-(pos%8)))) != 0;
99        }
100    }
101};
102
103#else
104#error ali_sequence.hxx included twice
105#endif // ALI_SEQUENCE_HXX
Note: See TracBrowser for help on using the repository browser.