]> git.donarmstrong.com Git - mothur.git/blob - uchime_src/setnucmx.cpp
changes while testing
[mothur.git] / uchime_src / setnucmx.cpp
1 #include "myutils.h"
2 #include "mx.h"
3
4 Mx<float> g_SubstMxf;
5 float **g_SubstMx;
6
7 static const char Alphabet[] = "ACGTU";
8
9 void SetNucSubstMx(double Match, double Mismatch)\r
10         {\r
11         static bool Done = false;\r
12         if (Done)\r
13                 return;\r
14         Done = true;\r
15 \r
16         if (Match <= 0.0)\r
17                 Die("Match score should be +ve");\r
18         if (Mismatch >= 0.0)\r
19                 Die("Mismatch score should be -ve");\r
20 \r
21         unsigned N = unsigned(strlen(Alphabet));\r
22 \r
23         g_SubstMxf.Alloc("NUCMX", 256, 256);\r
24         strcpy(g_SubstMxf.m_Alpha, "ACGT");\r
25         g_SubstMxf.Init(0);\r
26         g_SubstMx = g_SubstMxf.GetData();\r
27         for (unsigned i = 0; i < N; ++i)\r
28                 {\r
29                 for (unsigned j = 0; j < N; ++j)\r
30                         {\r
31                         float v = float(i == j ? Match : Mismatch);\r
32 \r
33                         byte ui = (byte) toupper(Alphabet[i]);\r
34                         byte uj = (byte) toupper(Alphabet[j]);\r
35                         byte li = (byte) tolower(ui);\r
36                         byte lj = (byte) tolower(uj);\r
37                         ui = (byte) toupper(ui);\r
38                         uj = (byte) toupper(uj);\r
39 \r
40                         g_SubstMx[ui][uj] = v;\r
41                         g_SubstMx[uj][ui] = v;\r
42 \r
43                         g_SubstMx[ui][lj] = v;\r
44                         g_SubstMx[uj][li] = v;\r
45 \r
46                         g_SubstMx[li][uj] = v;\r
47                         g_SubstMx[lj][ui] = v;\r
48 \r
49                         g_SubstMx[li][lj] = v;\r
50                         g_SubstMx[lj][li] = v;\r
51                         }\r
52                 }\r
53 \r
54         for (unsigned j = 0; j < N; ++j)\r
55                 {\r
56                 float v = 0.0f;\r
57 \r
58                 byte ui = (byte) 'N';\r
59                 byte uj = (byte) toupper(Alphabet[j]);\r
60                 byte li = (byte) 'n';\r
61                 byte lj = (byte) tolower(uj);\r
62                 ui = (byte) toupper(ui);\r
63                 uj = (byte) toupper(uj);\r
64 \r
65                 g_SubstMx[ui][uj] = v;\r
66                 g_SubstMx[uj][ui] = v;\r
67 \r
68                 g_SubstMx[ui][lj] = v;\r
69                 g_SubstMx[uj][li] = v;\r
70 \r
71                 g_SubstMx[li][uj] = v;\r
72                 g_SubstMx[lj][ui] = v;\r
73 \r
74                 g_SubstMx[li][lj] = v;\r
75                 g_SubstMx[lj][li] = v;\r
76                 }\r
77         }\r