File: basic-DNA-RNA-AA-routines.h

package info (click to toggle)
baitfisher 1.2.7%2Bgit20180107.e92dbf2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 28,216 kB
  • sloc: cpp: 30,737; makefile: 30; sh: 6
file content (662 lines) | stat: -rw-r--r-- 17,619 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
/*  BaitFisher (version 1.2.8) a program for designing DNA target enrichment baits
 *  BaitFilter (version 1.0.6) a program for selecting optimal bait regions
 *  Copyright 2013-2017 by Christoph Mayer
 *
 *  This source file is part of the BaitFisher-package.
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with BaitFisher.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 *  For any enquiries send an Email to Christoph Mayer
 *  c.mayer.zfmk@uni-bonn.de
 *
 *  When publishing work that is based on the results please cite:
 *  Mayer et al. 2016: BaitFisher: A software package for multi-species target DNA enrichment probe design
 *  
 */
#ifndef DNA_ROUTINES_H
#define DNA_ROUTINES_H

/* Todo:  count DNA bases, guess data type, is AA, etc.  */

// Changes 10/11.11.2016:
// * Removed a bug: (c == 'O' && c == 'U') should read (c == 'O' || c == 'U').
// The impact of this error is low. Basically, we overlook O or U as not allowed amino acids.
// Since they should not occur in normal amino acid sequences, it does not make much of a difference.
// * added the blosum symbols, lists and functions
// * added some upper lists and functions.
// * added a look-up table for the blosum symbols. This is much more efficient.
// * removed z from aa_symbols, aa_symbols_ext and _upper, since it as an ambiguity character.


#include <cstring>
#include <cctype>

static const char DNARNA_symbols[]         = "aAcCgGtTuU";
static const char DNARNA_symbols_upper[]   = "ACGTU";
static const char aa_symbols[]             = "aArRnNdDcCeEqQgGhHiIlLkKmMfFpPsStTwWyYvVxX";
static const char aa_symbols_upper[]       = "ARNDCEQGHILKMFPSTWYVX";

// Extended also includes: O and U:
static const char aa_symbols_ext[]         = "aArRnNdDcCeEqQgGhHiIlLkKmMfFpPsStTwWyYvVxXuUoO*";
static const char aa_symbols_ext_upper []  = "ARNDCEQGHILKMFPSTWYVXUO*";

static const char non_aa_in_ABC [] = "BJOUZbjouz";

// AA ambiguity characters: J is a very rare ambiguity character also included in this set.
// J is not allowed in many programs.
static const char aa_ambig [] = "bBzZjJxX";

// Usually a safe list of allowed characters are those in the blosum matrix:
// Lists the symbols that are allowed in the blosum matrix: Contains B,Z but not J as ambiguity character.
// See also the look up tables:  is_aa_blosum_code[] and is_aa_blosum_code_or_gap[]

static const char aa_symbols_blosum[]         = "aArRnNdDcCeEqQzZgGhHiIlLkKmMfFpPsStTwWyYvVbBxX*";
static const char aa_symbols_blosum_upper []  = "ARNDCEQZGHILKMFPSTWYVBX*";

static const char non_aa_symbols_blosum[]         = "jJoOuU";
static const char non_aa_symbols_blosum_upper []  = "JOU";

static const char DNARNA_iupac_symbols []          = "aAcCgGtTuURYSWryswKMBDkmbdHVNhvn";
static const char phylip_DNARNA_allowed_symbols [] = "?-nNaAcCgGtTuURYSWryswKMBDkmbdHVhvoOxX";

static const char phylip_neither_aa_dna_symbol [] = "jJzZ";
static const char allowed_non_ABC [] = "-?*";

// O and U are special amino acids that are usually not in the models.
// Chars that are not an aa symbol: B, J, O, U, Z
// X is the amibuity code

// Includes the symbols which occur in the blosum matrices: 
const int is_aa_blosum_code_lookup[] = {
  0,0,0,0,0,0,0,0,0,0, //  0- 9
  0,0,0,0,0,0,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,1,0,0,0,0,0,0,0, // 40-49  45: - is not included, 42: * included 
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,0,0,1,1,1,1,1, // 60-69  63: ? is not included
  1,1,1,1,0,1,1,1,1,0, // 70-79
  1,1,1,1,1,0,1,1,1,1, // 80-89
  1,0,0,0,0,0,0,1,1,1, // 90-99
  1,1,1,1,1,1,0,1,1,1, //100-109
  1,0,1,1,1,1,1,0,1,1, //110-119
  1,1,1,0,0,0,0,0 //120-127
};

