source: branches/stable/SL/SEQUENCE/AP_seq_simple_pro.cxx

Last change on this file was 16880, checked in by westram, 6 years ago
  • reintegrates 'multicore' into 'trunk'
    • derive sequence classes able to be combined from new class AP_combinableSeq
      • elim dummy functions from rest of hierarchy
    • implements non-writing combine for add-species (speedup: 25-35%)
    • introduce type Mutations ⇒ uses long everywhere (before mostly, but not always used float)
    • allows use of futures
      • nucleotide combine is able to calculate async (disabled via define atm → NEVER_COMBINE_ASYNC; needs more work on calling algorithm)
  • adds: log:branches/multicore@16769:16879
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 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 = NULp;
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 = NULp;
77    mark_sequence_set(false);
78}
79
80
81
Note: See TracBrowser for help on using the repository browser.