- Timestamp:
- 13/12/11 14:01:48 (6 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
NTREE/ad_transpro.cxx (modified) (6 diffs)
-
SL/PRONUC/AP_codon_table.hxx (modified) (1 diff)
-
SL/TRANSLATE/Translate.cxx (modified) (1 diff)
-
SL/TRANSLATE/Translate.hxx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/NTREE/ad_transpro.cxx
r7272 r8302 338 338 // before deciding "X was realigned correctly" 339 339 340 GB_ERROR arb_transdna(GBDATA *gb_main, char *ali_source, char *ali_dest, long *neededLength) 341 { 340 static GB_ERROR arb_transdna(GBDATA *gb_main, char *ali_source, char *ali_dest, long *neededLength) { 342 341 AP_initialize_codon_tables(); 343 342 344 343 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"; 346 345 347 346 long ali_len = GBT_get_alignment_len(gb_main, ali_dest); … … 349 348 GB_ERROR error = 0; 350 349 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); 352 354 progress.auto_subtitles("Re-aligning species"); 353 355 … … 637 639 // re-alignment successful 638 640 error = GB_write_string(gb_dest_data, buffer); 641 639 642 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); 643 651 } 644 652 } … … 651 659 652 660 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); 664 674 665 675 return error; … … 682 692 error = GB_end_transaction(GLOBAL_gb_main, error); 683 693 684 if ( neededLength >0) {694 if (!error && neededLength>0) { 685 695 if (retrying || !aw_ask_sure(GBS_global_string("Increase length of '%s' to %li?", ali_dest, neededLength))) { 686 696 error = GBS_global_string("Missing %li columns in alignment '%s'", neededLength, ali_dest); … … 695 705 "running re-aligner again!", 696 706 ali_dest, neededLength)); 697 retrying = true; 707 retrying = true; 708 neededLength = -1; 698 709 } 699 710 } -
trunk/SL/PRONUC/AP_codon_table.hxx
r7653 r8302 72 72 } 73 73 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; 80 81 } 81 82 } 82 return t rue;83 return table; 83 84 } 84 85 }; -
trunk/SL/TRANSLATE/Translate.cxx
r7013 r8302 26 26 GB_ERROR error = GBT_write_string(gb_species, "transl_table", GBS_global_string("%i", embl_transl_table)); 27 27 if (!error) error = GBT_write_string(gb_species, "codon_start", GBS_global_string("%i", codon_start+1)); 28 29 return error; 30 } 31 32 GB_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 } 28 42 29 43 return error; -
trunk/SL/TRANSLATE/Translate.hxx
r6381 r8302 20 20 GB_ERROR AWT_getTranslationInfo(GBDATA *gb_species, int& arb_transl_table, int &codon_start); 21 21 GB_ERROR AWT_saveTranslationInfo(GBDATA *gb_species, int arb_transl_table, int codon_start); 22 GB_ERROR AWT_removeTranslationInfo(GBDATA *gb_species); 22 23 23 24 int 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);