// Includes the symbols which occur in the blosum matrices and the gap character:
const int is_aa_blosum_code_or_gap_lookup[] = {
  0,0,0,0,0,0,0,0,0,0, //  0- 9
  0,0,0,0,0,0,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,1,0,0,1,0,0,0,0, // 40-49  45: - is included, 42: * included 
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,0,0,1,1,1,1,1, // 60-69  63: ? is not included
  1,1,1,1,0,1,1,1,1,0, // 70-79
  1,1,1,1,1,0,1,1,1,1, // 80-89
  1,0,0,0,0,0,0,1,1,1, // 90-99
  1,1,1,1,1,1,0,1,1,1, //100-109
  1,0,1,1,1,1,1,0,1,1, //110-119
  1,1,1,0,0,0,0,0 //120-127
};

// Inlcudes all DNA symbols, no ambiguity characters
const char is_DNA_lookup[128] = {
  0,0,0,0,0,0,0,0,0,0, //  0- 9
  0,0,0,0,0,0,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,0,0,0,0,0,0,0,0, // 40-49
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,0,0,1,0,1,0,0, // 60-69     63:'?', 65:'A' to  69:'E'
  0,1,0,0,0,0,0,0,0,0, // 70-79
  0,0,0,0,1,0,0,0,0,0, // 80-89
  0,0,0,0,0,0,0,1,0,1, // 90-99
  0,0,0,1,0,0,0,0,0,0, //100-109
  0,0,0,0,0,0,1,0,0,0, //110-119
  0,0,0,0,0,0,0,0      //120-127
};

// Inlcudes all DNA symbols and gap '-', no ambiguity characters
const char is_DNA_or_GAP_lookup[128] = {
  0,0,0,0,0,0,0,0,0,0, //  0- 9
  0,0,0,0,0,0,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,0,0,0,1,0,0,0,0, // 40-49
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,0,0,1,0,1,0,0, // 60-69     63:'?', 65:'A' to  69:'E'
  0,1,0,0,0,0,0,0,0,0, // 70-79
  0,0,0,0,1,0,0,0,0,0, // 80-89
  0,0,0,0,0,0,0,1,0,1, // 90-99
  0,0,0,1,0,0,0,0,0,0, //100-109
  0,0,0,0,0,0,1,0,0,0, //110-119
  0,0,0,0,0,0,0,0      //120-127
};

// Inlcudes all ambiguity characters as well as ?
const char is_DNA_or_AMBIG_lookup[128] = {
  0,0,0,0,0,0,0,0,0,0, //  0- 9
  0,0,0,0,0,0,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,0,0,0,0,0,0,0,0, // 40-49
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,1,0,1,1,1,1,0, // 60-69     63:'?', 65:'A' to  69:'E'
  0,1,1,0,0,1,0,1,1,0, // 70-79
  0,0,1,1,1,0,1,1,0,1, // 80-89
  0,0,0,0,0,0,0,1,1,1, // 90-99
  1,0,0,1,1,0,0,0,0,0, //100-109
  0,0,0,0,1,0,1,0,1,1, //110-119
  0,1,0,0,0,0,0,0      //120-127
};

// Inlcudes all ambiguity characters as well as ? and -
const char is_DNA_or_AMBIG_or_GAP_lookup[128] = {
  0,0,0,0,0,0,0,0,0,0, //  0- 9
  0,0,0,0,0,0,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,0,0,0,1,0,0,0,0, // 40-49     45: - is included
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,1,0,1,1,1,1,0, // 60-69     63:'?', 65:'A' to  69:'E'
  0,1,1,0,0,1,0,1,1,0, // 70-79
  0,0,1,1,1,0,1,1,0,1, // 80-89
  0,0,0,0,0,0,0,1,1,1, // 90-99
  1,0,0,1,1,0,0,0,0,0, //100-109
  0,0,0,0,1,0,1,0,1,1, //110-119
  0,1,0,0,0,0,0,0      //120-127
};


/* inline bool is_DNA_base_upper(char c) */
/* {  */
/*   if (c == 'A' || c == 'C' || c == 'G' || c == 'T' ) */
/*     return true; */
/*   return false; */
/* } */

/* inline bool is_DNA_base_lower(char c) */
/* {  */
/*   if (c == 'a' || c == 'c' || c == 'g' || c == 't' ) */
/*     return true; */
/*   return false; */
/* } */

// Only defined if c <= 127
inline bool is_DNA_base(char c)
{
  return is_DNA_lookup[(int)c];
}

