1 | #include "muscle.h" |
---|
2 | #include "msa.h" |
---|
3 | #include "tree.h" |
---|
4 | #include "seqvect.h" |
---|
5 | |
---|
6 | #if DEBUG |
---|
7 | static SeqVect *g_ptrMuscleSeqVect = 0; |
---|
8 | static MSA MuscleInputMSA; |
---|
9 | |
---|
10 | void SetMuscleInputMSA(MSA &msa) |
---|
11 | { |
---|
12 | MuscleInputMSA.Copy(msa); |
---|
13 | } |
---|
14 | |
---|
15 | void SetMuscleSeqVect(SeqVect &v) |
---|
16 | { |
---|
17 | g_ptrMuscleSeqVect = &v; |
---|
18 | } |
---|
19 | |
---|
20 | void ValidateMuscleIdsSeqVect(const MSA &msa) |
---|
21 | { |
---|
22 | const unsigned uSeqCount = msa.GetSeqCount(); |
---|
23 | for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex) |
---|
24 | { |
---|
25 | const unsigned uId = msa.GetSeqId(uSeqIndex); |
---|
26 | const char *ptrNameMSA = msa.GetSeqName(uSeqIndex); |
---|
27 | const char *ptrName = g_ptrMuscleSeqVect->GetSeqName(uId); |
---|
28 | if (0 != strcmp(ptrNameMSA, ptrName)) |
---|
29 | Quit("ValidateMuscleIdsSeqVect, names don't match"); |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | void ValidateMuscleIdsMSA(const MSA &msa) |
---|
34 | { |
---|
35 | const unsigned uSeqCount = msa.GetSeqCount(); |
---|
36 | for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex) |
---|
37 | { |
---|
38 | const unsigned uId = msa.GetSeqId(uSeqIndex); |
---|
39 | const char *ptrNameMSA = msa.GetSeqName(uSeqIndex); |
---|
40 | const char *ptrName = MuscleInputMSA.GetSeqName(uId); |
---|
41 | if (0 != strcmp(ptrNameMSA, ptrName)) |
---|
42 | { |
---|
43 | Log("Input MSA:\n"); |
---|
44 | MuscleInputMSA.LogMe(); |
---|
45 | Log("MSA being tested:\n"); |
---|
46 | msa.LogMe(); |
---|
47 | Log("Id=%u\n", uId); |
---|
48 | Log("Input name=%s\n", ptrName); |
---|
49 | Log("Test name=%s\n", ptrNameMSA); |
---|
50 | Quit("ValidateMuscleIdsMSA, names don't match"); |
---|
51 | } |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | void ValidateMuscleIds(const MSA &msa) |
---|
56 | { |
---|
57 | if (0 != g_ptrMuscleSeqVect) |
---|
58 | ValidateMuscleIdsSeqVect(msa); |
---|
59 | else if (0 != MuscleInputMSA.GetSeqCount()) |
---|
60 | ValidateMuscleIdsMSA(msa); |
---|
61 | else |
---|
62 | Quit("ValidateMuscleIds, ptrMuscleSeqVect=0 && 0 == MuscleInputMSA.SeqCount()"); |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | void ValidateMuscleIdsSeqVect(const Tree &tree) |
---|
67 | { |
---|
68 | const unsigned uSeqCount = g_ptrMuscleSeqVect->GetSeqCount(); |
---|
69 | const unsigned uNodeCount = tree.GetNodeCount(); |
---|
70 | for (unsigned uNodeIndex = 0; uNodeIndex < uNodeCount; ++uNodeIndex) |
---|
71 | { |
---|
72 | if (!tree.IsLeaf(uNodeIndex)) |
---|
73 | continue; |
---|
74 | const unsigned uId = tree.GetLeafId(uNodeIndex); |
---|
75 | if (uId >= uSeqCount) |
---|
76 | { |
---|
77 | tree.LogMe(); |
---|
78 | Quit("Leaf with node index %u has id=%u, there are %u seqs", |
---|
79 | uNodeIndex, uId, uSeqCount); |
---|
80 | } |
---|
81 | const char *ptrNameTree = tree.GetLeafName(uNodeIndex); |
---|
82 | const char *ptrName = g_ptrMuscleSeqVect->GetSeqName(uId); |
---|
83 | if (0 != strcmp(ptrNameTree, ptrName)) |
---|
84 | Quit("ValidateMuscleIds: names don't match"); |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | void ValidateMuscleIdsMSA(const Tree &tree) |
---|
89 | { |
---|
90 | const unsigned uNodeCount = tree.GetNodeCount(); |
---|
91 | for (unsigned uNodeIndex = 0; uNodeIndex < uNodeCount; ++uNodeIndex) |
---|
92 | { |
---|
93 | if (!tree.IsLeaf(uNodeIndex)) |
---|
94 | continue; |
---|
95 | const unsigned uId = tree.GetLeafId(uNodeIndex); |
---|
96 | const char *ptrNameTree = tree.GetLeafName(uNodeIndex); |
---|
97 | const char *ptrName = MuscleInputMSA.GetSeqName(uId); |
---|
98 | if (0 != strcmp(ptrNameTree, ptrName)) |
---|
99 | Quit("ValidateMuscleIds: names don't match"); |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | void ValidateMuscleIds(const Tree &tree) |
---|
104 | { |
---|
105 | if (0 != g_ptrMuscleSeqVect) |
---|
106 | ValidateMuscleIdsSeqVect(tree); |
---|
107 | else if (0 != MuscleInputMSA.GetSeqCount()) |
---|
108 | ValidateMuscleIdsMSA(tree); |
---|
109 | else |
---|
110 | Quit("ValidateMuscleIds, ptrMuscleSeqVect=0 && 0 == MuscleInputMSA.SeqCount"); |
---|
111 | } |
---|
112 | #endif |
---|