source: tags/cvs_2_svn/AWT/AWT_seq_simple_pro.cxx

Last change on this file was 5436, checked in by westram, 16 years ago
  • fixed signed chars used as array index
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1#include <stdio.h>
2#include <memory.h>
3#include <string.h>
4
5#include <arbdb.h>
6#include <arbdbt.h>
7#include <awt_tree.hxx>
8#include "awt_seq_simple_pro.hxx"
9
10#define awt_assert(bed) arb_assert(bed)
11
12AP_sequence_simple_protein::AP_sequence_simple_protein(AP_tree_root *rooti) : AP_sequence(rooti) {
13    sequence = 0;
14}
15
16AP_sequence_simple_protein::~AP_sequence_simple_protein(void) {
17    delete sequence;
18    sequence = 0;
19}
20
21AP_sequence *AP_sequence_simple_protein::dup(void) {
22    return new AP_sequence_simple_protein(root);
23}
24
25
26
27void AP_sequence_simple_protein::set(const char *isequence) {
28    const char    *s;
29    unsigned char  c;
30    ap_pro        *d;
31    if (!awt_pro_a_nucs) {
32        awt_pro_a_nucs_gen_dist (this->root->gb_main);
33    }
34
35    struct arb_r2a_pro_2_nuc **s2str = &awt_pro_a_nucs->s2str[0];
36    sequence_len = root->filter->real_len;
37    sequence = new ap_pro[sequence_len+1];
38    memset(sequence,s2str['.']->index,(size_t)(sizeof(ap_pro) * sequence_len));
39    s = isequence;
40    d = sequence;
41    const uchar *simplify = root->filter->simplify;
42    int sindex = s2str['s']->index;
43    if (root->filter->bootstrap){
44        int iseqlen = strlen(isequence);
45        int i;
46        for (i=root->filter->real_len-1;i>=0;i--){
47            int pos = root->filter->bootstrap[i];
48            if (pos >= iseqlen) continue;
49            c = s[pos];
50            if (! (s2str[c] ) ) {   // unknown character
51                continue;
52            }
53            int ind = s2str[simplify[c]]->index;
54            if (ind >= sindex) ind --;
55            d[i] = ind;
56        }
57    }else{
58        char *f = root->filter->filter_mask;
59        int i = root->filter->filter_len;
60        while ( (c = (*s++)) ) {
61            if (!i) break;
62            i--;
63            if (*(f++)) {
64                if (! (s2str[c] ) ) {   // unknown character
65                    d++;
66                    continue;
67                }
68                int ind = s2str[simplify[c]]->index;
69                if (ind >= sindex) ind --;
70                *(d++) = ind;
71            }
72        }
73    }
74    is_set_flag = AP_TRUE;
75    cashed_real_len = -1.0;
76}
77
78AP_FLOAT AP_sequence_simple_protein::combine( const AP_sequence *, const AP_sequence *) {
79    return 0.0;
80}
81
82void AP_sequence_simple_protein::partial_match(const AP_sequence* /*part*/, long */*overlap*/, long */*penalty*/) const {
83    awt_assert(0); // should be unused
84}
85
86
87
Note: See TracBrowser for help on using the repository browser.