22 long cnt = *((
long*)counterPtr);
24 GB_warningf(
"Species '%s' has no data in any alignment", species_name);
26 *((
long*)counterPtr) = cnt+1;
63 if (!ali_name) error =
"Alignment w/o 'alignment_name'";
66 long security_write = -1;
67 long stored_ali_len = -1;
68 long found_ali_len = -1;
73 GBDATA *gb_ali_wsec =
GB_entry(preset_alignment,
"alignment_write_security");
75 error =
"has no 'alignment_write_security' entry";
84 gb_ali_len =
GB_entry(preset_alignment,
"alignment_len");
86 error =
"has no 'alignment_len' entry";
100 const char *name =
NULp;
101 int alignment_seen = 0;
109 gb_name =
GB_entry(gb_species,
"name");
111 GB_warningf(
"Seen unnamed species (gave name '%s')", unique);
118 if (species_name_hash) {
122 if (seen == 2) alignment_seen = 1;
137 error =
GBT_write_string(gb_ali,
"data",
"Error: entry 'data' was missing and therefore was filled with this text.");
138 GB_warningf(
"No '%s/data' entry for species '%s' (has been filled with dummy data)", ali_name, name);
143 error =
GBS_global_string(
"'%s/data' of species '%s' had wrong DB-type (%s) and has been deleted!",
148 if (found_ali_len != data_len) {
149 if (found_ali_len>0) aligned = 0;
150 if (found_ali_len<data_len) found_ali_len = data_len;
155 if (!alignment_seen && species_name_hash) {
177 if (!gb_sai_name)
continue;
181 gb_ali =
GB_entry(gb_sai, ali_name);
184 for (gb_sai_data =
GB_child(gb_ali);
196 if (found_ali_len != data_len) {
197 if (found_ali_len>0) aligned = 0;
198 if (found_ali_len<data_len) found_ali_len = data_len;
205 if (!error && stored_ali_len != found_ali_len) error =
GB_write_int(gb_ali_len, found_ali_len);
206 if (!error) error =
GBT_write_int(preset_alignment,
"aligned", aligned);
209 error =
GBS_global_string(
"Error checking alignment '%s':\n%s\n", ali_name, error);
233 if (alignment_name) {
236 error =
GBS_global_string(
"Alignment '%s' does not exist - it can't be checked.", alignment_name);
247 error = gb_ali_name ?
249 "No alignment defined";
253 if (!alignment_name && !error) {
278 "Found %li duplicated species with identical names!\n"
279 "Fix the problem using\n"
280 " 'Search For Equal Fields and Mark Duplicates'\n"
281 "in ARB_NTREE search tool, save DB and restart ARB.",
286 "Found %li species without IDs ('name')!\n"
287 "This is a sewere problem!\n"
288 "ARB will not work as expected!",
302 if (species_name_hash) {
307 GB_warningf(
"Found %li species without alignment data (only some were listed)", counter);
331 char *ali_other =
NULp;
334 for (counter = 1; !ali_other; ++counter) {
346 error =
GBS_global_string(
"alignment name '%s' has to start with 'ali_'", alignment_name);
364 "(Reason: %s)", field, error);
382 "(Reason: %s)", field, error);
403 if (!error && (security<0 || security>6)) {
404 error =
GBS_global_string(
"Illegal security value %li (allowed 0..6)", security);
407 const char *allowed_types =
":dna:rna:ami:usr:";
408 int tlen = strlen(type);
409 const char *found = strstr(allowed_types, type);
410 if (!found || found == allowed_types || found[-1] !=
':' || found[tlen] !=
':') {
436 if (!error) result = gb_ali;
460 for (gb_item =
GB_entry(gb_item_container, item_entry_name);
465 if (!gb_ali)
continue;
481 if (error && gb_item) {
496 bool is_case_error =
false;
512 if (!gb_old_alignment) {
521 is_case_error = (strcasecmp(source, dest) == 0);
529 if (!error) error =
GBT_write_string(gb_new_alignment,
"alignment_name", dest);
534 if (mode !=
COPY && !error) {
542 if (!error && mode ==
MOVE) {
559 error =
"Cannot copy alignment if destination name only differs in case.";
570 printf(
"Renaming alignment '%s' -> '%s' -> '%s' (to avoid case-problem)\n", source, ali_other, dest);
579 error = ta.
close(error);
610 error =
GBS_global_string(
"Invalid alignment name '%s' (Reason: %s)", ali_name, error);
690 if (result != 0 && result != 1) {
691 error =
"Illegal value for 'ARB_partial' (only 1 or 0 allowed)";
695 if (define_if_undef) {
696 error =
GBT_write_int(gb_species,
"ARB_partial", default_value);
698 result = default_value;
721 static SmartCharPtr startup_ali_name;
723 char *ali_name =
NULp;
724 if (startup_ali_name.isSet()) {
739 if (ali_name && use_startup_ali) {
778 bool freeze_and_reset =
false;
782 freeze_and_reset =
true;
785 freeze_and_reset = strcmp(default_ali, alignment_name) != 0;
787 if (freeze_and_reset) {
793 if (strcmp(startup_ali, alignment_name) != 0) {
794 error =
GBS_global_string(
"Cannot freeze alignment to '%s' (already was frozen to '%s' before)", alignment_name, startup_ali);
802 error = error ? error : minerr;
821 if (!gb_alignment_name) {
839 long len = gb_alignment ? *
GBT_read_int(gb_alignment,
"alignment_len") : -1;
857 error =
GBT_write_int(gb_alignment,
"alignment_len", new_len);
858 if (!error) error =
GBT_write_int(gb_alignment,
"aligned", 0);
886 switch (ali_type[0]) {
887 case 'r':
if (strcmp(ali_type,
"rna")==0) at =
GB_AT_RNA;
break;
888 case 'd':
if (strcmp(ali_type,
"dna")==0) at =
GB_AT_DNA;
break;
889 case 'a':
if (strcmp(ali_type,
"ami")==0) at =
GB_AT_AA;
break;
890 case 'p':
if (strcmp(ali_type,
"pro")==0) at =
GB_AT_AA;
break;
909 static char *last_genome =
NULp;
911 if (gb_genome != gb_last_genome) {
915 gb_last_genome = gb_genome;
935 for (i = 0; i<256; ++i) gpp->
offset[i] = 0;
937 gpp->
offset[(
int)
'+'] = 1;
945 int forParts = parts+10;
947 memset(gpp->
certain,
'=', forParts);
949 gpp->
parts = forParts;
985 int parts = pos->
parts;
987 int separatorSize = partSeparator ? 1 : 0;
992 for (p = 0; p<parts && !
error; p++) {
997 if (start<1 || start>(stop+1) || stop > seq_length) {
998 error =
GBS_global_string(
"Illegal gene position(s): start=%zu, end=%zu, seq.length=%li",
999 start, stop, seq_length);
1002 resultlen += stop-start+1;
1006 if (separatorSize) resultlen += (parts-1)*separatorSize;
1010 if (use_revComplement) {
1025 if (gene_length) *gene_length = resultlen;
1027 for (p = 0; p<parts; ++p) {
1032 int len = stop-start+1;
1034 if (separatorSize && p>0) *resultpos++ = partSeparator;
1036 memcpy(resultpos, seq_data+start-1, len);
1053 error =
GB_export_errorf(
"Can't read sequence of '%s' (Reason: %s)",
id, error);
1071 #define TEST_EXPECT_EXISTING_ALIGNMENTS(expected) do{ \
1073 GBT_get_alignment_names(names, gb_main); \
1074 TEST_EXPECT_STRARRAY_CONTAINS(names, '*', expected); \
1078 #define TEST_EXPECT_EXISTING_ALIGNMENTS__BROKEN(want,got) do{ \
1080 GBT_get_alignment_names(names, gb_main); \
1081 TEST_EXPECT_STRARRAY_CONTAINS__BROKEN(names, '*', want,got); \
1086 #define TEST_EXPECT_DEFAULT_ALIGNMENT(expected) \
1087 TEST_EXPECT_EQUAL_STRINGCOPY__NOERROREXPORTED(GBT_get_default_alignment(gb_main), expected);
1090 #define TEST_EXPECT_ALIGNMENT_STATE(expected_default,expected_existing) do{ \
1091 GB_initial_transaction ta(gb_main); \
1092 TEST_EXPECT_DEFAULT_ALIGNMENT(expected_default); \
1093 TEST_EXPECT_EXISTING_ALIGNMENTS(expected_existing); \
1096 void TEST_alignment() {
1106 TEST_EXPECT_DEFAULT_ALIGNMENT(
"ali_tuf_dna");
1107 TEST_EXPECT_EXISTING_ALIGNMENTS(
"ali_tuf_pro*ali_tuf_dna");
1109 for (
int i = 0; names[i]; ++i) {
1136 TEST_EXPECT_ALIGNMENT_STATE(
"ali_tuf_dna",
"ali_tuf_pro*ali_tuf_dna");
1145 TEST_EXPECT_ALIGNMENT_STATE(
"ali_tuf_dna",
"ali_tuf_pro*ali_tuf_dna*ali_copied_pro*ali_copied_dna");
1152 TEST_EXPECT_ALIGNMENT_STATE(
"ali_tuf_dna",
"ali_tuf_pro*ali_tuf_dna*ali_copied_pro*ali_copied_dna");
1160 TEST_EXPECT_ALIGNMENT_STATE(
"ali_moved_dna",
"ali_copied_pro*ali_copied_dna*ali_moved_pro*ali_moved_dna");
1168 TEST_EXPECT_ALIGNMENT_STATE(
"ali_moved_dna",
1169 "ali_copied_dna*ali_moved_pro");
1183 TEST_EXPECT_ALIGNMENT_STATE(
"ali_copied_DNA",
"ali_moved_pro*ali_copied_DNA");
1189 #endif // UNIT_TESTS
GB_ERROR GB_check_key(const char *key) __ATTR__USERESULT
GB_ERROR GB_copy_dropProtectMarksAndTempstate(GBDATA *dest, GBDATA *source)
GB_ERROR GBT_rename_alignment(GBDATA *gbMain, const char *source, const char *dest)
long GBT_get_alignment_len(GBDATA *gb_main, const char *aliname)
GBDATA * GB_open(const char *path, const char *opent)
unsigned char * complement
void put(const char *elem)
long GB_read_int(GBDATA *gbd)
static GB_ERROR copy_move_del_alignment(GBDATA *gbMain, const char *source, const char *dest, CopyMoveDelMode mode)
GBDATA * GB_child(GBDATA *father)
static void init_gpp(int parts)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
#define GB_DEFAULT_ALIGNMENT
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
char * GBT_read_gene_sequence(GBDATA *gb_gene, bool use_revComplement, char partSeparator)
void GEN_free_position(GEN_position *pos)
long GBS_incr_hash(GB_HASH *hs, const char *key)
static void getPartPositions(const GEN_position *pos, int part, size_t *startPos, size_t *stopPos)
GBDATA * GB_nextEntry(GBDATA *entry)
static const char * gb_cache_genome(GBDATA *gb_genome)
static GB_ERROR create_ali_strEntry(GBDATA *gb_ali, const char *field, const char *strval, long write_protection)
char * ARB_strdup(const char *str)
const char * ARB_date_string()
const char * GBS_global_string(const char *templat,...)
static char * alignment_name
void GEN_sortAndMergeLocationParts(GEN_position *location)
void GBS_free_hash(GB_HASH *hs)
GBDATA * GBT_get_tree_data(GBDATA *gb_main)
static char * get_default_alignment(GBDATA *gb_main, bool use_startup_ali)
GBDATA * GB_get_grandfather(GBDATA *gbd)
GBDATA * GB_get_father(GBDATA *gbd)
static char * gbt_nonexisting_alignment(GBDATA *gbMain)
GBDATA * GBT_get_alignment(GBDATA *gb_main, const char *aliname)
GB_ERROR GBT_delete_alignment(GBDATA *gbMain, const char *source)
GB_ERROR GB_delete(GBDATA *&source)
GBDATA * GBT_first_species_rel_species_data(GBDATA *gb_species_data)
static HelixNrInfo * start
GB_ERROR GB_check_hkey(const char *key) __ATTR__USERESULT
#define TEST_PUBLISH(testfunction)
#define TEST_EXPECT_CONTAINS(str, part)
GB_ERROR GB_export_error(const char *error)
size_t GB_read_string_count(GBDATA *gbd)
GB_ERROR GB_await_error()
GB_alignment_type GBT_get_alignment_type(GBDATA *gb_main, const char *aliname)
NOT4PERL long * GBT_read_int(GBDATA *gb_container, const char *fieldpath)
GBDATA * GB_create_container(GBDATA *father, const char *key)
long GB_read_count(GBDATA *gbd)
char * GBT_read_string(GBDATA *gb_container, const char *fieldpath)
GB_TYPES GB_read_type(GBDATA *gbd)
void GB_warningf(const char *templat,...)
TYPE * ARB_alloc(size_t nelem)
GB_CSTR GB_read_key_pntr(GBDATA *gbd)
NOT4PERL void GBT_reverseComplementNucSequence(char *seq, long length, char T_or_U)
GB_ERROR GBT_copy_alignment(GBDATA *gbMain, const char *source, const char *dest)
GBDATA * GB_create(GBDATA *father, const char *key, GB_TYPES type)
GBDATA * GBT_get_presets(GBDATA *gb_main)
unsigned char * start_uncertain
void GBS_hash_do_const_loop(const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
NOT4PERL char * GBT_read_gene_sequence_and_length(GBDATA *gb_gene, bool use_revComplement, char partSeparator, size_t *gene_length)
static void check_for_species_without_data(const char *species_name, long value, void *counterPtr)
char * GBT_create_unique_species_name(GBDATA *gb_main, const char *default_name)
static void error(const char *msg)
char * GBT_get_alignment_type_string(GBDATA *gb_main, const char *aliname)
GBDATA * GBT_first_SAI_rel_SAI_data(GBDATA *gb_sai_data)
char * GBT_get_default_alignment(GBDATA *gb_main)
GB_ERROR GB_write_security_write(GBDATA *gbd, unsigned long level)
NOT4PERL GBDATA * GBT_add_data(GBDATA *species, const char *ali_name, const char *key, GB_TYPES type)
GB_ERROR GB_write_int(GBDATA *gbd, long i)
GB_ERROR GBT_set_alignment_len(GBDATA *gb_main, const char *aliname, long new_len)
int GBT_count_alignments(GBDATA *gb_main)
int GBT_is_partial(GBDATA *gb_species, int default_value, bool define_if_undef)
GBDATA * GBT_next_SAI(GBDATA *gb_sai)
static GB_ERROR GBT_check_alignment(GBDATA *gb_main, GBDATA *preset_alignment, GB_HASH *species_name_hash)
GB_ERROR GB_export_errorf(const char *templat,...)
bool GBT_is_alignment_protein(GBDATA *gb_main, const char *alignment_name)
char * GEN_global_gene_identifier(GBDATA *gb_gene, GBDATA *gb_organism)
GB_ERROR close(GB_ERROR error)
static gene_part_pos * gpp
GB_ERROR GBT_set_default_alignment(GBDATA *gb_main, const char *alignment_name)
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
static GB_ERROR gbt_rename_alignment_of_item(GBDATA *gb_item_container, const char *item_name, const char *item_entry_name, const char *source, const char *dest, CopyMoveDelMode mode)
GBDATA * GBT_create_alignment(GBDATA *gb_main, const char *name, long len, long aligned, long security, const char *type, const char *why_created)
char * GB_read_string(GBDATA *gbd)
GBDATA * GBT_find_or_create(GBDATA *father, const char *key, long delete_level)
char * GBT_get_startup_alignment(GBDATA *gb_main)
void GBT_get_alignment_names(ConstStrArray &names, GBDATA *gbd)
GB_ERROR GB_write_security_delete(GBDATA *gbd, unsigned long level)
uint32_t GBS_checksum(const char *seq, int ignore_case, const char *exclude)
#define TEST_EXPECT_NO_ERROR(call)
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
GBDATA * GB_find_string(GBDATA *gbd, const char *key, const char *str, GB_CASE case_sens, GB_SEARCH_TYPE gbs)
GB_ERROR GBT_check_alignment_name(const char *alignment_name)
GBDATA * GBT_next_species(GBDATA *gb_species)
#define TEST_EXPECT_ERROR_CONTAINS(call, part)
GB_ERROR GBT_check_data(GBDATA *Main, const char *alignment_name)
bool ARB_strBeginsWith(const char *str, const char *with)
const char * GBT_get_name(GBDATA *gb_item)
GBDATA * GB_nextChild(GBDATA *child)
long GBT_get_species_count(GBDATA *gb_main)
GB_transaction ta(gb_var)
GB_ERROR GBT_write_int(GBDATA *gb_container, const char *fieldpath, long content)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
GBDATA * GBT_get_SAI_data(GBDATA *gb_main)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
GB_ERROR GBT_set_startup_alignment(GBDATA *gb_main, const char *alignment_name)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
NOT4PERL GBDATA * GBT_create_sequence_data(GBDATA *species, const char *ali_name, const char *key, GB_TYPES type, int security_write)
GEN_position * GEN_read_position(GBDATA *gb_gene)
#define TEST_EXPECT_EQUAL(expr, want)
GBDATA * GBT_gen_accession_number(GBDATA *gb_species, const char *ali_name)
long GBS_read_hash(const GB_HASH *hs, const char *key)
GBDATA * GB_entry(GBDATA *father, const char *key)
static GB_ERROR create_ali_intEntry(GBDATA *gb_ali, const char *field, int intval, long write_protection)
char * GBS_global_string_copy(const char *templat,...)
void GB_close(GBDATA *gbd)
NOT4PERL GB_ERROR GBT_determine_T_or_U(GB_alignment_type alignment_type, char *T_or_U, const char *supposed_target)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
unsigned char * stop_uncertain
GBDATA * GBT_get_species_data(GBDATA *gb_main)