inline bool is_DNA_base_or_GAP(char c)
{
  return is_DNA_or_GAP_lookup[(int)c];
}

inline bool is_DNA_or_DNA_ambig(char c)
{
  return is_DNA_or_AMBIG_lookup[(int)c];
}

inline bool is_DNA_or_DNA_ambig_or_GAP(char c)
{
  return is_DNA_or_AMBIG_or_GAP_lookup[(int)c];
}

inline bool is_DNA_or_RNA_base(char c)
{
  if (c == 'A' || c == 'C' || c == 'G' || c == 'T' ||
      c == 'a' || c == 'c' || c == 'g' || c == 't' || c == 'U' || c == 'u')
    return true;
  return false;
}

inline bool is_allowed_non_ABC(char c)
{
  if (c == '-' || c == '?' || c == '*')
    return true;
  else
    return false;
}

inline bool is_phylip_aa_dna_symbol(char c) // Does not include -? or similar
{
  // Only one character is not allowed:
  if (c=='o' || c == 'O')
    return false;
  if (c >='a' && c <= 'z')
  {
      return true;
  }
  else if (c >='A' && c <= 'Z')
  {
      return true;
  }
  return false;
}

inline bool is_gap(char c)
{
  return c == '-';
}


// Only defined if c <= 127
// Includes only DNA ambig symbols. Does not include DNA symbols. See also is_DNA_or_AMBIG below.
inline bool is_DNA_ambig(char c)
{
  return is_DNA_or_AMBIG_lookup[(int)c] && !is_DNA_lookup[(int)c];
/*   if (c == 'N'  ||  c == '?'  || c == 'n' || */
/*       c == 'R'  ||  c == 'Y'  || c == 'S' || c == 'W' || */
/*       c == 'r'  ||  c == 'y'  || c == 's' || c == 'w' || */
/*       c == 'K'  ||  c == 'M'  || c == 'B' || c == 'D' || */
/*       c == 'k'  ||  c == 'm'  || c == 'b' || c == 'd' || */
/*       c == 'H'  ||  c == 'V'  || */
/*       c == 'h'  ||  c == 'v') */
/*     return true; */
/*   else */
/*     return false; */
}

/* inline bool is_DNA_iupac_ambig_upper(char c) */
/* { */
/*   if (c == 'N'  ||  c == '?'  || */
/*       c == 'R'  ||  c == 'Y'  || c == 'S' || c == 'W' || */
/*       c == 'K'  ||  c == 'M'  || c == 'B' || c == 'D' || */
/*       c == 'H'  ||  c == 'V') */
/*     return true; */
/*   else */
/*     return false; */
/* } */










// A list can be found here: https://en.wikipedia.org/wiki/Amino_acid
// The acceptance of J as an ambiguous amino acid symbol is low.
// J does not occur in the blosm matrix and is not allowed in some programs.
inline bool is_aa_ambig(char c)
{
  if (c == 'b' || c == 'B' || c == '?' || c == 'x' || c == 'X' || 
      c == 'j' || c == 'J' || c == 'z' || c == 'Z')
    return true;
  else
    return false;
}

inline bool is_aa_blosum_code(unsigned char c)
{
  return (is_aa_blosum_code_lookup[c] != 0);
}

inline bool is_aa_blosum_code_or_gap(unsigned char c)
{
  return (is_aa_blosum_code_or_gap_lookup[c] != 0);
}



inline int is_aa_upper(char c)
{
  if (c >='A' && c <= 'Z')
  {
    // AA ambigs:
    if (c == 'B' || c == 'X' || c == 'J' || c == 'Z')
      return false;

    // The few symbols that represent nothing.
    // Indeed they are listed as the 21st and 22nd amino acid in https://en.wikipedia.org/wiki/Amino_acid
    // But they are usually not handled by programs, so we return false.
    if (c == 'O' || c == 'U') // OU
      return false;
    return true;
  }
  return false;
}


inline int is_aa_or_aa_ambig(char c) // includes '?' and  B, Z, J, X
{
  if (c >='a' && c <= 'z')
  {
    if (c != 'o' && c != 'u') // Only not allowed characters in a..z are: ou
      return true;
  }
  else if (c >='A' && c <= 'Z')
  {
    if (c != 'O' && c != 'U') // Only not allowed characters in a..z are: OU
      return true;
  }

  if (c == '?' || c == '*')
    return true;

  return false;
  //  return (strchr(aa_symbols, c) != NULL);
}

