| 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 | |
|---|
| 12 | AP_sequence_simple_protein::AP_sequence_simple_protein(AP_tree_root *rooti) : AP_sequence(rooti) { |
|---|
| 13 | sequence = 0; |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | AP_sequence_simple_protein::~AP_sequence_simple_protein(void) { |
|---|
| 17 | delete sequence; |
|---|
| 18 | sequence = 0; |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | AP_sequence *AP_sequence_simple_protein::dup(void) { |
|---|
| 22 | return new AP_sequence_simple_protein(root); |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | void AP_sequence_simple_protein::set(const char *isequence) { |
|---|
| 28 | const char *s; |
|---|
| 29 | unsigned char c; |
|---|
| 30 | ap_pro *d; |
|---|
| 31 | |
|---|
| 32 | AWT_translator *translator = AWT_get_user_translator(this->root->gb_main); |
|---|
| 33 | |
|---|
| 34 | const struct arb_r2a_pro_2_nuc * const *s2str = translator->S2strArray(); |
|---|
| 35 | sequence_len = root->filter->real_len; |
|---|
| 36 | sequence = new ap_pro[sequence_len+1]; |
|---|
| 37 | memset(sequence,s2str['.']->index,(size_t)(sizeof(ap_pro) * sequence_len)); |
|---|
| 38 | s = isequence; |
|---|
| 39 | d = sequence; |
|---|
| 40 | const uchar *simplify = root->filter->simplify; |
|---|
| 41 | int sindex = s2str['s']->index; |
|---|
| 42 | if (root->filter->bootstrap){ |
|---|
| 43 | int iseqlen = strlen(isequence); |
|---|
| 44 | int i; |
|---|
| 45 | for (i=root->filter->real_len-1;i>=0;i--){ |
|---|
| 46 | int pos = root->filter->bootstrap[i]; |
|---|
| 47 | if (pos >= iseqlen) continue; |
|---|
| 48 | c = s[pos]; |
|---|
| 49 | if (! (s2str[c] ) ) { // unknown character |
|---|
| 50 | continue; |
|---|
| 51 | } |
|---|
| 52 | int ind = s2str[simplify[c]]->index; |
|---|
| 53 | if (ind >= sindex) ind --; |
|---|
| 54 | d[i] = ind; |
|---|
| 55 | } |
|---|
| 56 | }else{ |
|---|
| 57 | char *f = root->filter->filter_mask; |
|---|
| 58 | int i = root->filter->filter_len; |
|---|
| 59 | while ( (c = (*s++)) ) { |
|---|
| 60 | if (!i) break; |
|---|
| 61 | i--; |
|---|
| 62 | if (*(f++)) { |
|---|
| 63 | if (! (s2str[c] ) ) { // unknown character |
|---|
| 64 | d++; |
|---|
| 65 | continue; |
|---|
| 66 | } |
|---|
| 67 | int ind = s2str[simplify[c]]->index; |
|---|
| 68 | if (ind >= sindex) ind --; |
|---|
| 69 | *(d++) = ind; |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | is_set_flag = AP_TRUE; |
|---|
| 74 | cashed_real_len = -1.0; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | AP_FLOAT AP_sequence_simple_protein::combine( const AP_sequence *, const AP_sequence *) { |
|---|
| 78 | return 0.0; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | void AP_sequence_simple_protein::partial_match(const AP_sequence* /*part*/, long */*overlap*/, long */*penalty*/) const { |
|---|
| 82 | awt_assert(0); // should be unused |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | |
|---|