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];
86
87
if (!erg) erg = ' ';
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
char *helix = (char *)GB_calloc(sizeof(char), size()+1);
95
96
for (i=0; i<size2; i++) {
96
97
BI_PAIR_TYPE pairType = pairtype(i);
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)
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;
119
118
for (k=0; k<size; k++) {
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);
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);
136
int AW_helix::show_helix( void *devicei, int gc1 , char *sequence,
139
AW_CL cd1, AW_CL cd2){
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);
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;
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();
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;
162
pairdef[i+1] = right;
164
for (int j = 0; helix_awars[j].awar; j++) {
166
AW_awar *awar_pair2 = aw_root->awar(helix_pair_awar(j));
167
char *pd2 = awar_pair2->read_string();
169
bool modified = false;
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;
175
if ((left == l && right == r) || (left == r && right == l)) {
176
// remove duplicated pair
185
if (!pd2[k+2]) break;
190
awar_pair2->write_string(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();
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;
156
pairdef[i+1] = right;
158
for (int j = 0; helix_awars[j].awar; j++) {
160
AW_awar *awar_pair2 = aw_root->awar(helix_pair_awar(j));
161
char *pd2 = awar_pair2->read_string();
163
bool modified = false;
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;
169
if ((left == l && right == r) || (left == r && right == l)) {
170
// remove duplicated pair
179
if (!pd2[k+2]) break;
184
awar_pair2->write_string(pd2);
191
if (!pairdef[i+2]) break;
197
if (!pairdef[i+2]) break;
193
awar_pair->write_string(pairdef); // write back uppercase version
199
awar_pair->write_string(pairdef); // write back uppercase version
202
awcbs->run_callback();
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;
211
204
aws = new AW_window_simple;
212
205
aws->init(awr, "HELIX_PROPS", "HELIX_PROPERTIES");
215
aws->auto_space(3,3);
208
aws->auto_space(3, 3);
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");
222
215
aws->at_newline();
237
230
aw_assert(strlen(helix_awars[j].awar) <= max_awar_len);
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);
244
237
if (j == 0) ex = aws->get_at_xposition();
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);
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();