Main Page   Class Hierarchy   Compound List   File List   Compound Members  

nucleic_acid_bit_char_traits.hpp

00001 namespace bioinfo
00002 {
00003 
00004   template<size_t NB>
00005   std::size_t
00006   nucleic_acid_min_traits<NB>::bit_code(basic_char_type c) {
00007     switch(c) {
00008     case 'a':
00009     case 'A':
00010       return 0x0;
00011     case 'c':
00012     case 'C':
00013       return 0x1;
00014     case 'g':
00015     case 'G':
00016       return 0x2;
00017     case 't':
00018     case 'T':
00019       return 0x3;
00020     default:
00021       return 0x0;
00022     }
00023   }
00024   template<size_t NB>
00025   typename nucleic_acid_min_traits<NB>::basic_char_type
00026   nucleic_acid_min_traits<NB>::char_code(typename nucleic_acid_min_traits<NB>::char_type ch) {
00027     typename nucleic_acid_min_traits<NB>::char_type high_order_mask = 0x3;
00028     ch = high_order_mask & ch; // automatically mask out higher order bits
00029     if( ch == 0x0 ) 
00030       return 'a';
00031     else if( ch == 0x1)
00032       return 'c';
00033     else if( ch == 0x2)
00034       return 'g';
00035     else if( ch == 0x3)
00036       return 't';
00037     else 
00038       return 'e';
00039   }
00040   template<size_t NB>
00041   bool
00042   nucleic_acid_min_traits<NB>::valid_code(basic_char_type c) {
00043     switch(c) {
00044     case 'a':
00045     case 'A':
00046     case 'c':
00047     case 'C':
00048     case 'g':
00049     case 'G':
00050     case 't':
00051     case 'T':
00052       return true;
00053     default:
00054       return false;
00055     }
00056   }
00057   
00058 
00059 }