33 #define AWAR_REMAP_CANDIDATE AWAR_MERGE_TMP "remap_candidates"
34 #define AWAR_REMAP_ALIGNMENT AWAR_MERGE_TMP "remap_alignment"
35 #define AWAR_REMAP_SEL_REFERENCE AWAR_MERGE_TMP "remap_reference"
49 for (i = 0; ali_names[i]; ++i) {
51 if (!gb_ali_name) ali_names.
remove(i--);
73 for (
long i = 0; i<len; ++i) {
91 long len = strlen(bitstring);
109 int found_alignments;
110 long base_count_diff;
114 : name(is_species ? name_ :
string(
"SAI:")+name_)
116 found_alignments = 0;
123 for (
int i = 0; valid && ali_names[i]; ++i) {
130 base_count_diff = labs(src_bases-dst_bases);
135 if (base_count_diff>5) factor = 0.2;
136 else factor = (6-base_count_diff)*(1.0/6);
138 long min_bases = src_bases<dst_bases ? src_bases : dst_bases;
139 score += min_bases*factor;
144 if (!valid) found_alignments = 0;
151 const char *
get_name()
const {
return name.c_str(); }
153 return GBS_global_string(
"%24s %i %li %f", get_name(), found_alignments, base_count_diff, score);
157 int ali_diff = found_alignments-other.found_alignments;
158 if (ali_diff)
return ali_diff>0;
159 return score > other.score;
165 return c1->operator<(*c2);
174 bool aborted =
false;
178 gb_dst_species && !aborted;
184 Candidate *cand =
new Candidate(
true, dst_name, gb_src_species, gb_dst_species, ali_names);
187 candidates.insert(cand);
222 candidates.insert(cand);
254 if (0 == strcmp(ali,
"All")) {
265 Candidates::iterator e = candidates.end();
268 for (Candidates::iterator i = candidates.begin();
269 i != e && count<5000;
272 string name = (*i)->get_name();
273 string shown = (*i)->get_entry();
275 refCandList->
insert(shown.c_str(), name.c_str());
314 int cand_index = refs.
index_of(candidate);
315 int sel_index = refs.
index_of(selected);
317 if (cand_index == -1) refs.
put_before(sel_index+1, candidate);
318 else refs.
move(cand_index, sel_index);
340 int sel_index = refs.
index_of(selected);
342 if (sel_index >= 0) {
357 int sel_index = refs.
index_of(selected);
359 if (sel_index >= 0) {
360 refs.
move(sel_index, sel_index+1);
372 int sel_index = refs.
index_of(selected);
375 refs.
move(sel_index, sel_index-1);
389 free(reference_species_names);
402 AW_window_simple *aws =
new AW_window_simple;
404 aws->init(aw_root,
"SELECT_PRESERVES",
"Select adaption candidates");
405 aws->load_xfig(
"merge/preserves.fig");
409 aws->create_button(
"CLOSE",
"CLOSE",
"C");
413 aws->create_button(
"HELP",
"HELP",
"H");
425 aws->label(
"Adapt alignments");
428 aws->at(
"reference");
431 aws->button_length(8);
435 aws->create_button(
"CLEAR",
"Clear",
"C");
439 aws->create_button(
"DEL",
"Del",
"L");
443 aws->create_button(
"UP",
"Up",
"U");
447 aws->create_button(
"DOWN",
"Down",
"D");
451 aws->create_button(
"TEST",
"Test",
"T");
457 aws->create_autosize_button(
"FIND",
"Find candidates",
"F", 1);
461 aws->create_button(
"ADD",
"Add",
"A");
463 aws->at(
"candidate");
GBDATA * GBT_first_SAI(GBDATA *gb_main)
static void calculate_preserves_cb(AW_window *aww, preserve_para *para)
void put(const char *elem)
#define AWAR_REMAP_SEL_REFERENCE
int has_alignments() const
return string(buffer, length)
#define AWAR_REMAP_ALIGNMENT
AW_selection_list * usedRefsList
void insert_default(const char *displayed, const AW_scalar &value)
static void lower_reference_cb(AW_window *aww)
#define AWAR_REMAP_SPECIES_LIST
static void init_preserve_awars(AW_root *aw_root)
#define AWAR_REMAP_CANDIDATE
const char * GB_get_type_name(GBDATA *gbd)
void GBT_get_alignment_names(ConstStrArray &names, GBDATA *gbd)
char * GB_read_as_string(GBDATA *gbd)
const char * GBS_global_string(const char *templat,...)
GB_HASH * GBT_create_SAI_hash(GBDATA *gb_main)
void AW_POPDOWN(AW_window *window)
void GBS_free_hash(GB_HASH *hs)
GB_HASH * GBT_create_species_hash(GBDATA *gb_main)
const char * get_entry() const
AW_selection_list * alignmentList
AW_selection_list * refCandidatesList
AW_awar * add_callback(const RootCallback &cb)
void insert(const char *displayed, const AW_scalar &value)
const char * read_char_pntr() const
GB_ERROR GB_await_error()
WindowCallback makeHelpCallback(const char *helpfile)
long GB_read_count(GBDATA *gbd)
GB_TYPES GB_read_type(GBDATA *gbd)
int index_of(const char *search_for) const
static void find_species_candidates(Candidates &candidates, const CharPtrArray &ali_names)
static void clear_references_cb(AW_window *aww)
static void init_alignments(preserve_para *para)
AW_window * MG_create_preserves_selection_window(AW_root *aw_root)
set< SmartPtr< Candidate > > Candidates
static void add_selected_cb(AW_window *aww, preserve_para *para)
size_t GBS_hash_elements(const GB_HASH *hs)
static void raise_reference_cb(AW_window *aww)
char * read_string() const
CONSTEXPR_INLINE bool valid(SpeciesCreationMode m)
void put_before(int insert_before, const char *elem)
AW_awar * awar(const char *awar)
GBDATA * GBT_find_sequence(GBDATA *gb_species, const char *aliname)
static void test_references_cb(AW_window *aww)
static void read_references(ConstStrArray &refs, AW_root *aw_root)
static void clear_candidates(preserve_para *para)
static void find_SAI_candidates(Candidates &candidates, const CharPtrArray &ali_names)
char * GBT_join_strings(const CharPtrArray &strings, char separator)
GBDATA * GBT_next_SAI(GBDATA *gb_sai)
GB_ERROR GB_export_errorf(const char *templat,...)
static void get_global_alignments(ConstStrArray &ali_names)
static char * get_selected_reference(AW_root *aw_root)
void move_selection(int offset)
void move(int from, int to)
GBDATA * GBT_first_species(GBDATA *gb_main)
void aw_message(const char *msg)
static void write_references(AW_root *aw_root, const CharPtrArray &ref_array)
GBDATA * GB_find_string(GBDATA *gbd, const char *key, const char *str, GB_CASE case_sens, GB_SEARCH_TYPE gbs)
static void del_reference_cb(AW_window *aww)
bool is_std_gap(const char c)
GBDATA * GBT_next_species(GBDATA *gb_species)
GB_ERROR write_string(const char *aw_string)
static long count_bases(const char *data, long len)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
void init_from_array(const CharPtrArray &entries, const char *default_displayed, const char *default_value)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
GBDATA * GBT_get_presets(GBDATA *gb_main)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
#define AWAR_REMAP_ENABLE
static bool operator<(const SmartPtr< Candidate > &c1, const SmartPtr< Candidate > &c2)
const char * get_name() const
void GBT_splitNdestroy_string(ConstStrArray &names, char *&namelist, const char *separator, SplitMode mode)
GB_ERROR write_int(long aw_int)
long GBS_read_hash(const GB_HASH *hs, const char *key)
static void refresh_reference_list_cb(AW_root *aw_root, preserve_para *para)
static void select_reference(AW_root *aw_root, const char *ref_to_select)
static struct SearchAwarList awar_list[SEARCH_PATTERNS]
Candidate(bool is_species, const char *name_, GBDATA *gb_src, GBDATA *gb_dst, const CharPtrArray &ali_names)