Changeset 8301

Show
Ignore:
Timestamp:
13/12/11 13:30:13 (6 months ago)
Author:
westram
Message:
  • fixed some realigner bugs
    • when species did not contain transl_table and codon_start, the realigner inserted only codon_start.
      • the next realignment/translation failed since it expected BOTH or NONE of the two fields.
      • now the realigner
        • either writes both fields (if used transl_table is well-defined)
        • deletes both fields
    • when some/all species did not contain data in source and/or destination alignment, the realigner silently skipped them
      • now prints a message about skipped species
    • errors during realignment (e.g. protection errors) were not shown

Note: grml .. similar patch was already in trunk as [6600]

Location:
branches/stable_5.0
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/stable_5.0/AWT/AWT_translate.cxx

    r7019 r8301  
    2828    GB_ERROR error    = GBT_write_string(gb_species, "transl_table", GBS_global_string("%i", embl_transl_table)); 
    2929    if (!error) error = GBT_write_string(gb_species, "codon_start",  GBS_global_string("%i", codon_start+1)); 
     30 
     31    return error; 
     32} 
     33 
     34GB_ERROR AWT_removeTranslationInfo(GBDATA *gb_species) { 
     35    GB_ERROR error = NULL; 
     36 
     37    GBDATA *gb_transl_table    = GB_entry(gb_species, "transl_table"); 
     38    if (gb_transl_table) error = GB_delete(gb_transl_table); 
     39 
     40    if (!error) { 
     41        GBDATA *gb_codon_start    = GB_entry(gb_species, "codon_start"); 
     42        if (gb_codon_start) error = GB_delete(gb_codon_start); 
     43    } 
    3044 
    3145    return error; 
  • branches/stable_5.0/AWT/awt_codon_table.hxx

    r5968 r8301  
    7171        } 
    7272    } 
     73 
     74    int explicit_table() const { 
     75        // return explicit table number (or -1 if not exactly 1 table is allowed) 
     76        int table = -1; 
     77        for (int i = 0; i<AWT_CODON_TABLES; ++i) { 
     78            if (allowed[i]) { 
     79                if (table != -1) return -1; 
     80                table = i; 
     81            } 
     82        } 
     83        return table; 
     84    } 
    7385}; 
    7486 
  • branches/stable_5.0/AWT/awt_translate.hxx

    r5817 r8301  
    1414GB_ERROR AWT_getTranslationInfo(GBDATA *gb_species, int& arb_transl_table, int &codon_start); 
    1515GB_ERROR AWT_saveTranslationInfo(GBDATA *gb_species, int arb_transl_table, int codon_start); 
     16GB_ERROR AWT_removeTranslationInfo(GBDATA *gb_species); 
    1617 
    1718int AWT_pro_a_nucs_convert(int arb_code_nr, char *data, size_t size, size_t pos, bool translate_all, bool create_start_codon, bool append_stop_codon, int *translatedSize); 
  • branches/stable_5.0/NTREE/ad_transpro.cxx

    r6143 r8301  
    341341// before deciding "X was realigned correctly" 
    342342 
    343 GB_ERROR arb_transdna(GBDATA *gb_main, char *ali_source, char *ali_dest, long *neededLength) 
    344 { 
     343static GB_ERROR arb_transdna(GBDATA *gb_main, char *ali_source, char *ali_dest, long *neededLength) { 
    345344    AWT_initialize_codon_tables(); 
    346345 
     
    353352 
    354353    aw_openstatus("Re-aligner"); 
    355      
     354 
    356355    int no_of_marked_species    = GBT_count_marked_species(gb_main); 
    357356    int no_of_realigned_species = 0; 
     
    642641 
    643642            // re-alignment successful 
    644             error             = GB_write_string(gb_dest_data, buffer); 
    645             if (!error) error = GBT_write_string(gb_species, "codon_start", "1"); // after re-alignment codon_start is always 1 
     643            error = GB_write_string(gb_dest_data, buffer); 
     644 
     645            if (!error) { 
     646                int explicit_table_known = allowed_code.explicit_table(); 
     647 
     648                if (explicit_table_known >= 0) { // we know the exact code -> write codon_start and transl_table 
     649                    const int codon_start  = 1; // by definition (after realignment) 
     650                    error = AWT_saveTranslationInfo(gb_species, explicit_table_known, codon_start); 
     651                } 
     652                else { // we dont know the exact code -> delete codon_start and transl_table 
     653                    error = AWT_removeTranslationInfo(gb_species); 
     654                } 
     655            } 
    646656        } 
    647657 
     
    656666    aw_closestatus(); 
    657667 
    658     if (max_wanted_ali_len>0) { 
    659         if (neededLength) *neededLength = max_wanted_ali_len; 
    660     } 
    661  
    662     if (error) { 
    663         return error; 
    664     } 
    665  
    666     error = GBT_check_data(gb_main,ali_dest); 
    667  
     668    *neededLength = max_wanted_ali_len; 
     669 
     670    if (!error) { 
     671        int not_realigned = no_of_marked_species - no_of_realigned_species; 
     672        if (not_realigned>0) { 
     673            aw_message(GBS_global_string("Did not try to realign %i species (source/dest alignment missing?)", not_realigned)); 
     674        } 
     675    } 
     676 
     677    if (!error) error = GBT_check_data(gb_main,ali_dest); 
    668678    return error; 
    669679} 
     
    685695        error = GB_end_transaction(GLOBAL_gb_main, error); 
    686696 
    687         if (neededLength) { 
     697        if (!error && neededLength>0) { 
    688698            if (retrying || !aw_ask_sure(GBS_global_string("Increase length of '%s' to %li?", ali_dest, neededLength))) { 
    689699                error = GBS_global_string("Missing %li columns in alignment '%s'", neededLength, ali_dest); 
     
    698708                                                 "running re-aligner again!", 
    699709                                                 ali_dest, neededLength)); 
    700                     retrying = true; 
     710                    retrying     = true; 
     711                    neededLength = -1; 
    701712                } 
    702713            }