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

Last change on this file was 5968, checked in by westram, 15 years ago
  • new flag -w to aisc_mkpt (add include wrapper)
  • uniform style for several include wrappers
  • removed duplicated includes
  • removed useless nt_concatenate.hxx
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 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
75// --------------------------------------------------------------------------------
76
77void AWT_initialize_codon_tables();
78
79int AWT_embl_transl_table_2_arb_code_nr(int embl_code_nr);
80int AWT_arb_code_nr_2_embl_transl_table(int arb_code_nr);
81
82bool        AWT_is_codon(char protein, const char *dna, const AWT_allowedCode& allowed_code, AWT_allowedCode& allowed_code_left, const char **fail_reason = 0);
83const char *AWT_get_codons(char protein, int code_nr);
84
85char AWT_is_start_codon(const char *dna, int arb_code_nr);
86
87const char *AWT_get_protein_name(char protein);
88const char* AWT_get_codon_code_name(int code);
89
90#ifdef DEBUG
91void AWT_dump_codons();
92void test_AWT_get_codons();
93#endif
94
95// --------------------------------------------------------------------------------
96
97
98#else
99#error awt_codon_table.hxx included twice
100#endif // AWT_CODON_TABLE_HXX
Note: See TracBrowser for help on using the repository browser.