Changeset 2742


Ignore:
Timestamp:
Jun 8, 2012, 2:19:18 AM (9 years ago)
Author:
Peter
Message:

minor speedup in DNA::complement

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/dna.cc

    r2370 r2742  
    8888void complement(test::Suite& suite)
    8989{
     90  suite.add(DNA(' ').complement()==DNA(' '));
     91
    9092  suite.add(DNA('A').complement()==DNA('T'));
     93  suite.add(DNA('C').complement()==DNA('G'));
    9194  suite.add(DNA('G').complement()==DNA('C'));
     95  suite.add(DNA('T').complement()==DNA('A'));
     96
     97  suite.add(DNA('M').complement()==DNA('K'));
     98  suite.add(DNA('K').complement()==DNA('M'));
    9299  suite.add(DNA('R').complement()==DNA('Y'));
     100  suite.add(DNA('Y').complement()==DNA('R'));
     101  suite.add(DNA('S').complement()==DNA('S'));
     102  suite.add(DNA('W').complement()==DNA('W'));
     103
     104  suite.add(DNA('V').complement()==DNA('B'));
     105  suite.add(DNA('H').complement()==DNA('D'));
     106  suite.add(DNA('D').complement()==DNA('H'));
     107  suite.add(DNA('B').complement()==DNA('V'));
     108
     109  suite.add(DNA('N').complement()==DNA('N'));
    93110}
    94111
  • trunk/yat/omic/DNA.cc

    r2741 r2742  
    7878  DNA DNA::complement(void) const
    7979  {
    80     DNA result;
    81     assert(result.code_==0);
    82     // FIXME, should probably hard-code this or some magic seq of binary ops
    83     if ((*this & DNA('A')) != DNA(' '))
    84       result |= DNA('T');
    85     if ((*this & DNA('T')) != DNA(' '))
    86       result |= DNA('A');
    87     if ((*this & DNA('C')) != DNA(' '))
    88       result |= DNA('G');
    89     if ((*this & DNA('G')) != DNA(' '))
    90       result |= DNA('C');
    91     assert(result.code_<16);
    92     return result;
     80    //          code2char_ = " ACMGRSVTWYHKDBN";
     81    // complment to string char2code_
     82    std::string complement = " TGKCYSBAWRDMHVN";
     83    return DNA(complement[code_]);
    9384  }
    9485
Note: See TracChangeset for help on using the changeset viewer.