17 #define LEFT_HELIX "{[<("
18 #define RIGHT_HELIX "}]>)"
19 #define LEFT_NONS "#*abcdefghij"
20 #define RIGHT_NONS "#*ABCDEFGHIJ"
22 char *BI_helix::helix_error =
NULp;
31 void BI_helix::_init() {
70 pairs[i] = strdup(
"");
88 for (i = 0; i<Size; ++i) {
89 if (entries[i].allocated) {
90 free(entries[i].helix_nr);
108 for (; stack; stack =
next) {
135 size_t len = strlen(helix_in);
136 if (len > Size) len = Size;
138 char *h = ARB_alloc<char>(Size+1);
141 if (len<Size) memset(h+len,
'.', Size-len);
142 memcpy(h, helix_in, len);
146 char *helix_nr =
NULp;
148 size_t len = strlen(helix_nr_in);
149 if (len > Size) len = (
int)Size;
151 char *h = ARB_alloc<char>(Size+1);
154 if (len<Size) memset(h+len,
'.', (
int)(Size-len));
155 memcpy(h, helix_nr_in, len);
160 long pos_scanned_till = -1;
165 for (pos = 0; pos < Size; pos ++) {
167 if (
long(pos)>pos_scanned_till && isalnum(helix_nr[pos])) {
168 for (
int j=0; (pos+j)<Size; j++) {
169 char hn = helix_nr[pos+j];
175 pos_scanned_till = pos+j;
185 stack->
next = laststack;
205 helix_error =
GBS_global_string_copy(
"Character '%c' pos %li doesn't match character '%c' pos %zu in Helix '%s'",
206 stack->
c, stack->
pos, c, pos, ident);
222 if (!sident || strcmp(sident+1, ident) != 0) {
224 sprintf(sident,
"-%s", ident);
249 const char *BI_helix::init(
GBDATA *gb_helix_nr,
GBDATA *gb_helix,
size_t sizei) {
252 if (!gb_helix)
set_error(
"Can't find SAI:HELIX");
253 else if (!gb_helix_nr)
set_error(
"Can't find SAI:HELIX_NR");
278 if (gb_helix_nr_con) gb_helix_nr =
GBT_find_sequence(gb_helix_nr_con, alignment_name);
281 init(gb_helix_nr, gb_helix, size2);
287 const char *BI_helix::init(
GBDATA *gb_main,
const char *alignment_name) {
293 const char *err =
init(gb_main, alignment_name, helix_nr, helix);
301 const char *BI_helix::init(
GBDATA *gb_main) {
305 const char *err =
init(gb_main, alignment_name);
307 free(alignment_name);
312 int len = strlen(
pairs[pair_type])-1;
313 char *pai =
pairs[pair_type];
315 for (
int i=0; i<len; i+=3) {
316 if ((pai[i] == left && pai[i+1] == right) ||
317 (pai[i] == right && pai[i+1] == left))
return true;
329 left = toupper(left);
330 right = toupper(right);
344 return is_pairtype(left, right, pair_type) ? 1 : 0;
353 if (entries[pos].next_pair_pos == 0) {
356 for (p = pos+1; p<Size && next_pos == -1; ++p) {
360 else if (entries[p].next_pair_pos != 0) {
365 size_t q = p<Size ? p-2 : Size-1;
367 for (p = pos; p <= q; ++p) {
368 bi_assert(entries[p].next_pair_pos == 0);
378 if (strcmp(helix_Nr, entries[pos].helix_nr) == 0)
break;
387 while (next_pos != -1 && strcmp(helix_Nr, entries[next_pos].helix_nr) == 0) {
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
long first_position(const char *helixNr) const
const char * GBS_global_string(const char *templat,...)
long GBT_get_alignment_len(GBDATA *gb_main, const char *aliname)
static char * alignment_name
void GBS_free_hash(GB_HASH *hs)
char * GBT_get_default_helix_nr(GBDATA *)
long last_position(const char *helixNr) const
char * char_bind[HELIX_MAX]
GB_ERROR GB_await_error()
TYPE * ARB_alloc(size_t nelem)
void GBS_hash_do_const_loop(const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
long first_pair_position() const
bool is_pairtype(char left, char right, BI_PAIR_TYPE pair_type)
static long BI_helix_free_hash(const char *, long val, void *)
long next_pair_position(size_t pos) const
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
static void set_error(const char *err)
void GBS_hash_do_loop(GB_HASH *hs, gb_hash_loop_type func, void *client_data)
TYPE * ARB_calloc(size_t nelem)
int check_pair(char left, char right, BI_PAIR_TYPE pair_type)
static char * get_error()
static ARB_init_perl_interface init
char * GBT_get_default_helix(GBDATA *)
char * GBT_get_default_alignment(GBDATA *gb_main)
GBDATA * GBT_find_SAI_rel_SAI_data(GBDATA *gb_sai_data, const char *name)
static void clear_error()
const char * initFromData(const char *helix_nr, const char *helix, size_t size)
GB_transaction ta(gb_var)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
static void BI_helix_check_error(const char *key, long val, void *)
GBDATA * GBT_get_SAI_data(GBDATA *gb_main)
struct helix_stack * next
long GBS_read_hash(const GB_HASH *hs, const char *key)
char * GBS_global_string_copy(const char *templat,...)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)