1 //uchime by Robert C. Edgar http://drive5.com/uchime This code is donated to the public domain.
\r
6 Mx<float> g_SubstMxf;
\r
9 static const char Alphabet[] = "ACGTU";
\r
11 void SetNucSubstMx(double Match, double Mismatch)
\r
13 static bool Done = false;
\r
19 Die("Match score should be +ve");
\r
20 if (Mismatch >= 0.0)
\r
21 Die("Mismatch score should be -ve");
\r
23 unsigned N = unsigned(strlen(Alphabet));
\r
25 g_SubstMxf.Alloc("NUCMX", 256, 256);
\r
26 strcpy(g_SubstMxf.m_Alpha, "ACGT");
\r
28 g_SubstMx = g_SubstMxf.GetData();
\r
29 for (unsigned i = 0; i < N; ++i)
\r
31 for (unsigned j = 0; j < N; ++j)
\r
33 float v = float(i == j ? Match : Mismatch);
\r
35 byte ui = (byte) toupper(Alphabet[i]);
\r
36 byte uj = (byte) toupper(Alphabet[j]);
\r
37 byte li = (byte) tolower(ui);
\r
38 byte lj = (byte) tolower(uj);
\r
39 ui = (byte) toupper(ui);
\r
40 uj = (byte) toupper(uj);
\r
42 g_SubstMx[ui][uj] = v;
\r
43 g_SubstMx[uj][ui] = v;
\r
45 g_SubstMx[ui][lj] = v;
\r
46 g_SubstMx[uj][li] = v;
\r
48 g_SubstMx[li][uj] = v;
\r
49 g_SubstMx[lj][ui] = v;
\r
51 g_SubstMx[li][lj] = v;
\r
52 g_SubstMx[lj][li] = v;
\r
56 for (unsigned j = 0; j < N; ++j)
\r
60 byte ui = (byte) 'N';
\r
61 byte uj = (byte) toupper(Alphabet[j]);
\r
62 byte li = (byte) 'n';
\r
63 byte lj = (byte) tolower(uj);
\r
64 ui = (byte) toupper(ui);
\r
65 uj = (byte) toupper(uj);
\r
67 g_SubstMx[ui][uj] = v;
\r
68 g_SubstMx[uj][ui] = v;
\r
70 g_SubstMx[ui][lj] = v;
\r
71 g_SubstMx[uj][li] = v;
\r
73 g_SubstMx[li][uj] = v;
\r
74 g_SubstMx[lj][ui] = v;
\r
76 g_SubstMx[li][lj] = v;
\r
77 g_SubstMx[lj][li] = v;
\r