1 //uchime by Robert C. Edgar http://drive5.com/uchime This code is donated to the public domain.
\r
9 return c == '-' || c == '.';
\r
12 const char *WordToStrAmino(unsigned Word, unsigned WordLength)
\r
14 static char Str[32];
\r
15 for (unsigned i = 0; i < WordLength; ++i)
\r
17 unsigned Letter = Word%20;
\r
18 Str[WordLength-i-1] = g_LetterToCharAmino[Letter];
\r
21 Str[WordLength] = 0;
\r
25 const char *WordToStrAmino2(unsigned Word, unsigned WordLength, char *Str)
\r
27 for (unsigned i = 0; i < WordLength; ++i)
\r
29 unsigned Letter = Word%20;
\r
30 Str[WordLength-i-1] = g_LetterToCharAmino[Letter];
\r
33 Str[WordLength] = 0;
\r
37 const char *WordToStrNucleo(unsigned Word, unsigned WordLength)
\r
39 static char Str[32];
\r
40 for (unsigned i = 0; i < WordLength; ++i)
\r
42 unsigned Letter = Word%4;
\r
43 Str[WordLength-i-1] = g_LetterToCharNucleo[Letter];
\r
46 Str[WordLength] = 0;
\r
50 const char *WordToStr(unsigned Word, unsigned WordLength, bool Nucleo)
\r
52 return (Nucleo ? WordToStrNucleo : WordToStrAmino)(Word, WordLength);
\r
55 byte *RevCompAlloc(const byte *Seq, unsigned L)
\r
57 byte *RCSeq = MYALLOC(byte, L, Alpha);
\r
59 for (unsigned i = 0; i < L; ++i)
\r
60 RCSeq[L-i-1] = g_CharToCompChar[Seq[i]];
\r
65 void RevCompInPlace(byte *Seq, unsigned L)
\r
67 unsigned L1 = L - 1;
\r
69 for (unsigned i = 0; i < L2; ++i)
\r
71 unsigned j = L1 - i;
\r
72 unsigned ci = Seq[i];
\r
73 unsigned cj = Seq[j];
\r
75 unsigned ri = g_CharToCompChar[ci];
\r
76 unsigned rj = g_CharToCompChar[cj];
\r
83 Seq[L2] = g_CharToCompChar[Seq[L2]];
\r
86 void RevComp(const byte *Seq, unsigned L, byte *RCSeq)
\r
88 for (unsigned i = 0; i < L; ++i)
\r
89 RCSeq[L-i-1] = g_CharToCompChar[Seq[i]];
\r
92 unsigned char GetAminoCharFrom3NucChars(unsigned char c1, unsigned char c2,
\r
95 unsigned Letter1 = g_CharToLetterNucleo[c1];
\r
96 unsigned Letter2 = g_CharToLetterNucleo[c2];
\r
97 unsigned Letter3 = g_CharToLetterNucleo[c3];
\r
98 unsigned Word = Letter1*(4*4) + Letter2*4 + Letter3;
\r
100 unsigned Letter = g_CodonWordToAminoLetter[Word];
\r
101 return g_LetterToCharAmino[Letter];
\r