15 #define LEFT_HELIX "{[<("
16 #define RIGHT_HELIX "}]>)"
66 bool BI_pairdef::is_pairtype(
char left,
char right,
BI_PAIR_TYPE pair_type)
const {
67 const char *pairs = pairs_def[pair_type];
68 int len = strlen(pairs)-1;
70 for (
int i=0; i<len; i+=3) {
71 if ((pairs[i] == left && pairs[i+1] == right) ||
72 (pairs[i] == right && pairs[i+1] == left)) {
81 right = toupper(right);
102 left = toupper(left);
103 right = toupper(right);
113 char *BI_helix::helix_error =
NULp;
129 for (
size_t i = 0; i<Size; ++i) {
130 if (entries[i].allocated) {
131 free(entries[i].helix_nr);
142 if (!*errorPtr && stack) {
151 for (; stack; stack =
next) {
178 size_t len = strlen(helix_in);
179 if (len > Size) len = Size;
181 char *h = ARB_alloc<char>(Size+1);
184 if (len<Size) memset(h+len,
'.', Size-len);
185 memcpy(h, helix_in, len);
189 char *helix_nr =
NULp;
191 size_t len = strlen(helix_nr_in);
192 if (len > Size) len = (
int)Size;
194 char *h = ARB_alloc<char>(Size+1);
197 if (len<Size) memset(h+len,
'.', (
int)(Size-len));
198 memcpy(h, helix_nr_in, len);
203 long pos_scanned_till = -1;
208 for (pos = 0; pos < Size; pos ++) {
210 if (
long(pos)>pos_scanned_till && isalnum(helix_nr[pos])) {
211 for (
int j=0; (pos+j)<Size; j++) {
212 char hn = helix_nr[pos+j];
218 pos_scanned_till = pos+j;
228 stack->
next = laststack;
248 helix_error =
GBS_global_string_copy(
"Character '%c' pos %li doesn't match character '%c' pos %zu in Helix '%s'",
249 stack->
c, stack->
pos, c, pos, ident);
262 if (!sident || strcmp(sident+1, ident) != 0) {
264 sprintf(sident,
"-%s", ident);
279 if (error) set_error(error);
311 if (gb_helix_nr_con) gb_helix_nr =
GBT_find_sequence(gb_helix_nr_con, alignment_name);
315 else if (!gb_helix_nr) set_error(
GBS_global_string(
"Can't find SAI:%s", helix_nr_name));
331 if (!alignment_name) {
335 init(gb_main, alignment_name);
336 free(alignment_name);
347 if (entries[pos].next_pair_pos == 0) {
350 for (p = pos+1; p<Size && next_pos == -1; ++p) {
354 else if (entries[p].next_pair_pos != 0) {
359 size_t q = p<Size ? p-2 : Size-1;
361 for (p = pos; p <= q; ++p) {
362 bi_assert(entries[p].next_pair_pos == 0);
372 if (strcmp(helix_Nr, entries[pos].helix_nr) == 0)
break;
381 while (next_pos != -1 && strcmp(helix_Nr, entries[next_pos].helix_nr) == 0) {
bool is_pairpos(size_t pos) const
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
int pair_strength(char left, char right)
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
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
static GB_ERROR get_error()
static long BI_helix_free_hash(const char *, long val, void *)
static void error(const char *msg)
long next_pair_position(size_t pos) const
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
void GBS_hash_do_loop(GB_HASH *hs, gb_hash_loop_type func, void *client_data)
char get_symbol(char left, char right) const
TYPE * ARB_calloc(size_t nelem)
GB_ERROR initFromData(const char *helix_nr, const char *helix, size_t size)
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)
GB_transaction ta(gb_var)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
GBDATA * GBT_get_SAI_data(GBDATA *gb_main)
static void BI_helix_check_error(const char *key, long val, void *client_data)
const BI_PAIR_TYPE PAIR_TYPE_COUNT
GB_ERROR init(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)