source: tags/arb_5.5/AWT/awt_codon_table.hxx

Last change on this file was 8301, checked in by westram, 12 years ago
  • 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]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1// =========================================================== //
2//                                                             //
3//   File      : awt_codon_table.hxx                           //
4//   Purpose   :                                               //
5//                                                             //
6//   Coded by Ralf Westram (coder@reallysoft.de)               //
7//   Institute of Microbiology (Technical University Munich)   //
8//   http://www.arb-home.de/                                   //
9//                                                             //
10// =========================================================== //
11
12#ifndef AWT_CODON_TABLE_HXX
13#define AWT_CODON_TABLE_HXX
14
15#ifndef AWT_HXX
16#include <awt.hxx>
17#endif
18
19// --------------------------------------------------------------------------------
20
21struct AWT_Codon_Code_Definition {
22    const char *name;
23    const char *aa;             // amino-codes
24    const char *starts;
25    int         embl_feature_transl_table; // number of transl_table-entry in EMBL/GENEBANK features list
26};
27
28#define AWT_CODON_TABLES 17     // number of different Amino-Translation-Tables
29#define AWT_MAX_CODONS 64       // maximum of possible codon (= 4^3)
30
31extern struct AWT_Codon_Code_Definition AWT_codon_def[AWT_CODON_TABLES+1];
32
33const int AWAR_PROTEIN_TYPE_bacterial_code_index = 8; // contains the index of the bacterial code table
34
35// --------------------------------------------------------------------------------
36
37class AWT_allowedCode {
38    char allowed[AWT_CODON_TABLES];
39
40    void copy(const AWT_allowedCode& other) {
41        for (int a=0; a<AWT_CODON_TABLES; a++) {
42            allowed[a] = other.allowed[a];
43        }
44    }
45    void set(int val) {
46        for (int a=0; a<AWT_CODON_TABLES; a++) {
47            allowed[a] = val;
48        }
49    }
50    void legal(int nr) const {
51        if (nr<0 || nr>=AWT_CODON_TABLES) {
52            *((char*)0)=0; // throw exception
53        }
54    }
55public:
56    AWT_allowedCode() { set(1); }
57    AWT_allowedCode(const AWT_allowedCode& other) { copy(other); }
58    AWT_allowedCode& operator=(const AWT_allowedCode& other)  { copy(other); return *this; }
59
60    int is_allowed(int nr) const { legal(nr); return allowed[nr]!=0; }
61    void allow(int nr) { legal(nr); allowed[nr]=1; }
62    void forbid(int nr) { legal(nr); allowed[nr]=0; }
63
64    void forbidAll() { set(0); }
65    void allowAll() { set(1); }
66
67    void forbidAllBut(int nr) {
68        legal(nr);
69        for (int a=0; a<AWT_CODON_TABLES; a++) {
70            if (a != nr) allowed[a] = 0;
71        }
72    }
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    }
85};
86
87// --------------------------------------------------------------------------------
88
89void AWT_initialize_codon_tables();
90
91int AWT_embl_transl_table_2_arb_code_nr(int embl_code_nr);
92int AWT_arb_code_nr_2_embl_transl_table(int arb_code_nr);
93
94bool        AWT_is_codon(char protein, const char *dna, const AWT_allowedCode& allowed_code, AWT_allowedCode& allowed_code_left, const char **fail_reason = 0);
95const char *AWT_get_codons(char protein, int code_nr);
96
97char AWT_is_start_codon(const char *dna, int arb_code_nr);
98
99const char *AWT_get_protein_name(char protein);
100const char* AWT_get_codon_code_name(int code);
101
102#ifdef DEBUG
103void AWT_dump_codons();
104void test_AWT_get_codons();
105#endif
106
107// --------------------------------------------------------------------------------
108
109
110#else
111#error awt_codon_table.hxx included twice
112#endif // AWT_CODON_TABLE_HXX
Note: See TracBrowser for help on using the repository browser.