NCBI C++ ToolKit
sequtil_tables.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef UTIL_SEQUTIL___SEQUTIL_TABLES__HPP
2 #define UTIL_SEQUTIL___SEQUTIL_TABLES__HPP
3 
4 /* $Id: sequtil_tables.hpp 51894 2011-11-10 15:31:33Z ucko $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Mati Shomrat
30  *
31  * File Description:
32  * Conversion tables
33  */
34 #include <util/sequtil/sequtil.hpp>
35 
36 
38 
39 
40 /////////////////////////////////////////////////////////////////////////////
41 //
42 // Conversion Tables
43 
44 // IUPACna -> ....
45 //===========================================================================
46 
47 // IUPACna to IUPACna
48 // Size: 256 (1 column)
49 // each IUPACna is mapped to itself, lower case letters are mapped
50 // to upper case, U / u are mapped to T
51 
53 {
54 public:
55  static const Uint1* GetTable(void) { return scm_Table; }
56 
57 private:
59 
60  static const Uint1 scm_Table[256];
61 };
62 
63 // IUPACna to NCBI2na
64 // Size: 1024 (256 rows * 4 columns)
65 
67 {
68 public:
69  static const Uint1* GetTable(void) { return scm_Table; }
70 
71 private:
73 
74  static const Uint1 scm_Table[1024];
75 };
76 
77 
78 // IUPACna to NCBI2na_expand
79 // Size: 256
80 
82 {
83 public:
84  static const Uint1* GetTable(void) { return scm_Table; }
85 
86 private:
88 
89  static const Uint1 scm_Table[256];
90 };
91 
92 
93 // IUPACna to NCBI4na
94 // Size: 512 (256 rown * 2 columns)
95 
97 {
98 public:
99  static const Uint1* GetTable(void) { return scm_Table; }
100 
101 private:
103 
104  static void Init(void);
105 
106  static const Uint1 scm_Table[512];
107 };
108 
109 
110 // IUPACna to NCBI8na
111 // Size: 256
112 
114 {
115 public:
116  static const Uint1* GetTable(void) { return scm_Table; }
117 
118 private:
120 
121  static const Uint1 scm_Table[256];
122 };
123 
124 
125 // NCBI2na -> ....
126 //===========================================================================
127 
128 // NCBI2na to IUPACna
129 // Size: 1024 (256 rows * 4 columns)
130 
132 {
133 public:
134  static const Uint1* GetTable(void) { return scm_Table; }
135 
136 private:
138 
139  static const Uint1 scm_Table[1024];
140 };
141 
142 
143 // NCBI2na to NCBI2na_expand
144 // Size: 1024 (256 rows * 4 columns)
145 
147 {
148 public:
149  static const Uint1* GetTable(void) { return scm_Table; }
150 
151 private:
153 
154  static const Uint1 scm_Table[1024];
155 };
156 
157 
158 // NCBI2na to NCBI4na
159 // We use 2 tables for this conversion; a straight forward table in
160 // the case when the starting position of the conversion (within a
161 // ncbi2na byte) is 0 or 2. this table maps a single ncbi2na byte to
162 // 2 ncbi4na bytes.
163 // a second table is used when the offset is 1 or 3. this table consist
164 // of 3 columns. for a given ncbi2na byte the first column is the mapping of
165 // the lower 2 bits (1st base) in the ncbi2na byte, the second is the
166 // mapping of bases 2 and 3 and the 3rd column is the mapping of the 4th base.
167 
169 {
170 public:
171  static const Uint1* GetTable(bool boundry) {
172  return boundry ? scm_Table0 : scm_Table1;
173  }
174 
175 private:
176  C2naTo4na(void);
177 
178  static const Uint1 scm_Table0[512];
179  static const Uint1 scm_Table1[768];
180 };
181 
182 
183 // NCBI2na to NCBI8na (NCBI4na_expand)
184 // each ncbi2na byte is mapped to 4 ncbi8na bytes
185 
187 {
188 public:
189  static const Uint1* GetTable(void) { return scm_Table; }
190 
191 private:
192  C2naTo8na(void);
193 
194  static const Uint1 scm_Table[1024];
195 };
196 
197 
198 // NCBI2na_expand -> ....
199 //===========================================================================
200 
201 // NCBI2na_expand to IUPACna
202 // 0 -> A
203 // 1 -> C
204 // 2 -> G
205 // 3 -> T
206 
208 {
209 public:
210  static const Uint1* GetTable(void) { return scm_Table; }
211 
212 private:
214 
215  static const Uint1 scm_Table[256];
216 };
217 
218 
219 // NCBI4na -> ....
220 //===========================================================================
221 
222 
223 // NCBI4na to IUPACna
224 // each ncbi4na byte maps to 2 iupacna bytes
225 
227 {
228 public:
229  static const Uint1* GetTable(void) { return scm_Table; }
230 
231 private:
233 
234  static const Uint1 scm_Table[512];
235 };
236 
237 
238 // NCBI4na to NCBI2na
239 // depending on the initial offset 4 bases that are packed in
240 // a single ncbi2na byte might come from either 2 or 3 ncbi4na bytes.
241 // we use 2 different tables to accomodate to 2 cases.
242 // 0 -> 3 (gap -> T)
243 // 1 -> 0 (A -> A)
244 // 2 -> 1 (C -> C)
245 // 3 -> 1 (M -> C)
246 // 4 -> 2 (G -> G)
247 // 5 -> 2 (R -> G)
248 // 6 -> 1 (S -> C)
249 // 7 -> 0 (V -> A)
250 // 8 -> 3 (T -> T)
251 // 9 -> 3 (W -> T)
252 // 10 -> 3 (Y -> T)
253 // 11 -> 0 (H -> A)
254 // 12 -> 2 (K -> G)
255 // 13 -> 2 (D -> G)
256 // 14 -> 1 (B -> C)
257 // 15 -> 0 (N -> A)
258 
260 {
261 public:
262  static const Uint1* GetTable(size_t offset) {
263  return (offset == 0) ? scm_Table0 : scm_Table1;
264  }
265 
266 private:
267  C4naTo2na(void);
268 
269  static const Uint1 scm_Table0[512];
270  static const Uint1 scm_Table1[768];
271 };
272 
273 
274 // NCBI4na to NCBI2na_expand
275 // each ncbi4na byte maps to 2 iupacna bytes
276 
277 // gap -> 3 T
278 // A -> 0 A
279 // C -> 1 C
280 // M -> 1 C
281 // G -> 2 G
282 // R -> 2 G
283 // S -> 1 C
284 // V -> 0 A
285 // T -> 3 T
286 // W -> 3 T
287 // Y -> 3 T
288 // H -> 0 A
289 // K -> 2 G
290 // D -> 2 G
291 // B -> 1 C
292 // N -> 0 A
293 
295 {
296 public:
297  static const Uint1* GetTable(void) { return scm_Table; }
298 
299 private:
301 
302  static const Uint1 scm_Table[512];
303 };
304 
305 
306 // NCBI4na to NCBI8na (NCBI4na_expand)
307 // expand a single ncbi4na byte to 2 ncbi8na bytes
308 
310 {
311 public:
312  static const Uint1* GetTable(void) { return scm_Table; }
313 
314 private:
315  C4naTo8na(void);
316 
317  static const Uint1 scm_Table[512];
318 };
319 
320 
321 // NCBI8na -> ....
322 //===========================================================================
323 
324 // NCBI8na to IUPACna
325 // map ncbi8na byte to an iupacna one.
326 
328 {
329 public:
330  static const Uint1* GetTable(void) { return scm_Table; }
331 
332 private:
334 
335  static const Uint1 scm_Table[256];
336 };
337 
338 
339 // NCBI8na to NCBI2na
340 // map ncbi8na byte to the corresponding ncbi2na 2 bits based on the offset
341 // of the byte in the 4 bytes comprising the single ncbi2na byte.
342 
344 {
345 public:
346  static const Uint1* GetTable(void) { return scm_Table; }
347 
348 private:
349  C8naTo2na(void);
350 
351  static const Uint1 scm_Table[1024];
352 };
353 
354 
355 // IUPACaa to NCBIstdaa
356 
358 {
359 public:
360  static const Uint1* GetTable(void) { return scm_Table; }
361 
362 private:
364 
365  static const Uint1 scm_Table[256];
366 };
367 
368 
369 // NCBIeaa to IUPACaa
370 
372 {
373 public:
374  static const Uint1* GetTable(void) { return scm_Table; }
375 
376 private:
378 
379  static const Uint1 scm_Table[256];
380 };
381 
382 
383 // NCBIeaa to NCBIstdaa
384 
386 {
387 public:
388  static const Uint1* GetTable(void) { return scm_Table; }
389 
390 private:
391  CEaaToStdaa(void);
392 
393  static const Uint1 scm_Table[256];
394 };
395 
396 
397 // NCBIstdaa to IUPACaa
398 
400 {
401 public:
402  static const Uint1* GetTable(void) { return scm_Table; }
403 
404 private:
406 
407  static const Uint1 scm_Table[256];
408 };
409 
410 
411 // NCBIstdaa to NCBIeaa
412 
414 {
415 public:
416  static const Uint1* GetTable(void) { return scm_Table; }
417 
418 private:
419  CStdaaToEaa(void);
420 
421  static const Uint1 scm_Table[256];
422 };
423 
424 
425 /////////////////////////////////////////////////////////////////////////////
426 //
427 // Reverse Tables
428 
429 // NCBI2na
430 
432 {
433 public:
434  static const Uint1* GetTable(size_t offset) { return scm_Tables[offset]; }
435 
436 private:
437  C2naReverse(void);
438 
439  static const Uint1 scm_Table3[256]; // offset 3 - byte boundry
440  static const Uint1 scm_Table2[512]; // offset 2
441  static const Uint1 scm_Table1[512]; // offset 1
442  static const Uint1 scm_Table0[512]; // offset 0
443  static const Uint1* scm_Tables[4];
444 };
445 
446 
447 
448 // NCBI4na
449 
451 {
452 public:
453  static const Uint1* GetTable(void) { return scm_Table; }
454 
455 private:
456  C4naReverse(void);
457 
458  static const Uint1 scm_Table[256];
459 };
460 
461 
462 /////////////////////////////////////////////////////////////////////////////
463 //
464 // Complement Tables
465 
466 // IUPACna
467 
469 {
470 public:
471  static const Uint1* GetTable(void) { return scm_Table; }
472 
473 private:
474  CIupacnaCmp(void);
475 
476  static const Uint1 scm_Table[256];
477 };
478 
479 
480 // NCBI2na
481 
482 class C2naCmp
483 {
484 public:
485  static const Uint1* GetTable(size_t offset) { return scm_Tables[offset]; }
486 
487 private:
488  C2naCmp(void);
489 
490  static const Uint1 scm_Table1[512];
491  static const Uint1 scm_Table2[512];
492  static const Uint1 scm_Table3[512];
493  static const Uint1* scm_Tables[4];
494 };
495 
496 
497 // NCBI4na
498 
499 // 0 -> 0
500 // 1 -> 8
501 // 2 -> 4
502 // 3 -> 12
503 // 4 -> 2
504 // 5 -> 10
505 // 6 -> 9
506 // 7 -> 14
507 // 8 -> 1
508 // 9 -> 6
509 // 10 -> 5
510 // 11 -> 13
511 // 12 -> 3
512 // 13 -> 11
513 // 14 -> 7
514 // 15 -> 15
515 
516 class C4naCmp
517 {
518 public:
519  static const Uint1* GetTable(size_t offset) {
520  return (offset == 0) ? scm_Table0 : scm_Table1;
521  }
522 
523 private:
524  C4naCmp(void);
525 
526  static const Uint1 scm_Table0[256];
527  static const Uint1 scm_Table1[512];
528 };
529 
530 
531 // NCBI8na
532 
533 class C8naCmp
534 {
535 public:
536  static const Uint1* GetTable(void) { return scm_Table; }
537 
538 private:
539  C8naCmp(void);
540 
541  static const Uint1 scm_Table[256];
542 };
543 
544 
545 
546 /////////////////////////////////////////////////////////////////////////////
547 //
548 // ReverseComplement Tables
549 
550 // NCBI2na
552 {
553 public:
554  static const Uint1* GetTable(size_t offset) { return scm_Tables[offset]; }
555 
556 private:
557  C2naRevCmp(void);
558 
559  static const Uint1* scm_Tables[4];
560  static const Uint1 scm_Table0[512];
561  static const Uint1 scm_Table1[512];
562  static const Uint1 scm_Table2[512];
563  static const Uint1 scm_Table3[256];
564 };
565 
566 
568 {
569 public:
570  static const Uint1* GetTable(size_t offset) {
571  return (offset == 0) ? scm_Table0 : scm_Table1;
572  }
573 
574 private:
575  C4naRevCmp(void);
576 
577  static const Uint1* scm_Tables[4];
578  static const Uint1 scm_Table0[512];
579  static const Uint1 scm_Table1[256];
580 };
581 
582 /////////////////////////////////////////////////////////////////////////////
583 //
584 // Ambiguity Tables
585 
586 // IUPACna
587 
589 {
590 public:
591  static const bool* GetTable(void) { return scm_Table; }
592 
593 private:
595 
596  static const bool scm_Table[256];
597 };
598 
599 
600 // NCBI4na
601 
603 {
604 public:
605  static const bool* GetTable(void) { return scm_Table; }
606 
607 private:
609 
610  static const bool scm_Table[256];
611 };
612 
613 
614 // NCBI8na
615 
617 {
618 public:
619  static const bool* GetTable(void) { return scm_Table; }
620 
621 private:
623 
624  static const bool scm_Table[256];
625 };
626 
627 
628 /////////////////////////////////////////////////////////////////////////////
629 //
630 // Residue classification
631 
632 struct SBestCodings {
634 
640 };
641 
643 
645 
646 
647 #endif /* UTIL_SEQUTIL___SEQUTIL_TABLES__HPP */
C2naCmp(void)
static const Uint1 * GetTable(size_t offset)
static const Uint1 scm_Table1[512]
static const Uint1 scm_Table3[512]
static const Uint1 scm_Table2[512]
static const Uint1 * scm_Tables[4]
static const Uint1 scm_Table[256]
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(size_t offset)
static const Uint1 * scm_Tables[4]
static const Uint1 scm_Table1[512]
static const Uint1 scm_Table2[512]
C2naRevCmp(void)
static const Uint1 scm_Table0[512]
static const Uint1 scm_Table3[256]
C2naReverse(void)
static const Uint1 scm_Table0[512]
static const Uint1 scm_Table3[256]
static const Uint1 * scm_Tables[4]
static const Uint1 * GetTable(size_t offset)
static const Uint1 scm_Table1[512]
static const Uint1 scm_Table2[512]
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[1024]
static const Uint1 scm_Table1[768]
C2naTo4na(void)
static const Uint1 * GetTable(bool boundry)
static const Uint1 scm_Table0[512]
static const Uint1 scm_Table[1024]
static const Uint1 * GetTable(void)
C2naTo8na(void)
C2naToIupacna(void)
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[1024]
C4naCmp(void)
static const Uint1 scm_Table0[256]
static const Uint1 scm_Table1[512]
static const Uint1 * GetTable(size_t offset)
static const Uint1 * scm_Tables[4]
C4naRevCmp(void)
static const Uint1 scm_Table1[256]
static const Uint1 * GetTable(size_t offset)
static const Uint1 scm_Table0[512]
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[256]
C4naReverse(void)
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[512]
static const Uint1 scm_Table0[512]
C4naTo2na(void)
static const Uint1 * GetTable(size_t offset)
static const Uint1 scm_Table1[768]
static const Uint1 scm_Table[512]
static const Uint1 * GetTable(void)
C4naTo8na(void)
static const Uint1 scm_Table[512]
static const Uint1 * GetTable(void)
C4naToIupacna(void)
static const Uint1 * GetTable(void)
C8naCmp(void)
static const Uint1 scm_Table[256]
C8naTo2na(void)
static const Uint1 scm_Table[1024]
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[256]
C8naToIupacna(void)
CEaaToIupacaa(void)
static const Uint1 scm_Table[256]
static const Uint1 * GetTable(void)
CEaaToStdaa(void)
static const Uint1 scm_Table[256]
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[256]
static const Uint1 * GetTable(void)
static const bool scm_Table[256]
static const bool * GetTable(void)
CIupacnaAmbig(void)
static const Uint1 * GetTable(void)
CIupacnaCmp(void)
static const Uint1 scm_Table[256]
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[256]
static const Uint1 * GetTable(void)
CIupacnaTo2na(void)
static const Uint1 scm_Table[1024]
static void Init(void)
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[512]
CIupacnaTo4na(void)
CIupacnaTo8na(void)
static const Uint1 scm_Table[256]
static const Uint1 * GetTable(void)
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[256]
CNcbi4naAmbig(void)
static const bool * GetTable(void)
static const bool scm_Table[256]
CNcbi8naAmbig(void)
static const bool scm_Table[256]
static const bool * GetTable(void)
static const Uint1 scm_Table[256]
static const Uint1 * GetTable(void)
CStdaaToEaa(void)
static const Uint1 * GetTable(void)
static const Uint1 scm_Table[256]
int offset
Definition: replacements.h:160
uint8_t Uint1
1-byte (8-bit) unsigned integer
Definition: ncbitype.h:99
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const SBestCodings kBestCodingsWithoutGaps
const SBestCodings kBestCodingsWithGaps
TCoding ncbi8na[256]
TCoding ncbieaa[256]
TCoding ncbi4na[256]
CSeqUtil::ECoding TCoding
TCoding ncbi8aa[256]
TCoding iupacna[256]
Modified on Sat Apr 13 11:47:49 2024 by modify_doxy.py rev. 669887