inline int is_aa_or_aa_ambig_extended(char c) // O and U are allowed  // includes '?' and  B, Z, J, X
{
  if (c >='a' && c <= 'z')
  {
      return true;
  }
  else if (c >='A' && c <= 'Z')
  {
      return true;
  }

  if (c == '?' || c == '*')
    return true;

  return false;
  //  return (strchr(aa_symbols, c) != NULL);
}


inline char complementBase_of_upper(char c)
{
  switch (c) {
  case 'A':  c = 'T'; break;
  case 'T':  c = 'A'; break;
  case 'G':  c = 'C'; break;
  case 'C':  c = 'G'; break;
    
  case 'R':  c = 'Y'; break;
  case 'Y':  c = 'R'; break;

  case 'M':  c = 'K'; break;
  case 'K':  c = 'M'; break;

  case 'B':  c = 'V'; break;
  case 'V':  c = 'B'; break;

  case 'D':  c = 'H'; break;
  case 'H':  c = 'D'; break;

  case 'N':  c = 'N'; break;
  case '?':  c = '?'; break;
  case '-':  c = '-'; break;

  default:
    c = '*';
    break;
  }
  return c;
}

inline char complementBase_of_lower(char c)
{
  switch (c) {
  case 'a':  c = 't'; break;
  case 't':  c = 'a'; break;
  case 'g':  c = 'c'; break;
  case 'c':  c = 'g'; break;
    
  case 'r':  c = 'y'; break;
  case 'y':  c = 'r'; break;

  case 'm':  c = 'k'; break;
  case 'k':  c = 'm'; break;

  case 'b':  c = 'v'; break;
  case 'v':  c = 'b'; break;

  case 'd':  c = 'h'; break;
  case 'h':  c = 'd'; break;

  case 'n':  c = 'n'; break;
  case '?':  c = '?'; break;
  case '-':  c = '-'; break;

  default:
    c = '*';
    break;
  }
  return c;
}

inline char complementBase(char c)
{
  if ( isupper(c) )
    return complementBase_of_upper(c);
  else
    return complementBase_of_lower(c);
}


inline void CG_AT_content_in_region(const char *beg, const char *end, unsigned &AT, unsigned &CG)
{
  AT = 0;
  CG = 0;

  char c;

  while (beg != end)
  {
    c = *beg;
    if (c == 'C' || c == 'c' || c == 'G' || c == 'g')
      ++CG;
    else if (c == 'A' || c == 'a' || c == 'T' || c == 't')
      ++AT;

    ++beg;
  }
}

inline void content_in_region_DNA(const char *beg, const char *end, unsigned &AT, unsigned &CG, unsigned &gap, unsigned &ambig, unsigned &unknown)
{
  AT      = 0;
  CG      = 0;
  gap     = 0;
  ambig   = 0;
  unknown = 0;

  char c;

  while (beg != end)
  {
    c = *beg;
    if (c == 'C' || c == 'c' || c == 'G' || c == 'g')
      ++CG;
    else if (c == 'A' || c == 'a' || c == 'T' || c == 't')
      ++AT;
    else if (c == '-')
      ++gap;
    else if (is_DNA_ambig(c) )
      ++ambig;
    else
      ++unknown;

    ++beg;
  }
}

inline bool is_aa_blosum_code_or_gap_sequence(const char *p1, const char *p2, unsigned *offending_pos)
{
  const char *startp = p1;

  while (p1 != p2)
  {
    if (!is_aa_blosum_code_or_gap(*p1) )
    {
      *offending_pos = p1 - startp;
      return false;
    }
    ++p1;
  }
  return true;
}



// Recoding symbols:
// A char can hold 8 bits, enough for 8 characters to be "in or out",
// to be switched on or off. Thus a char can be used to hold
// all bases including ambiguities as follows:
// Say A, C, G, T are the bits 1,2,3,4,
// the ambiguity {A,C} is 1+2 = 3

// A:       65, 97  -> 1
// C:       67, 99  -> 2
// G:       71,103  -> 4
// T:       84,116  -> 8
// R(AG):   82,114  -> 5
// Y(CT):   89,121  -> 10
// S(CG):   83,115  -> 6
// W(TA):   87,119  -> 9
// K(TG):   75,107  -> 12
// M(CA):   77,109  -> 3
// B(CTG):  66,98   -> 14
// D(ATG):  68,100  -> 13
// H(ATC):  72,104  -> 11
// V(ACG):  86,118  -> 7
// N(ACGT): 78,110  -> 15
// -        45      -> 0
// ?        63      -> 15

