source: tags/ms_r16q3/SL/SEQUENCE/AP_seq_simple_pro.cxx

Last change on this file was 13625, checked in by westram, 9 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#include "AP_seq_simple_pro.hxx"
2#include <AP_pro_a_nucs.hxx>
3#include <AP_filter.hxx>
4#include <ARB_Tree.hxx>
5
6
7// #define ap_assert(bed) arb_assert(bed)
8
9AP_sequence_simple_protein::AP_sequence_simple_protein(const AliView *aliview)
10: AP_sequence(aliview)
11{
12    sequence = 0;
13}
14
15AP_sequence_simple_protein::~AP_sequence_simple_protein() {
16    delete [] sequence;
17}
18
19AP_sequence *AP_sequence_simple_protein::dup() const {
20    return new AP_sequence_simple_protein(get_aliview());
21}
22
23
24
25void AP_sequence_simple_protein::set(const char *isequence) {
26    AWT_translator  *translator = AWT_get_user_translator(get_aliview()->get_gb_main());
27
28    const struct arb_r2a_pro_2_nuc * const *s2str = translator->S2strArray();
29
30    size_t sequence_len = get_sequence_length();
31    sequence     = new ap_pro[sequence_len+1];
32    memset(sequence, s2str['.']->index, (size_t)(sizeof(ap_pro) * sequence_len));
33
34    const char    *s = isequence;
35    ap_pro        *d = sequence;
36
37    const AP_filter *filt      = get_filter();
38    const uchar     *simplify  = filt->get_simplify_table();
39    int              sindex    = s2str['s']->index;
40
41    if (filt->does_bootstrap()) {
42        int iseqlen = strlen(isequence);
43        for (int i = filt->get_filtered_length()-1; i>=0; i--) {
44            int pos = filt->bootstrapped_seqpos(i);
45            if (pos >= iseqlen) continue;
46            unsigned char c = s[pos];
47            if (! (s2str[c])) {     // unknown character
48                continue;
49            }
50            int ind = s2str[simplify[c]]->index;
51            if (ind >= sindex) ind --;
52            d[i] = ind;
53        }
54    }
55    else {
56        size_t i, j;
57        size_t flen = filt->get_length();
58        for (i = j = 0; i < flen; ++i) {
59            unsigned char c = s[i];
60            if (!c) break;
61            if (filt->use_position(i)) {
62                if (s2str[c]) {
63                    int ind = s2str[simplify[c]]->index;
64                    if (ind >= sindex) ind--;
65                    d[j]    = ind;
66                }
67                j++;
68            }
69        }
70    }
71    mark_sequence_set(true);
72}
73
74void AP_sequence_simple_protein::unset() {
75    delete [] sequence;
76    sequence = 0;
77    mark_sequence_set(false);
78}
79
80
81AP_FLOAT AP_sequence_simple_protein::combine(const AP_sequence *, const AP_sequence *, char*) {
82    ap_assert(0); // should be unused
83    return -1.0;
84}
85
86void AP_sequence_simple_protein::partial_match(const AP_sequence* /* part */, long * /* overlap */, long * /* penalty */) const {
87    ap_assert(0); // should be unused
88}
89
90AP_FLOAT AP_sequence_simple_protein::count_weighted_bases() const {
91    ap_assert(0); // should be unused
92    return -1.0;
93}
94
95uint32_t AP_sequence_simple_protein::checksum() const {
96    ap_assert(0); // not impl
97    return 0;
98}
99
100
101
Note: See TracBrowser for help on using the repository browser.