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