~ubuntu-branches/debian/jessie/arb/jessie

« back to all changes in this revision

Viewing changes to SL/AW_HELIX/AW_helix.cxx

  • Committer: Package Import Robot
  • Author(s): Elmar Pruesse, Andreas Tille, Elmar Pruesse
  • Date: 2014-09-02 15:15:06 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140902151506-jihq58b3iz342wif
Tags: 6.0.2-1
[ Andreas Tille ]
* New upstream version
  Closes: #741890
* debian/upstream -> debian/upstream/metadata
* debian/control:
   - Build-Depends: added libglib2.0-dev
   - Depends: added mafft, mrbayes
* debian/rules
   - Add explicite --remove-section=.comment option to manual strip call
* cme fix dpkg-control
* arb-common.dirs: Do not create unneeded lintian dir
* Add turkish debconf translation (thanks for the patch to Mert Dirik
  <mertdirik@gmail.com>)
  Closes: #757497

[ Elmar Pruesse ]
* patches removed:
   - 10_config.makefiles.patch,
     80_no_GL.patch
       removed in favor of creating file from config.makefile.template via 
       sed in debian/control
   - 20_Makefile_main.patch
       merged upstream
   - 21_Makefiles.patch
       no longer needed
   - 30_tmpfile_CVE-2008-5378.patch: 
       merged upstream
   - 50_fix_gcc-4.8.patch:
       merged upstream
   - 40_add_libGLU.patch:
       libGLU not needed for arb_ntree)
   - 60_use_debian_packaged_raxml.patch:
       merged upstream
   - 70_hardening.patch
       merged upstream
   - 72_add_math_lib_to_linker.patch
       does not appear to be needed
* patches added:
   - 10_upstream_r12793__show_db_load_progress:
       backported patch showing progress while ARB is loading a database
       (needed as indicator/splash screen while ARB is launching)
   - 20_upstream_r12794__socket_permissions:
       backported security fix
   - 30_upstream_r12814__desktop_keywords:
       backported add keywords to desktop (fixes lintian warning)
   - 40_upstream_r12815__lintian_spelling:
       backported fix for lintian reported spelling errors
   - 50_private_nameservers
       change configuration to put nameservers into users home dirs
       (avoids need for shared writeable directory)
   - 60_use_debian_phyml
       use phyml from debian package for both interfaces in ARB
* debian/rules:
   - create config.makefile from override_dh_configure target
   - use "make tarfile" in override_dh_install
   - remove extra cleaning not needed for ARB 6
   - use "dh_install --list-missing" to avoid missing files
   - added override_dh_fixperms target
* debian/control:
   - added libarb-dev package
   - Depends: added phyml, xdg-utils
   - Suggests: removed phyml
   - fix lintian duplicate-short-description (new descriptions)
