Changeset 8362 for branches

Show
Ignore:
Timestamp:
04/02/12 15:16:30 (4 months ago)
Author:
westram
Message:
  • sequence color mapping
    • fixed broken window layout
    • increased number of sets to 8
      • added symbolic ambiguity set as default
    • hide default value '=0'
Location:
branches/e4fix
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/e4fix/AWT/AWT_seq_colors.cxx

    r8136 r8362  
    2222static int default_AMI_set = 3;     // number of default amino acid set 
    2323 
    24 static const char *default_sets[AWT_SEQ_COLORS_MAX_SET] = { 
    25     // A B C D E F G H I J K L M N O P Q R S T U V W X Y Z * - 
     24#define SEQ_COLOR_SETS      8 
     25#define SEQ_COLOR_SET_ELEMS 28 // has to be a even number! 
     26 
     27static const char *default_sets[SEQ_COLOR_SETS] = { 
     28    //A B C D E F G H I J K L M N O P Q R S T U V W X Y Z * - 
    2629    "=2=0=3=0=0=0=4=0=0=0=0=0=0=6=0=0=0=0=0=5=5=0=0=0=0=0=0=6", // A, C, G, TU and N in 5 colors 
    2730    "R2=0Y3=0=0=0R2=0=0=0=0=0=0=0=0=0=0=2=0Y3Y3=0=0=0=3=0=0=6", // AG and CTU in 2 colors 
    2831    "=0=5=0=5=7=7=0=5=7=7=3=7=3=9=7=7=7=3=3=0=0=5=3=7=3=7=0=6", // ambiguity 
    2932    "=7=0=7=8=2=9=8=9=3=0=2=3=7=8=0=8=2=2=2=2=0=3=9=6=9=0=0=6", // Protein colors 
     33 
     34    "=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=6", 
     35    "o9=0|2=0=0=0o5=0=0=0=0=0=0=0=0=0=0=0=0|8|8=0=0=0=0=0=0=6", // ambiguity (symbols) 
     36    "=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=6", 
    3037    "=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=6", 
    3138}; 
     
    5360    return result; 
    5461} 
    55 static const char *default_color(int set, int elem) { 
     62static const char *default_color(int cset, int elem) { 
    5663    // returns default color numbers for seq-color-set 
    5764    static char result[3] = "=0"; 
    58     const char *pos       = default_sets[set]+2*elem; 
     65    const char *pos       = default_sets[cset]+2*elem; 
    5966 
    6067    result[0] = pos[0]; 
    6168    result[1] = pos[1]; 
     69 
     70    if (result[0] == '=' && result[1] == '0') result[0] = 0; 
    6271 
    6372    return result; 
     
    7584    awr->awar_int(AWAR_SEQ_NAME_SELECTOR_AA, default_AMI_set, AW_ROOT_DEFAULT)->add_callback((AW_RCB)awt_awar_changed_cb, (AW_CL)asc, 0); 
    7685 
    77     for (int elem = 0; elem<AWT_SEQ_COLORS_MAX_ELEMS; ++elem) { 
     86    for (int elem = 0; elem<SEQ_COLOR_SET_ELEMS; ++elem) { 
    7887        const char *awar_name = GBS_global_string(AWAR_SEQ_NAME_STRINGS_TEMPLATE, elem); 
    7988        awr->awar_string(awar_name, default_characters(elem)); 
    8089 
    81         for (int set = 0; set<AWT_SEQ_COLORS_MAX_SET; ++set) { 
    82             awar_name = GBS_global_string(AWAR_SEQ_NAME_TEMPLATE, set, elem); 
    83             awr->awar_string(awar_name, default_color(set, elem)); 
     90        for (int cset = 0; cset<SEQ_COLOR_SETS; ++cset) { 
     91            awar_name = GBS_global_string(AWAR_SEQ_NAME_TEMPLATE, cset, elem); 
     92            awr->awar_string(awar_name, default_color(cset, elem)); 
    8493        } 
    8594    } 
     
    96105 
    97106    aws = new AW_window_simple; 
    98     aws->init(awr, "SEQUENCE_COLOR_MAPPING", "SEQUENCE COLORS"); 
    99  
    100     aws->at           (10, 10); 
     107    aws->init(awr, "SEQUENCE_MAPPING", "Sequence color mapping"); 
     108 
     109    aws->at(10, 10); 
    101110    aws->auto_space(0, 3); 
    102111 
    103     aws->callback     (AW_POPDOWN); aws->create_button("CLOSE", "CLOSE", "C"); 
    104     aws->callback     (AW_POPUP_HELP, (AW_CL)"sequence_colors.hlp"); aws->create_button("HELP", "HELP"); 
     112    aws->callback(AW_POPDOWN); 
     113    aws->create_button("CLOSE", "CLOSE", "C"); 
     114 
     115    aws->callback(AW_POPUP_HELP, (AW_CL)"sequence_colors.hlp"); 
     116    aws->create_button("HELP", "HELP"); 
     117     
    105118    aws->at_newline(); 
    106  
    107     int set; 
    108119 
    109120    for (int seqType=0; seqType<2; seqType++) { 
    110121        if (seqType==0) { 
    111             aws->label("Select Colors For Nucleotides (NA) :"); 
     122            aws->label("Select color-set for Nucleotides (NA):"); 
    112123            aws->create_toggle_field(AWAR_SEQ_NAME_SELECTOR_NA, 1); 
    113124        } 
    114125        else { 
    115             aws->label("Select Colors For Amino Acids (AA) :"); 
     126            aws->label("Select color-set for Amino Acids (AA):"); 
    116127            aws->create_toggle_field(AWAR_SEQ_NAME_SELECTOR_AA, 1); 
    117128        } 
    118129 
    119         for (set = 0; set < AWT_SEQ_COLORS_MAX_SET; set++) { 
    120             sprintf(buf, "S_%i", set); 
    121             aws->insert_toggle(buf, " ", set); 
     130        for (int cset = 0; cset < SEQ_COLOR_SETS; cset++) { 
     131            sprintf(buf, "%i", cset+1); 
     132            aws->insert_toggle(buf, " ", cset); 
    122133        } 
    123134        aws->update_toggle_field(); 
     
    125136    } 
    126137 
    127     aws->label_length(6); 
    128     aws->button_length(6); 
    129  
    130     for (int big_columns = 0; big_columns <= 1; ++big_columns) { 
    131         aws->create_button(0, "Char"); 
    132         for (set = 0; set < AWT_SEQ_COLORS_MAX_SET; set++) { 
    133             sprintf(buf, "S %i", set); 
     138    const int BIG_COLUMNS    = 2; 
     139    const int CHAR_COL_WIDTH = 4; 
     140    const int SET_COL_WIDTH  = 2; 
     141 
     142    int col_x_off[BIG_COLUMNS][SEQ_COLOR_SETS+1]; 
     143 
     144    aws->auto_space(3, 2); 
     145 
     146    for (int bcol = 0; bcol<BIG_COLUMNS; ++bcol) { 
     147        col_x_off[bcol][0] = aws->get_at_xposition(); 
     148        aws->button_length(CHAR_COL_WIDTH); 
     149        aws->create_button(0, "Chars"); 
     150         
     151        aws->button_length(SET_COL_WIDTH); 
     152        for (int cset = 0; cset < SEQ_COLOR_SETS; cset++) { 
     153            sprintf(buf, "  %i", cset+1); 
     154            col_x_off[bcol][cset+1] = aws->get_at_xposition(); 
    134155            aws->create_button(0, buf); 
    135156        } 
    136157 
    137         buf[0] = 0; aws->create_button(0, buf); // empty 
    138     } 
     158        if (!bcol) { 
     159            int set_col_pixel_width = col_x_off[0][1]-col_x_off[0][0]; 
     160            aws->at_x(aws->get_at_xposition()+set_col_pixel_width); 
     161        } 
     162    } 
     163 
    139164    aws->at_newline(); 
    140     aws->auto_space(2, 2); 
    141  
    142     for (int elem = 0; elem < (AWT_SEQ_COLORS_MAX_ELEMS/2); elem++) { 
    143         for (int big_columns = 0; big_columns <= 1; ++big_columns) { 
    144             int my_elem = elem+big_columns*AWT_SEQ_COLORS_MAX_ELEMS/2; 
    145  
    146             sprintf(buf, AWAR_SEQ_NAME_STRINGS_TEMPLATE, my_elem); 
    147             aws->create_input_field(buf, 4); 
    148             for (set = 0; set < AWT_SEQ_COLORS_MAX_SET; set++) { 
    149                 sprintf(buf, AWAR_SEQ_NAME_TEMPLATE, set, my_elem); 
    150                 aws->create_input_field(buf, 4); 
    151             } 
    152             if (big_columns == 0) { 
    153                 buf[0] = 0; aws->create_button(0, buf); // empty 
     165 
     166    const int ROWS = SEQ_COLOR_SET_ELEMS/2; 
     167    for (int r = 0; r<ROWS; r++) { 
     168        for (int bcol = 0; bcol<BIG_COLUMNS; ++bcol) { 
     169            int elem = bcol*ROWS+r; 
     170 
     171            sprintf(buf, AWAR_SEQ_NAME_STRINGS_TEMPLATE, elem); 
     172            aws->at_x(col_x_off[bcol][0]); 
     173            aws->create_input_field(buf, CHAR_COL_WIDTH); 
     174 
     175            for (int cset = 0; cset < SEQ_COLOR_SETS; cset++) { 
     176                sprintf(buf, AWAR_SEQ_NAME_TEMPLATE, cset, elem); 
     177                aws->at_x(col_x_off[bcol][cset+1]); 
     178                aws->create_input_field(buf, SET_COL_WIDTH); 
    154179            } 
    155180        } 
     
    158183 
    159184    aws->window_fit(); 
    160     return (AW_window *)aws; 
     185     
     186    return aws; 
    161187} 
    162188 
     
    179205    for (int selector = 0; selector<2; selector++) { 
    180206        long def_set = selector == 0 ? default_NUC_set : default_AMI_set; 
    181         long set     = *GBT_readOrCreate_int(gb_def, selector_awar[selector], def_set); 
    182  
    183         if (set < 0 || set >= AWT_SEQ_COLORS_MAX_SET) { 
    184             set = def_set; 
    185         } 
    186  
    187         for (int elem = 0; elem < AWT_SEQ_COLORS_MAX_ELEMS; elem++) { 
     207        long cset    = *GBT_readOrCreate_int(gb_def, selector_awar[selector], def_set); 
     208 
     209        if (cset < 0 || cset >= SEQ_COLOR_SETS) { 
     210            cset = def_set; 
     211        } 
     212 
     213        for (int elem = 0; elem < SEQ_COLOR_SET_ELEMS; elem++) { 
    188214            sprintf(buf, AWAR_SEQ_NAME_STRINGS_TEMPLATE, elem); 
    189215            unsigned char *sc = (unsigned char *)GBT_readOrCreate_string(gb_def, buf, default_characters(elem)); 
     
    191217                GBDATA *gb_ne = GB_search(gb_def, buf, GB_STRING); 
    192218                GB_ensure_callback(gb_ne, GB_CB_CHANGED, awt_awar_changed_cb, (int *)this); 
    193                 for (int s2=0; s2<AWT_SEQ_COLORS_MAX_SET; s2++) { 
     219                for (int s2=0; s2<SEQ_COLOR_SETS; s2++) { 
    194220                    sprintf(buf, AWAR_SEQ_NAME_TEMPLATE, s2, elem); 
    195221                    GBT_readOrCreate_char_pntr(gb_def, buf, default_color(s2, elem)); // add default if missing 
     
    198224                } 
    199225            } 
    200             sprintf(buf, AWAR_SEQ_NAME_TEMPLATE, (int)set, elem); 
     226            sprintf(buf, AWAR_SEQ_NAME_TEMPLATE, (int)cset, elem); 
    201227            char *val = GBT_read_string(gb_def, buf); 
     228 
     229            if (strcmp(val, "=0") == 0) GBT_write_string(gb_def, buf, ""); // replace '=0' stored in props with '' 
     230            if (!val[0]) freedup(val, "=0"); // interpret '' as '  = 0' 
     231 
    202232            if (strlen(val) != 2 || val[1] >'9' || val[1] < '0') { 
    203233                aw_message(GB_export_errorf("Error in Color Lookup Table: '%s' is not of type X#", val)); 
  • branches/e4fix/AWT/awt_seq_colors.hxx

    r7623 r8362  
    2121#define AWAR_SEQ_NAME_SELECTOR_NA      AWAR_SEQ_PATH   "na/select" 
    2222#define AWAR_SEQ_NAME_SELECTOR_AA      AWAR_SEQ_PATH   "aa/select" 
    23  
    24 #define AWT_SEQ_COLORS_MAX_SET   5 
    25 #define AWT_SEQ_COLORS_MAX_ELEMS 28 // has to be a even number! 
    2623 
    2724class AWT_seq_colors { 
  • branches/e4fix/EDIT4/ED4_root.cxx

    r8353 r8362  
    16441644    SEP________________________SEP; 
    16451645 
    1646     awmm->insert_menu_topic("props_data",       "Change Colors & Fonts ", "C", 0,         AWM_ALL, AW_POPUP, (AW_CL)ED4_create_gc_window,      (AW_CL)first_gc_manager); 
    1647     awmm->insert_menu_topic("props_seq_colors", "Set Sequence Colors ",   "S", "no help", AWM_ALL, AW_POPUP, (AW_CL)create_seq_colors_window, (AW_CL)sequence_colors); 
     1646    awmm->insert_menu_topic("props_data",       "Change Colors & Fonts ", "C", 0,                     AWM_ALL, AW_POPUP, (AW_CL)ED4_create_gc_window,     (AW_CL)first_gc_manager); 
     1647    awmm->insert_menu_topic("props_seq_colors", "Sequence color mapping", "S", "sequence_colors.hlp", AWM_ALL, AW_POPUP, (AW_CL)create_seq_colors_window, (AW_CL)sequence_colors); 
    16481648 
    16491649    SEP________________________SEP; 
  • branches/e4fix/HELP_SOURCE/oldhelp/sequence_colors.hlp

    r6141 r8362  
    99 
    1010#************* Title of helpfile !! and start of real helpfile ******** 
    11 TITLE           Change Colors Of Sequences 
     11TITLE           Sequence color mapping 
    1212 
    13 OCCURRENCE      ARB_EDIT4 
     13OCCURRENCE      ARB_EDIT4/Properties/Sequence color mapping 
    1414 
    1515DESCRIPTION     The ARB_EDIT4 editor uses two tables to translate the 
     
    2020                      Each character in each sequence is translated into 
    2121                      a new character and a color index (0..9) using the definitions 
    22                       from the 'SEQUENCE COLORS' subwindow. 
     22                      from the 'Sequence color mapping' subwindow. 
    2323 
    24                       - There are different sets (S_0 .. S_#) of color shemes, 
    25                         one column for each set. 
     24                      - There are different sets (1..8) of color shemes, 
     25                        using two columns for each set. 
    2626 
    27                       - In the first row you may choose which set is used for translation. 
     27                      - At the top of the window you may choose which set is used 
     28                        for translation of nucleotides and aminoacids. 
    2829 
    2930                      - The first column shows the characters which should be 
    3031                        translated/replaced. 
    3132 
    32                       - The nth + 1 column holds the data for translation set n. 
     33                      - The Nth + 1 column holds the translation instruction for set N. 
    3334                        Each of its fields has two characters: 
    3435 
    35                            1. the character which should replace the original value, 
    36                            or '=' if no translation should be performed. 
     36                        - the character which should replace the original value, 
     37                          or '=' if no translation should be performed. 
    3738 
    38                            2. A color index for this character, between 0 and 9. 
     39                        - a color index for this character, between 0 and 9. 
     40 
     41                        The default for the translation instruction is '=0'  
    3942 
    4043                Second Step: 
     
    5962                - Only YR instead of ACGTU 
    6063                - Only ambiguous symbols 
    61                 - ... 
     64                - etc. 
    6265 
    6366BUGS            No bugs known