--- /dev/null
+#include "myutils.h"
+#include "mx.h"
+
+Mx<float> g_SubstMxf;
+float **g_SubstMx;
+
+static const char Alphabet[] = "ACGTU";
+
+void SetNucSubstMx(double Match, double Mismatch)\r
+ {\r
+ static bool Done = false;\r
+ if (Done)\r
+ return;\r
+ Done = true;\r
+\r
+ if (Match <= 0.0)\r
+ Die("Match score should be +ve");\r
+ if (Mismatch >= 0.0)\r
+ Die("Mismatch score should be -ve");\r
+\r
+ unsigned N = unsigned(strlen(Alphabet));\r
+\r
+ g_SubstMxf.Alloc("NUCMX", 256, 256);\r
+ strcpy(g_SubstMxf.m_Alpha, "ACGT");\r
+ g_SubstMxf.Init(0);\r
+ g_SubstMx = g_SubstMxf.GetData();\r
+ for (unsigned i = 0; i < N; ++i)\r
+ {\r
+ for (unsigned j = 0; j < N; ++j)\r
+ {\r
+ float v = float(i == j ? Match : Mismatch);\r
+\r
+ byte ui = (byte) toupper(Alphabet[i]);\r
+ byte uj = (byte) toupper(Alphabet[j]);\r
+ byte li = (byte) tolower(ui);\r
+ byte lj = (byte) tolower(uj);\r
+ ui = (byte) toupper(ui);\r
+ uj = (byte) toupper(uj);\r
+\r
+ g_SubstMx[ui][uj] = v;\r
+ g_SubstMx[uj][ui] = v;\r
+\r
+ g_SubstMx[ui][lj] = v;\r
+ g_SubstMx[uj][li] = v;\r
+\r
+ g_SubstMx[li][uj] = v;\r
+ g_SubstMx[lj][ui] = v;\r
+\r
+ g_SubstMx[li][lj] = v;\r
+ g_SubstMx[lj][li] = v;\r
+ }\r
+ }\r
+\r
+ for (unsigned j = 0; j < N; ++j)\r
+ {\r
+ float v = 0.0f;\r
+\r
+ byte ui = (byte) 'N';\r
+ byte uj = (byte) toupper(Alphabet[j]);\r
+ byte li = (byte) 'n';\r
+ byte lj = (byte) tolower(uj);\r
+ ui = (byte) toupper(ui);\r
+ uj = (byte) toupper(uj);\r
+\r
+ g_SubstMx[ui][uj] = v;\r
+ g_SubstMx[uj][ui] = v;\r
+\r
+ g_SubstMx[ui][lj] = v;\r
+ g_SubstMx[uj][li] = v;\r
+\r
+ g_SubstMx[li][uj] = v;\r
+ g_SubstMx[lj][ui] = v;\r
+\r
+ g_SubstMx[li][lj] = v;\r
+ g_SubstMx[lj][li] = v;\r
+ }\r
+ }\r