Convert the specified ambiguity code to a bitmask. */
| 139 | |
| 140 | /** Convert the specified ambiguity code to a bitmask. */ |
| 141 | unsigned ambiguityToBitmask(char c) |
| 142 | { |
| 143 | if (isdigit(c)) // colour space |
| 144 | return 1 << baseToCode(c); |
| 145 | |
| 146 | static const unsigned ambiguityToBitmaskTable[26] = { |
| 147 | 0x1, // 'A' ---A |
| 148 | 0xe, // 'B' TGC- |
| 149 | 0x2, // 'C' --C- |
| 150 | 0xd, // 'D' TG-A |
| 151 | 0x0, // 'E' |
| 152 | 0x0, // 'F' |
| 153 | 0x4, // 'G' -G-- |
| 154 | 0xb, // 'H' T-CA |
| 155 | 0x0, // 'I' |
| 156 | 0x0, // 'J' |
| 157 | 0xc, // 'K' TG-- |
| 158 | 0x0, // 'L' |
| 159 | 0x3, // 'M' --CA |
| 160 | 0xf, // 'N' ACGT |
| 161 | 0x0, // 'O' |
| 162 | 0x0, // 'P' |
| 163 | 0x0, // 'Q' |
| 164 | 0x5, // 'R' -G-A |
| 165 | 0x6, // 'S' -GC- |
| 166 | 0x8, // 'T' T--- |
| 167 | 0x0, // 'U' |
| 168 | 0x7, // 'V' -GCA |
| 169 | 0x9, // 'W' T--A |
| 170 | 0x0, // 'X' |
| 171 | 0xa, // 'Y' T-C- |
| 172 | 0x0, // 'Z' |
| 173 | }; |
| 174 | unsigned i = toupper(c) - 'A'; |
| 175 | assert(i < 26); |
| 176 | unsigned x = ambiguityToBitmaskTable[i]; |
| 177 | assert(x > 0); |
| 178 | return x; |
| 179 | } |
| 180 | |
| 181 | /** Convert the specified bitmask to an ambiguity code. */ |
| 182 | unsigned bitmaskToAmbiguity(unsigned x) |
no test coverage detected