source: branches/profile/PRIMER_DESIGN/PRD_Globals.hxx

Last change on this file was 11002, checked in by westram, 10 years ago
  • 'class { public' → struct
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1#ifndef PRD_GLOBALS_HXX
2#define PRD_GLOBALS_HXX
3
4#ifndef _GLIBCXX_CLIMITS
5#include <climits>
6#endif
7#ifndef ARB_ASSERT_H
8#include <arb_assert.h>
9#endif
10#ifndef ARBTOOLS_H
11#include <arbtools.h>
12#endif
13
14#define prd_assert(cond) arb_assert(cond)
15
16#ifndef MAX_LONG
17#define MAX_LONG LONG_MAX
18#endif
19
20#define PRD_MAX_SEQUENCE_POS MAX_LONG
21typedef long int PRD_Sequence_Pos;
22
23
24//
25// BaseInverter is used to invert bases while matching sequence
26// backwards vs. the primertrees
27//
28struct BaseInverter {
29    char BASE[128];
30
31    BaseInverter()
32    {
33        for (int i=0; i < 128; i++)
34            BASE[i] = '\x00';
35
36        BASE[(unsigned char)'A'] = 'T';
37        BASE[(unsigned char)'T'] = 'A';
38        BASE[(unsigned char)'U'] = 'A';
39        BASE[(unsigned char)'C'] = 'G';
40        BASE[(unsigned char)'G'] = 'C';
41
42        BASE[(unsigned char)'R'] = 'Y';
43        BASE[(unsigned char)'M'] = 'K';
44        BASE[(unsigned char)'S'] = 'S';
45        BASE[(unsigned char)'Y'] = 'R';
46        BASE[(unsigned char)'K'] = 'M';
47        BASE[(unsigned char)'W'] = 'W';
48        BASE[(unsigned char)'V'] = 'B';
49        BASE[(unsigned char)'B'] = 'V';
50        BASE[(unsigned char)'D'] = 'H';
51        BASE[(unsigned char)'H'] = 'D';
52        BASE[(unsigned char)'N'] = 'N';
53    }
54};
55
56static BaseInverter INVERT;
57
58
59struct ChildLookupTable {
60    int INDEX[128];
61
62    ChildLookupTable ()
63    {
64        for (int i=0; i < 128; i++) INDEX[i] = -1;
65
66        INDEX[(unsigned char)'C'] = 0;
67        INDEX[(unsigned char)'G'] = 1;
68        INDEX[(unsigned char)'A'] = 2;
69        INDEX[(unsigned char)'T'] = 3;
70        INDEX[(unsigned char)'U'] = 3;
71    }
72};
73
74static ChildLookupTable CHAR2CHILD;
75
76
77class BitField {
78    // Meaning of single bits:
79    //  2^0 = 1 = A
80    //  2^1 = 2 = T/U
81    //  2^2 = 4 = C
82    //  2^3 = 8 = G
83public:
84    unsigned int FIELD[128]; // bitoperations are done as unsigned int :(
85
86    BitField()
87    {
88        for (int i=0; i < 128; i++)
89            FIELD[i] = 0;
90
91        FIELD[(unsigned char)'A'] =  1;
92        FIELD[(unsigned char)'T'] =  2;
93        FIELD[(unsigned char)'U'] =  2;
94        FIELD[(unsigned char)'C'] =  4;
95        FIELD[(unsigned char)'G'] =  8;
96
97        FIELD[(unsigned char)'R'] =  9; // A  G
98        FIELD[(unsigned char)'M'] =  5; // A C
99        FIELD[(unsigned char)'S'] = 12; //   CG
100        FIELD[(unsigned char)'Y'] =  6; //  TC
101        FIELD[(unsigned char)'K'] = 10; //  T G
102        FIELD[(unsigned char)'W'] =  3; // AT
103        FIELD[(unsigned char)'V'] = 13; // A CG
104        FIELD[(unsigned char)'B'] = 14; //  TCG
105        FIELD[(unsigned char)'D'] = 11; // AT G
106        FIELD[(unsigned char)'H'] =  7; // ATC
107        FIELD[(unsigned char)'N'] = 15; // ATCG
108    }
109};
110
111static BitField CHAR2BIT;
112
113#else
114#error PRD_Globals.hxx included twice
115#endif // PRD_GLOBALS_HXX
Note: See TracBrowser for help on using the repository browser.