* debian/*.install:
   - "unrolled" confusing globbing to select files
   - pick files from debian/tmp
   - moved all config files to /etc/arb
* debian/arb-common.templates: updated
* scripts:
   - removed arb-add-pt-server
   - launch-wrapper: 
     - only add demo.arb to newly created $ARBUSERDATA
     - pass commandline arguments through bin/arb wrapper
   - preinst: removing old PT server index files on upgrade from 5.5*
   - postinst: set setgid on shared PT dir
* rewrote arb.1 manfile
* added file icon for ARB databases
* using upstream arb_tcp.dat

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
// ==================================================================== //
13
13
 
14
14
#include "AW_helix.hxx"
15
 
 
 
15
#include <aw_root.hxx>
 
16
#include <aw_window.hxx>
 
17
#include <aw_awar.hxx>
 
18
#include <aw_device.hxx>
 
19
#include <arbdbt.h>
16
20
#include <cctype>
17
 
#include <cstring>
18
 
#include <aw_device.hxx>
19
 
#include <aw_window.hxx>
20
21
 
21
22
#define HELIX_AWAR_ENABLE          "Helix/enable"
22
23
#define HELIX_AWAR_SYMBOL_TEMPLATE "Helix/symbols/%s"
27
28
    BI_PAIR_TYPE pair_type;
28
29
};
29
30
 
30
 
helix_pair_def helix_awars[] = {
 
31
static helix_pair_def helix_awars[] = {
31
32
    { "Strong_Pair",      HELIX_STRONG_PAIR },
32
33
    { "Normal_Pair",      HELIX_PAIR },
33
34
    { "Weak_Pair",        HELIX_WEAK_PAIR },
57
58
AW_helix::AW_helix(AW_root * aw_root)
58
59
    : enabled(0)
59
60
{
60
 
    for (int j=0; helix_awars[j].awar; j++){
 
61
    for (int j=0; helix_awars[j].awar; j++) {
61
62
        int i = helix_awars[j].pair_type;
62
63
        aw_root->awar_string(helix_pair_awar(j),   pairs[i])    ->add_target_var(&pairs[i]);
63
64
        aw_root->awar_string(helix_symbol_awar(j), char_bind[i])->add_target_var(&char_bind[i]);
65
66
    aw_root->awar_int(HELIX_AWAR_ENABLE, 1)->add_target_var(&enabled);
66
67
}
67
68
 
68
 
char AW_helix::get_symbol(char left, char right, BI_PAIR_TYPE pair_type){
 
69
char AW_helix::get_symbol(char left, char right, BI_PAIR_TYPE pair_type) {
69
70
    left  = toupper(left);
70
71
    right = toupper(right);
71
 
    
 
72
 
72
73
    int erg;
73
74
    if (pair_type < HELIX_NON_STANDARD0) {
74
75
        erg = *char_bind[HELIX_DEFAULT];
75
 
        for (int i = HELIX_STRONG_PAIR; i< HELIX_NON_STANDARD0; i++){
76
 
            if (is_pairtype(left,right,(BI_PAIR_TYPE)i)){
 
76
        for (int i = HELIX_STRONG_PAIR; i< HELIX_NON_STANDARD0; i++) {
 
77
            if (is_pairtype(left, right, (BI_PAIR_TYPE)i)) {
77
78
                erg = *char_bind[i];
78
79
                break;
79
80
            }
81
82
    }
82
83
    else {
83
84
        erg = *char_bind[HELIX_NO_MATCH];
84
 
        if (is_pairtype(left,right,pair_type)) erg =  *char_bind[pair_type];
 
85
        if (is_pairtype(left, right, pair_type)) erg = *char_bind[pair_type];
85
86
    }
86
87
    if (!erg) erg = ' ';
87
88
    return erg;
88
89
}
89
90
 
90
 
char *AW_helix::seq_2_helix(char *sequence,char undefsymbol){
 
91
char *AW_helix::seq_2_helix(char *sequence, char undefsymbol) {
91
92
    size_t size2 = strlen(sequence);
92
93
    bi_assert(size2<=size()); // if this fails there is a sequence longer than the alignment
93
 
    char *helix = (char *)GB_calloc(sizeof(char),size()+1);
94
 
    size_t i,j;
 
94
    char *helix = (char *)GB_calloc(sizeof(char), size()+1);
 
95
    size_t i, j;
95
96
    for (i=0; i<size2; i++) {
96
97
        BI_PAIR_TYPE pairType = pairtype(i);
97
98
 
107
108
    return helix;
108
109
}
109
110
 
110
 
int BI_show_helix_on_device(AW_device *device, int gc, const char *opt_string, size_t opt_string_size, size_t start, size_t size,
111
 
                            AW_pos x,AW_pos y, AW_pos opt_ascent,AW_pos opt_descent,
112
 
                            AW_CL cduser, AW_CL cd1, AW_CL cd2)
 
111
static bool BI_show_helix_on_device(AW_device *device, int gc, const char *opt_string, size_t opt_string_size, size_t start, size_t size,
 
112
                                    AW_pos x, AW_pos y, AW_pos /*opt_ascent*/, AW_pos /*opt_descent*/, AW_CL cduser)
113
113
{
114
 
    AWUSE(opt_ascent);AWUSE(opt_descent);
115
114
    AW_helix *helix = (AW_helix *)cduser;
116
115
    char *buffer = GB_give_buffer(size+1);
117
 
    register unsigned long i,j,k;
 
116
    register unsigned long i, j, k;
118
117
 
119
118
    for (k=0; k<size; k++) {
120
119
        i = k+start;
126
125
        else {
127
126
            j             = helix->opposite_position(i);
128
127
            char pairchar = j<opt_string_size ? opt_string[j] : '.';
129
 
            buffer[k]     = helix->get_symbol(opt_string[i],pairchar, pairType);
 
128
            buffer[k]     = helix->get_symbol(opt_string[i], pairchar, pairType);
130
129
        }
131
130
    }
132
131
    buffer[size] = 0;
133
 
    return device->text(gc,buffer,x,y,0.0,(AW_bitset)-1,cd1,cd2);
 
132
    return device->text(gc, buffer, x, y);
134
133
}
135
134
 