const char ascii2recode_DNA[128] = {
  0,0,0,0,0,0,0,0,0,0, //  0- 9
  0,0,0,0,0,0,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,0,0,0,0,0,0,0,0, // 40-49
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,15,0,1,14,2,13,0, // 60-69
  0,4,11,0,0,12,0,3,15,0, // 70-79
  0,0,5,6,8,0,7,9,0,10, // 80-89
  0,0,0,0,0,0,0,1,14,2, // 90-99
  13,0,0,4,11,0,0,0,0,0, //100-109
  0,0,0,0,5,0,8,0,7,9, //110-119
  0,10,0,0,0,0,0,0 //120-127
};

const char recode2ascii_DNA[128] = {
  45,65,67,77,71,82,83,86,84,87, //  0- 9
  89,72,75,68,66,78,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,0,0,0,0,0,0,0,0, // 40-49
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,0,0,0,0,0,0,0, // 60-69
  0,0,0,0,0,0,0,0,0,0, // 70-79
  0,0,0,0,0,0,0,0,0,0, // 80-89
  0,0,0,0,0,0,0,0,0,0, // 90-99
  0,0,0,0,0,0,0,0,0,0, //100-109
  0,0,0,0,0,0,0,0,0,0, //110-119
  0,0,0,0,0,0,0,0 //120-127
};

const char recodeISDNAamig[128] = {
  0,0,0,1,0,1,1,1,0,1, //  0- 9
  1,1,1,1,1,1,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,0,0,0,0,0,0,0,0, // 40-49
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,0,0,0,0,0,0,0, // 60-69
  0,0,0,0,0,0,0,0,0,0, // 70-79
  0,0,0,0,0,0,0,0,0,0, // 80-89
  0,0,0,0,0,0,0,0,0,0, // 90-99
  0,0,0,0,0,0,0,0,0,0, //100-109
  0,0,0,0,0,0,0,0,0,0, //110-119
  0,0,0,0,0,0,0,0 //120-127
};

inline unsigned char recode_DNA(unsigned char c)
{
  return ascii2recode_DNA[c];
}

inline unsigned char backrecode_DNA(unsigned char c)
{
  return recode2ascii_DNA[c];
}

inline unsigned char recode_is_DNA_ambig(unsigned char c)
{
  return recodeISDNAamig[c];
}

inline bool is_base_in_recode(unsigned char recode, unsigned char base)
{
  return recode & recode_DNA(base);
}

inline bool is_valid_recode_DNA(unsigned char c)
{
  if (c > 15)
    return false;
  else
    return true;
}

inline bool is_recode_gap(unsigned char c)
{
  return (c == 0);
}



// A	Ala	Alanine         01   65
// R	Arg	Arginine        02   82
// N	Asn	Asparagine      03   78
// D	Asp	Aspartic acid   08   68
// C	Cys	Cysteine        16   67
// Q	Gln	Glutamine       32   81
// E	Glu	Glutamic acid   64   69
// G	Gly	Glycine        128   71
// H	His	Histidine      256   72
// I	Ile	Isoleucine     512   73
// L	Leu	Leucine       1024   76
// K	Lys	Lysine        2048   75 
// M	Met	Methionine    4096   77
// F	Phe	Phenylalanine 8192   70
// P	Pro	Proline      16384   80
// S	Ser	Serine       32768   83
// T	Thr	Threonine    65536   84
// W	Trp	Tryptophan  131072   87
// Y	Tyr	Tyrosine    262144   89
// V	Val	Valine      524288   86
// -        45      -> 0
// ?        63      -> 1048575
// X        88      -> 1048575

const int ascii2recode_aa[128] = {
  0,0,0,0,0,0,0,0,0,0, //  0- 9
  0,0,0,0,0,0,0,0,0,0, // 10-19
  0,0,0,0,0,0,0,0,0,0, // 20-29
  0,0,0,0,0,0,0,0,0,0, // 30-39
  0,0,0,0,0,64,0,0,0,0, // 40-49
  0,0,0,0,0,0,0,0,0,0, // 50-59
  0,0,0,15,0,1,14,2,13,0, // 60-69
  0,4,11,0,0,12,0,3,15,0, // 70-79
  0,0,5,6,8,0,7,9,0,10, // 80-89
  0,0,0,0,0,0,0,1,14,2, // 90-99
  13,0,0,4,11,0,0,0,0,0, //100-109
  0,0,0,0,5,0,8,0,7,9, //110-119
  0,10,0,0,0,0,0,0 //120-127
};


#endif