| 1 | #include "muscle.h" |
|---|
| 2 | #include "pwpath.h" |
|---|
| 3 | #include "timing.h" |
|---|
| 4 | #include "textfile.h" |
|---|
| 5 | #include "msa.h" |
|---|
| 6 | #include "profile.h" |
|---|
| 7 | |
|---|
| 8 | #if !VER_3_52 |
|---|
| 9 | |
|---|
| 10 | #define COMPARE_SIMPLE 0 |
|---|
| 11 | |
|---|
| 12 | #if TIMING |
|---|
| 13 | TICKS g_ticksDP = 0; |
|---|
| 14 | #endif |
|---|
| 15 | |
|---|
| 16 | #if 1 |
|---|
| 17 | extern bool g_bKeepSimpleDP; |
|---|
| 18 | SCORE NWSmall(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 19 | unsigned uLengthB, PWPath &Path); |
|---|
| 20 | SCORE NWDASmall(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 21 | unsigned uLengthB, PWPath &Path); |
|---|
| 22 | SCORE NWDASimple(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 23 | unsigned uLengthB, PWPath &Path); |
|---|
| 24 | SCORE NWDASimple2(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 25 | unsigned uLengthB, PWPath &Path); |
|---|
| 26 | SCORE GlobalAlignSimple(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 27 | unsigned uLengthB, PWPath &Path); |
|---|
| 28 | |
|---|
| 29 | SCORE GlobalAlignNoDiags(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 30 | unsigned uLengthB, PWPath &Path) |
|---|
| 31 | { |
|---|
| 32 | return GlobalAlign(PA, uLengthA, PB, uLengthB, Path); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | #if COMPARE_SIMPLE |
|---|
| 36 | |
|---|
| 37 | SCORE GlobalAlign(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 38 | unsigned uLengthB, PWPath &Path) |
|---|
| 39 | { |
|---|
| 40 | #if TIMING |
|---|
| 41 | TICKS t1 = GetClockTicks(); |
|---|
| 42 | #endif |
|---|
| 43 | g_bKeepSimpleDP = true; |
|---|
| 44 | PWPath SimplePath; |
|---|
| 45 | GlobalAlignSimple(PA, uLengthA, PB, uLengthB, SimplePath); |
|---|
| 46 | |
|---|
| 47 | SCORE Score = NWSmall(PA, uLengthA, PB, uLengthB, Path); |
|---|
| 48 | |
|---|
| 49 | if (!Path.Equal(SimplePath)) |
|---|
| 50 | { |
|---|
| 51 | Log("Simple:\n"); |
|---|
| 52 | SimplePath.LogMe(); |
|---|
| 53 | Log("Small:\n"); |
|---|
| 54 | Path.LogMe(); |
|---|
| 55 | Quit("Paths differ"); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | #if TIMING |
|---|
| 59 | TICKS t2 = GetClockTicks(); |
|---|
| 60 | g_ticksDP += (t2 - t1); |
|---|
| 61 | #endif |
|---|
| 62 | return Score; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | #else // COMPARE_SIMPLE |
|---|
| 66 | |
|---|
| 67 | SCORE GlobalAlign(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 68 | unsigned uLengthB, PWPath &Path) |
|---|
| 69 | { |
|---|
| 70 | #if TIMING |
|---|
| 71 | TICKS t1 = GetClockTicks(); |
|---|
| 72 | #endif |
|---|
| 73 | SCORE Score = NWSmall(PA, uLengthA, PB, uLengthB, Path); |
|---|
| 74 | #if TIMING |
|---|
| 75 | TICKS t2 = GetClockTicks(); |
|---|
| 76 | g_ticksDP += (t2 - t1); |
|---|
| 77 | #endif |
|---|
| 78 | return Score; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | #endif |
|---|
| 82 | |
|---|
| 83 | #else // 1 |
|---|
| 84 | |
|---|
| 85 | static void AllInserts(PWPath &Path, unsigned uLengthB) |
|---|
| 86 | { |
|---|
| 87 | Path.Clear(); |
|---|
| 88 | PWEdge Edge; |
|---|
| 89 | Edge.cType = 'I'; |
|---|
| 90 | Edge.uPrefixLengthA = 0; |
|---|
| 91 | for (unsigned uPrefixLengthB = 1; uPrefixLengthB <= uLengthB; ++uPrefixLengthB) |
|---|
| 92 | { |
|---|
| 93 | Edge.uPrefixLengthB = uPrefixLengthB; |
|---|
| 94 | Path.AppendEdge(Edge); |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | static void AllDeletes(PWPath &Path, unsigned uLengthA) |
|---|
| 99 | { |
|---|
| 100 | Path.Clear(); |
|---|
| 101 | PWEdge Edge; |
|---|
| 102 | Edge.cType = 'D'; |
|---|
| 103 | Edge.uPrefixLengthB = 0; |
|---|
| 104 | for (unsigned uPrefixLengthA = 1; uPrefixLengthA <= uLengthA; ++uPrefixLengthA) |
|---|
| 105 | { |
|---|
| 106 | Edge.uPrefixLengthA = uPrefixLengthA; |
|---|
| 107 | Path.AppendEdge(Edge); |
|---|
| 108 | } |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | SCORE GlobalAlign(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 112 | unsigned uLengthB, PWPath &Path) |
|---|
| 113 | { |
|---|
| 114 | #if TIMING |
|---|
| 115 | TICKS t1 = GetClockTicks(); |
|---|
| 116 | #endif |
|---|
| 117 | if (0 == uLengthA) |
|---|
| 118 | { |
|---|
| 119 | AllInserts(Path, uLengthB); |
|---|
| 120 | return 0; |
|---|
| 121 | } |
|---|
| 122 | else if (0 == uLengthB) |
|---|
| 123 | { |
|---|
| 124 | AllDeletes(Path, uLengthA); |
|---|
| 125 | return 0; |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | SCORE Score = 0; |
|---|
| 129 | if (g_bDiags) |
|---|
| 130 | Score = GlobalAlignDiags(PA, uLengthA, PB, uLengthB, Path); |
|---|
| 131 | else |
|---|
| 132 | Score = GlobalAlignNoDiags(PA, uLengthA, PB, uLengthB, Path); |
|---|
| 133 | #if TIMING |
|---|
| 134 | TICKS t2 = GetClockTicks(); |
|---|
| 135 | g_ticksDP += (t2 - t1); |
|---|
| 136 | #endif |
|---|
| 137 | return Score; |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | SCORE GlobalAlignNoDiags(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 141 | unsigned uLengthB, PWPath &Path) |
|---|
| 142 | { |
|---|
| 143 | if (g_bDimer) |
|---|
| 144 | return GlobalAlignDimer(PA, uLengthA, PB, uLengthB, Path); |
|---|
| 145 | |
|---|
| 146 | switch (g_PPScore) |
|---|
| 147 | { |
|---|
| 148 | case PPSCORE_LE: |
|---|
| 149 | return GlobalAlignLE(PA, uLengthA, PB, uLengthB, Path); |
|---|
| 150 | |
|---|
| 151 | case PPSCORE_SP: |
|---|
| 152 | case PPSCORE_SV: |
|---|
| 153 | return GlobalAlignSP(PA, uLengthA, PB, uLengthB, Path); |
|---|
| 154 | |
|---|
| 155 | case PPSCORE_SPN: |
|---|
| 156 | return GlobalAlignSPN(PA, uLengthA, PB, uLengthB, Path); |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | Quit("Invalid PP score (GlobalAlignNoDiags)"); |
|---|
| 160 | return 0; |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | #endif |
|---|
| 164 | |
|---|
| 165 | #endif // !VER_3_52 |
|---|