136
 
int AW_helix::show_helix( void *devicei, int gc1 , char *sequence,
137
 
                          AW_pos x, AW_pos y,
138
 
                          AW_bitset filter,
139
 
                          AW_CL cd1, AW_CL cd2){
140
 
 
 
135
int AW_helix::show_helix(void *devicei, int gc1, const char *sequence, AW_pos x, AW_pos y, AW_bitset filter) {
141
136
    if (!has_entries()) return 0;
142
137
    AW_device *device = (AW_device *)devicei;
143
 
    return device->text_overlay(gc1, sequence, 0, x , y, 0.0 , filter, (AW_CL)this, cd1, cd2,
144
 
                                1.0,1.0, BI_show_helix_on_device);
 
138
    return device->text_overlay(gc1, sequence, 0, AW::Position(x, y), 0.0,  filter, (AW_CL)this, 1.0, 1.0, BI_show_helix_on_device);
145
139
}
146
140
 
147
 
static void helix_pairs_changed_cb(AW_window *aww, AW_CL changed, AW_CL cl_cb_struct) {
 
141
static void helix_pairs_changed_cb(AW_window *aww, AW_CL changed, AW_CL cb) {
148
142
    static bool recursion = false;
149
143
 
150
144
    if (!recursion) {
151
 
        AW_cb_struct *awcbs     = reinterpret_cast<AW_cb_struct*>(cl_cb_struct);
152
 
        AW_root      *aw_root   = aww->get_root();
153
 
        AW_awar      *awar_pair = aw_root->awar(helix_pair_awar(changed));
154
 
        char         *pairdef   = awar_pair->read_string();
155
 
 
156
 
        recursion = true;
157
 
        for (int i = 0; ; i += 3) {
158
 
            char left  = toupper(pairdef[i]); if (!left) break;
159
 
            char right = toupper(pairdef[i+1]); if (!right) break;
160
 
 
161
 
            pairdef[i]   = left;
162
 
            pairdef[i+1] = right;
163
 
 
164
 
            for (int j = 0; helix_awars[j].awar; j++) {
165
 
                if (j != changed) {
166
 
                    AW_awar *awar_pair2 = aw_root->awar(helix_pair_awar(j));
167
 
                    char    *pd2        = awar_pair2->read_string();
168
 
                    int      dst        = 0;
169
 
                    bool     modified   = false;
170
 
 
171
 
                    for (int k = 0; ; k += 3) {
172
 
                        char l = toupper(pd2[k]); if (!l) break;
173
 
                        char r = toupper(pd2[k+1]); if (!r) break;
174
 
 
175
 
                        if ((left == l && right == r) || (left == r && right == l)) {
176
 
                            // remove duplicated pair
177
 
                            modified = true;
178
 
                        }
179
 
                        else {
180
 
                            pd2[dst]   = l;
181
 
                            pd2[dst+1] = r;
182
 
 
183
 
                            dst += 3;
184
 
                        }
185
 
                        if (!pd2[k+2]) break;
186
 
                    }
187
 
 
188
 
                    if (modified) {
189
 
                        pd2[dst-1] = 0;
190
 
                        awar_pair2->write_string(pd2);
191
 
                    }
192
 
 
193
 
                    free(pd2);
 
145
        AW_root *aw_root   = aww->get_root();
 
146
        AW_awar *awar_pair = aw_root->awar(helix_pair_awar(changed));
 
147
        char    *pairdef   = awar_pair->read_string();
 
148
 
 
149
        {
 
150
            LocallyModify<bool> flag(recursion, true);
 
151
            for (int i = 0; ; i += 3) {
 
152
                char left  = toupper(pairdef[i]); if (!left) break;
 
153
                char right = toupper(pairdef[i+1]); if (!right) break;
 
154
 
 
155
                pairdef[i]   = left;
 
156
                pairdef[i+1] = right;
 
157
 
 
158
                for (int j = 0; helix_awars[j].awar; j++) {
 
159
                    if (j != changed) {
 
160
                        AW_awar *awar_pair2 = aw_root->awar(helix_pair_awar(j));
 
161
                        char    *pd2        = awar_pair2->read_string();
 
162
                        int      dst        = 0;
 
163
                        bool     modified   = false;
 
164
 
 
165
                        for (int k = 0; ; k += 3) {
 
166
                            char l = toupper(pd2[k]); if (!l) break;
 
167
                            char r = toupper(pd2[k+1]); if (!r) break;
 
168
 
 
169
                            if ((left == l && right == r) || (left == r && right == l)) {
 
170
                                // remove duplicated pair
 
171
                                modified = true;
 
172
                            }
 
173
                            else {
 
174
                                pd2[dst]   = l;
 
175
                                pd2[dst+1] = r;
 
176
 
 
177
                                dst += 3;
 
178
                            }
 
179
                            if (!pd2[k+2]) break;
 
180
                        }
 
181
 
 
182
                        if (modified) {
 
183
                            pd2[dst-1] = 0;
 
184
                            awar_pair2->write_string(pd2);
 
185
                        }
 
186
 
 
187
                        free(pd2);
 
188
                    }
194
189
                }
 
190
 
 
191
                if (!pairdef[i+2]) break;
195
192
            }
196
 
 
197
 
            if (!pairdef[i+2]) break;
 
193
            awar_pair->write_string(pairdef); // write back uppercase version
198
194
        }
199
 
        awar_pair->write_string(pairdef); // write back uppercase version
200
 
        recursion = false;
201
 
 
202
 
        awcbs->run_callback();
 
195
        ((void (*)())cb)();
203
196
 
204
197
        free(pairdef);
205
198
    }
206
199
}
207
200
 
208
 
AW_window *create_helix_props_window(AW_root *awr, AW_cb_struct *awcbs){
 
201
AW_window *create_helix_props_window(AW_root *awr, void (*cb)(AW_window*)) {
209
202
    static AW_window_simple *aws = 0;
210
203
    if (!aws) {
211
204
        aws = new AW_window_simple;
212
205
        aws->init(awr, "HELIX_PROPS", "HELIX_PROPERTIES");
213
206
 
214
 
        aws->at(10,10);
215
 
        aws->auto_space(3,3);
 
207
        aws->at(10, 10);
 
208
        aws->auto_space(3, 3);
216
209
 
217
210
        aws->callback(AW_POPDOWN);
218
211
        aws->create_button("CLOSE", "CLOSE", "C");
219
 
        aws->callback( AW_POPUP_HELP, (AW_CL)"helixsym.hlp");
220
 
        aws->create_button("HELP","HELP","H");
 
212
        aws->callback(makeHelpCallback("helixsym.hlp"));
 
213
        aws->create_button("HELP", "HELP", "H");
221
214
 
222
215
        aws->at_newline();
223
216
 
225
218
        aws->label_length(max_awar_len);
226
219
 
227
220
        aws->label("Show helix?");
228
 
        aws->callback(awcbs);
 
221
        aws->callback(makeWindowCallback(cb));
229
222
        aws->create_toggle(HELIX_AWAR_ENABLE);
230
223
 
231
224
        aws->at_newline();
236
229
 
237
230
            aw_assert(strlen(helix_awars[j].awar) <= max_awar_len);
238
231
 
239
 
            if (i != HELIX_DEFAULT && i!= HELIX_NO_MATCH ) {
 
232
            if (i != HELIX_DEFAULT && i != HELIX_NO_MATCH) {
240
233
                aws->label(helix_awars[j].awar);
241
 
                aws->callback(helix_pairs_changed_cb, j, (AW_CL)awcbs);
 
234
                aws->callback(helix_pairs_changed_cb, j, (AW_CL)cb);
242
235
                aws->create_input_field(helix_pair_awar(j), 20);
243
 
                
 
236
 
244
237
                if (j == 0) ex = aws->get_at_xposition();
245
238
            }
246
239
            else {
247
240
                aw_assert(j != 0);
248
 
                aws->create_autosize_button(0,helix_awars[j].awar);
 
241
                aws->create_autosize_button(0, helix_awars[j].awar);
249
242
                aws->at_x(ex);
250
243
            }
251
244
 
252
 
            aws->callback(awcbs);
 
245
            aws->callback(makeWindowCallback(cb));
253
246
            aws->create_input_field(helix_symbol_awar(j), 3);
254
247
            aws->at_newline();
255
248
        }