Changeset 6353

Show
Ignore:
Timestamp:
14/01/10 15:10:39 (2 years ago)
Author:
westram
Message:
  • removed useless variable 'species_read'
  • fixed overflow if too many missing species in configuration
    • shortened error message (show only first 200 missing species)
  • moved some duplicated code into ED4_init_notFoundMessage / ED4_finish_and_show_notFoundMessage
Location:
trunk/EDIT4
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/EDIT4/ED4_cursor.cxx

    r6347 r6353  
    592592} 
    593593 
     594void ED4_init_notFoundMessage() { 
     595    not_found_counter = 0; 
     596    not_found_message = GBS_stropen(10000); 
     597    // GBS_strcat(not_found_message,"Species not found: "); 
     598} 
     599void ED4_finish_and_show_notFoundMessage() { 
     600    if (not_found_counter != 0) { 
     601        GBS_strcat(not_found_message, GBS_global_string("(skipped display of %i more species)\n", not_found_counter-MAX_SHOWN_MISSING_SPECIES)); 
     602        char *out_message = GBS_strclose(not_found_message); 
     603        aw_message(out_message); 
     604        aw_message(GBS_global_string("Couldn't load %i species:", not_found_counter)); 
     605        free(out_message); 
     606    } 
     607    else { 
     608        GBS_strforget(not_found_message); 
     609    } 
     610    not_found_message = 0; 
     611} 
     612 
    594613void ED4_get_and_jump_to_species(GB_CSTR species_name) 
    595614{ 
     
    608627        ED4_index                  lot                 = 0; 
    609628 
    610         all_found         = 0; 
    611         not_found_message = GBS_stropen(1000); 
    612         GBS_strcat(not_found_message,"Species not found: "); 
     629        ED4_init_notFoundMessage(); 
    613630 
    614631        sprintf(string, "-L%s", species_name); 
     
    618635        loaded = 1; 
    619636 
    620         { 
    621             char *out_message = GBS_strclose(not_found_message); 
    622             not_found_message = 0; 
    623             if (all_found != 0) aw_message(out_message); 
    624             free(out_message); 
    625         } 
     637        ED4_finish_and_show_notFoundMessage(); 
    626638 
    627639        { 
     
    698710        aw_status("Loading species..."); 
    699711 
    700         all_found         = 0; 
    701         not_found_message = GBS_stropen(1000); 
    702         GBS_strcat(not_found_message,"Species not found: "); 
     712        ED4_init_notFoundMessage(); 
    703713 
    704714        while (gb_species) { 
     
    754764        aw_message(GBS_global_string("Loaded %i of %i marked species.", inserted, marked)); 
    755765 
    756         { 
    757             char *out_message = GBS_strclose(not_found_message); 
    758             not_found_message = 0; 
    759             if (all_found != 0) aw_message(out_message); 
    760             free(out_message); 
    761         } 
    762  
     766        ED4_finish_and_show_notFoundMessage(); 
     767         
    763768        if (inserted) { 
    764769            /* new AAseqTerminals should be created if it is in ProtView mode */ 
  • trunk/EDIT4/ED4_main.cxx

    r6347 r6353  
    5151int MAXINFOWIDTH;                                                       // # of pixels used to display sequence info ("CONS", "4data", etc.) 
    5252 
    53 long           ED4_counter = 0; 
    54 long           all_found;                                               // nr of species which haven't been found 
    55 long           species_read;                                            // nr of species read; important during loading 
     53long ED4_counter = 0; 
     54 
     55long           not_found_counter;                   // nr of species which haven't been found 
    5656GBS_strstruct *not_found_message; 
    57 long           max_seq_terminal_length;                                 // global maximum of sequence terminal length 
    58 ED4_EDITMODI   awar_edit_mode; 
    59 long           awar_edit_direction; 
    60 bool           move_cursor;                                             // only needed for editing in consensus 
    61 bool           DRAW; 
    62 bool           last_window_reached;                                     // needed for refreshing all windows (if TRUE refresh/...-flags will be cleared) 
     57 
     58long         max_seq_terminal_length;               // global maximum of sequence terminal length 
     59ED4_EDITMODI awar_edit_mode; 
     60long         awar_edit_direction; 
     61bool         move_cursor;                           // only needed for editing in consensus 
     62bool         DRAW; 
     63bool         last_window_reached;                   // needed for refreshing all windows (if TRUE refresh/...-flags will be cleared) 
    6364 
    6465void ED4_config_change_cb(AW_root *) 
  • trunk/EDIT4/ED4_no_class.cxx

    r6348 r6353  
    12801280    ED4_calc_terminal_extentions(); 
    12811281 
    1282     all_found = 0; 
    1283     species_read = 0; 
    12841282    max_seq_terminal_length = 0; 
    1285     not_found_message = GBS_stropen(1000); 
    1286     GBS_strcat(not_found_message,"Some species not found:\n"); 
     1283     
     1284    ED4_init_notFoundMessage(); 
    12871285 
    12881286 
  • trunk/EDIT4/ED4_root.cxx

    r6348 r6353  
    660660    aw_root->add_timed_callback(2000,ED4_timer,(AW_CL)0,(AW_CL)0); 
    661661 
    662     char *out_message = GBS_strclose(not_found_message); 
    663     not_found_message = 0; 
    664     if (all_found != 0) aw_message(out_message); 
    665     free(out_message); 
     662    ED4_finish_and_show_notFoundMessage(); 
    666663 
    667664    return ( ED4_R_OK ); 
     
    18791876    DRAW                    = 1; 
    18801877    move_cursor             = 0; 
    1881     all_found               = 0; 
    1882     species_read            = 0; 
    18831878    max_seq_terminal_length = 0; 
    18841879 
    1885     not_found_message = GBS_stropen(1000); 
    1886  
    1887     GBS_strcat(not_found_message,"Some species not found:\n"); 
     1880    ED4_init_notFoundMessage(); 
    18881881 
    18891882    return ( new_window->aww ); 
  • trunk/EDIT4/EDB_root_bact.cxx

    r6348 r6353  
    7171    } 
    7272 
    73  
    7473    if (!gb_datamode) { // didn't find this species 
    7574        char dummy[150]; 
    76         all_found++; 
    77         sprintf(dummy,"%ld. %s\n",all_found, str); 
    78         GBS_strcat(not_found_message,dummy); 
     75        not_found_counter++; 
     76        if (not_found_counter <= MAX_SHOWN_MISSING_SPECIES) { 
     77            sprintf(dummy,"%ld. %s\n", not_found_counter, str); 
     78            GBS_strcat(not_found_message,dummy); 
     79        } 
    7980        return ED4_R_BREAK; 
    8081    } 
    8182 
    82     // check whether sequence has data in desired alignment 
     83        // check whether sequence has data in desired alignment 
    8384    bool has_alignment = 0 != GB_entry(gb_datamode,ED4_ROOT->alignment_name); 
    8485    if (!has_alignment) { 
    8586        if (datamode == ED4_D_SPECIES) { // only warn about species w/o data (SAIs are skipped silently) 
    8687            char dummy[150]; 
    87             all_found++; 
    88             sprintf(dummy,"%ld. %s (no data in alignment)\n",all_found, str); 
    89             GBS_strcat(not_found_message,dummy); 
     88            not_found_counter++; 
     89            if (not_found_counter <= MAX_SHOWN_MISSING_SPECIES) { 
     90                sprintf(dummy,"%ld. %s (no data in alignment)\n", not_found_counter, str); 
     91                GBS_strcat(not_found_message,dummy); 
     92            } 
    9093        } 
    9194        return ED4_R_BREAK; 
     
    134137    local_count_position += max(name_coords, seq_coords); 
    135138    name_coords = seq_coords = 0; 
    136     species_read ++; 
    137139 
    138140    if (!(multi_species_manager->flag.hidden)) { 
     
    577579    sequence_terminal->parent->resize_requested_by_child(); 
    578580 
    579     species_read ++; 
    580581    (*y) += height_terminal + height_spacer; 
    581582 
  • trunk/EDIT4/ed4_class.hxx

    r6347 r6353  
    18171817void ED4_selected_SAI_changed_cb     (AW_root *aw_root); 
    18181818 
     1819void ED4_init_notFoundMessage(); 
     1820void ED4_finish_and_show_notFoundMessage(); 
     1821 
    18191822extern int  ED4_elements_in_species_container; // # of elements in species container 
    18201823void        ED4_undo_redo               (AW_window*, AW_CL undo_type); 
  • trunk/EDIT4/ed4_defs.hxx

    r6284 r6353  
    3737extern int SEQ_TERM_TEXT_YOFFSET; 
    3838 
    39 extern int            MAXSEQUENCECHARACTERLENGTH; // greatest # of characters in a sequence string terminal 
    40 extern int            MAXSPECIESWIDTH; 
    41 extern int            MAXINFOWIDTH; 
    42 extern long           ED4_counter; 
    43 extern long           all_found; // nr of species which haven't been found 
    44 extern long           species_read; // nr of species read; important during loading 
    45 extern GBS_strstruct *not_found_message; 
    46 extern long           max_seq_terminal_length; // global maximum of sequence terminal length 
    47 extern ED4_EDITMODI   awar_edit_mode; 
    48 extern long           awar_edit_direction; 
    49 extern bool           move_cursor; //only needed for editing in consensus 
    50 extern bool           DRAW; 
    51 extern bool           last_window_reached; //only needed for refreshing all windows 
     39extern int  MAXSEQUENCECHARACTERLENGTH;             // greatest # of characters in a sequence string terminal 
     40extern int  MAXSPECIESWIDTH; 
     41extern int  MAXINFOWIDTH; 
     42extern long ED4_counter; 
     43 
     44// use ED4_init_notFoundMessage and ED4_finish_and_show_notFoundMessage to 
     45// modify the following elements 
     46#define MAX_SHOWN_MISSING_SPECIES 200               // limit no of missing species/data printed into not_found_message 
     47extern long           not_found_counter;            // nr of species which haven't been found 
     48extern GBS_strstruct *not_found_message;            // error message containing (some) missing/unloadable species 
     49 
     50extern long         max_seq_terminal_length;        // global maximum of sequence terminal length 
     51extern ED4_EDITMODI awar_edit_mode; 
     52extern long         awar_edit_direction; 
     53extern bool         move_cursor;                    //only needed for editing in consensus 
     54extern bool         DRAW; 
     55extern bool         last_window_reached;            //only needed for refreshing all windows 
    5256 
    5357// globally used defines and flags