Changeset 8302 for trunk

Show
Ignore:
Timestamp:
13/12/11 14:01:48 (6 months ago)
Author:
westram
Message:
  • merges [8301] from stable and fixes conflicts with partly duplicate [6600]
Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/NTREE/ad_transpro.cxx

    r7272 r8302  
    338338// before deciding "X was realigned correctly" 
    339339 
    340 GB_ERROR arb_transdna(GBDATA *gb_main, char *ali_source, char *ali_dest, long *neededLength) 
    341 { 
     340static GB_ERROR arb_transdna(GBDATA *gb_main, char *ali_source, char *ali_dest, long *neededLength) { 
    342341    AP_initialize_codon_tables(); 
    343342 
    344343    GBDATA *gb_source = GBT_get_alignment(gb_main, ali_source); if (!gb_source) return "Please select a valid source alignment"; 
    345     GBDATA *gb_dest   = GBT_get_alignment(gb_main, ali_dest);  if (!gb_dest)   return "Please select a valid destination alignment"; 
     344    GBDATA *gb_dest   = GBT_get_alignment(gb_main, ali_dest);   if (!gb_dest)   return "Please select a valid destination alignment"; 
    346345 
    347346    long     ali_len            = GBT_get_alignment_len(gb_main, ali_dest); 
     
    349348    GB_ERROR error              = 0; 
    350349 
    351     arb_progress progress("Re-aligner", GBT_count_marked_species(gb_main)); 
     350    long no_of_marked_species    = GBT_count_marked_species(gb_main); 
     351    long no_of_realigned_species = 0; 
     352 
     353    arb_progress progress("Re-aligner", no_of_marked_species); 
    352354    progress.auto_subtitles("Re-aligning species"); 
    353355 
     
    637639            // re-alignment successful 
    638640            error = GB_write_string(gb_dest_data, buffer); 
     641 
    639642            if (!error) { 
    640                 int writeTableNr = -1; 
    641                 if (allowed_code.strictly_defined(writeTableNr)) { 
    642                     error = AWT_saveTranslationInfo(gb_species, writeTableNr, 1); // after re-alignment codon_start is always 1 
     643                int explicit_table_known = allowed_code.explicit_table(); 
     644 
     645                if (explicit_table_known >= 0) { // we know the exact code -> write codon_start and transl_table 
     646                    const int codon_start  = 1; // by definition (after realignment) 
     647                    error = AWT_saveTranslationInfo(gb_species, explicit_table_known, codon_start); 
     648                } 
     649                else { // we dont know the exact code -> delete codon_start and transl_table 
     650                    error = AWT_removeTranslationInfo(gb_species); 
    643651                } 
    644652            } 
     
    651659 
    652660        progress.inc_and_check_user_abort(error); 
    653     } 
    654  
    655     if (max_wanted_ali_len>0) { 
    656         if (neededLength) *neededLength = max_wanted_ali_len; 
    657     } 
    658  
    659     if (error) { 
    660         return error; 
    661     } 
    662  
    663     error = GBT_check_data(gb_main, ali_dest); 
     661        no_of_realigned_species++; 
     662    } 
     663 
     664    *neededLength = max_wanted_ali_len; 
     665 
     666    if (!error) { 
     667        int not_realigned = no_of_marked_species - no_of_realigned_species; 
     668        if (not_realigned>0) { 
     669            aw_message(GBS_global_string("Did not try to realign %i species (source/dest alignment missing?)", not_realigned)); 
     670        } 
     671    } 
     672 
     673    if (!error) error = GBT_check_data(gb_main,ali_dest); 
    664674 
    665675    return error; 
     
    682692        error = GB_end_transaction(GLOBAL_gb_main, error); 
    683693 
    684         if (neededLength > 0) { 
     694        if (!error && neededLength>0) { 
    685695            if (retrying || !aw_ask_sure(GBS_global_string("Increase length of '%s' to %li?", ali_dest, neededLength))) { 
    686696                error = GBS_global_string("Missing %li columns in alignment '%s'", neededLength, ali_dest); 
     
    695705                                                 "running re-aligner again!", 
    696706                                                 ali_dest, neededLength)); 
    697                     retrying = true; 
     707                    retrying     = true; 
     708                    neededLength = -1; 
    698709                } 
    699710            } 
  • trunk/SL/PRONUC/AP_codon_table.hxx

    r7653 r8302  
    7272    } 
    7373 
    74     bool strictly_defined(int& nr) { 
    75         nr = -1; 
    76         for (int table = 0; table<AWT_CODON_TABLES; ++table) { 
    77             if (is_allowed(table)) { 
    78                 if (nr != -1) return false; 
    79                 nr = table; 
     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; 
    8081            } 
    8182        } 
    82         return true; 
     83        return table; 
    8384    } 
    8485}; 
  • trunk/SL/TRANSLATE/Translate.cxx

    r7013 r8302  
    2626    GB_ERROR error    = GBT_write_string(gb_species, "transl_table", GBS_global_string("%i", embl_transl_table)); 
    2727    if (!error) error = GBT_write_string(gb_species, "codon_start",  GBS_global_string("%i", codon_start+1)); 
     28 
     29    return error; 
     30} 
     31 
     32GB_ERROR AWT_removeTranslationInfo(GBDATA *gb_species) { 
     33    GB_ERROR error = NULL; 
     34 
     35    GBDATA *gb_transl_table    = GB_entry(gb_species, "transl_table"); 
     36    if (gb_transl_table) error = GB_delete(gb_transl_table); 
     37 
     38    if (!error) { 
     39        GBDATA *gb_codon_start    = GB_entry(gb_species, "codon_start"); 
     40        if (gb_codon_start) error = GB_delete(gb_codon_start); 
     41    } 
    2842 
    2943    return error; 
  • trunk/SL/TRANSLATE/Translate.hxx

    r6381 r8302  
    2020GB_ERROR AWT_getTranslationInfo(GBDATA *gb_species, int& arb_transl_table, int &codon_start); 
    2121GB_ERROR AWT_saveTranslationInfo(GBDATA *gb_species, int arb_transl_table, int codon_start); 
     22GB_ERROR AWT_removeTranslationInfo(GBDATA *gb_species); 
    2223 
    2324int 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);