+++ /dev/null
-#include "muscle.h"\r
-#include "dpreglist.h"\r
-#include "diaglist.h"\r
-#include "pwpath.h"\r
-#include "profile.h"\r
-#include "timing.h"\r
-\r
-#define TRACE 0\r
-#define TRACE_PATH 0\r
-#define LIST_DIAGS 0\r
-\r
-static double g_dDPAreaWithoutDiags = 0.0;\r
-static double g_dDPAreaWithDiags = 0.0;\r
-\r
-static void OffsetPath(PWPath &Path, unsigned uOffsetA, unsigned uOffsetB)\r
- {\r
- const unsigned uEdgeCount = Path.GetEdgeCount();\r
- for (unsigned uEdgeIndex = 0; uEdgeIndex < uEdgeCount; ++uEdgeIndex)\r
- {\r
- const PWEdge &Edge = Path.GetEdge(uEdgeIndex);\r
-\r
- // Nasty hack -- poke new values back into path, circumventing class\r
- PWEdge &NonConstEdge = (PWEdge &) Edge;\r
- NonConstEdge.uPrefixLengthA += uOffsetA;\r
- NonConstEdge.uPrefixLengthB += uOffsetB;\r
- }\r
- }\r
-\r
-static void DiagToPath(const Diag &d, PWPath &Path)\r
- {\r
- Path.Clear();\r
- const unsigned uLength = d.m_uLength;\r
- for (unsigned i = 0; i < uLength; ++i)\r
- {\r
- PWEdge Edge;\r
- Edge.cType = 'M';\r
- Edge.uPrefixLengthA = d.m_uStartPosA + i + 1;\r
- Edge.uPrefixLengthB = d.m_uStartPosB + i + 1;\r
- Path.AppendEdge(Edge);\r
- }\r
- }\r
-\r
-static void AppendRegPath(PWPath &Path, const PWPath &RegPath)\r
- {\r
- const unsigned uRegEdgeCount = RegPath.GetEdgeCount();\r
- for (unsigned uRegEdgeIndex = 0; uRegEdgeIndex < uRegEdgeCount; ++uRegEdgeIndex)\r
- {\r
- const PWEdge &RegEdge = RegPath.GetEdge(uRegEdgeIndex);\r
- Path.AppendEdge(RegEdge);\r
- }\r
- }\r
-\r
-SCORE GlobalAlignDiags(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB,\r
- unsigned uLengthB, PWPath &Path)\r
- {\r
-#if LIST_DIAGS\r
- TICKS t1 = GetClockTicks();\r
-#endif\r
-\r
- DiagList DL;\r
-\r
- if (ALPHA_Amino == g_Alpha)\r
- FindDiags(PA, uLengthA, PB, uLengthB, DL);\r
- else if (ALPHA_DNA == g_Alpha || ALPHA_RNA == g_Alpha)\r
- FindDiagsNuc(PA, uLengthA, PB, uLengthB, DL);\r
- else\r
- Quit("GlobalAlignDiags: bad alpha");\r
-\r
-#if TRACE\r
- Log("GlobalAlignDiags, diag list:\n");\r
- DL.LogMe();\r
-#endif\r
-\r
- DL.Sort();\r
- DL.DeleteIncompatible();\r
-\r
-#if TRACE\r
- Log("After DeleteIncompatible:\n");\r
- DL.LogMe();\r
-#endif\r
-\r
- MergeDiags(DL);\r
-\r
-#if TRACE\r
- Log("After MergeDiags:\n");\r
- DL.LogMe();\r
-#endif\r
-\r
- DPRegionList RL;\r
- DiagListToDPRegionList(DL, RL, uLengthA, uLengthB);\r
-\r
-#if TRACE\r
- Log("RegionList:\n");\r
- RL.LogMe();\r
-#endif\r
-\r
-#if LIST_DIAGS\r
- {\r
- TICKS t2 = GetClockTicks();\r
- unsigned uArea = RL.GetDPArea();\r
- Log("ticks=%ld\n", (long) (t2 - t1));\r
- Log("area=%u\n", uArea);\r
- }\r
-#endif\r
-\r
- g_dDPAreaWithoutDiags += uLengthA*uLengthB;\r
-\r
- double dDPAreaWithDiags = 0.0;\r
- const unsigned uRegionCount = RL.GetCount();\r
- for (unsigned uRegionIndex = 0; uRegionIndex < uRegionCount; ++uRegionIndex)\r
- {\r
- const DPRegion &r = RL.Get(uRegionIndex);\r
-\r
- PWPath RegPath;\r
- if (DPREGIONTYPE_Diag == r.m_Type)\r
- {\r
- DiagToPath(r.m_Diag, RegPath);\r
-#if TRACE_PATH\r
- Log("DiagToPath, path=\n");\r
- RegPath.LogMe();\r
-#endif\r
- }\r
- else if (DPREGIONTYPE_Rect == r.m_Type)\r
- {\r
- const unsigned uRegStartPosA = r.m_Rect.m_uStartPosA;\r
- const unsigned uRegStartPosB = r.m_Rect.m_uStartPosB;\r
- const unsigned uRegLengthA = r.m_Rect.m_uLengthA;\r
- const unsigned uRegLengthB = r.m_Rect.m_uLengthB;\r
- const ProfPos *RegPA = PA + uRegStartPosA;\r
- const ProfPos *RegPB = PB + uRegStartPosB;\r
-\r
- dDPAreaWithDiags += uRegLengthA*uRegLengthB;\r
- GlobalAlignNoDiags(RegPA, uRegLengthA, RegPB, uRegLengthB, RegPath);\r
-#if TRACE_PATH\r
- Log("GlobalAlignNoDiags RegPath=\n");\r
- RegPath.LogMe();\r
-#endif\r
- OffsetPath(RegPath, uRegStartPosA, uRegStartPosB);\r
-#if TRACE_PATH\r
- Log("After offset path, RegPath=\n");\r
- RegPath.LogMe();\r
-#endif\r
- }\r
- else\r
- Quit("GlobalAlignDiags, Invalid region type %u", r.m_Type);\r
-\r
- AppendRegPath(Path, RegPath);\r
-#if TRACE_PATH\r
- Log("After AppendPath, path=");\r
- Path.LogMe();\r
-#endif\r
- }\r
-\r
-#if TRACE\r
- {\r
- double dDPAreaWithoutDiags = uLengthA*uLengthB;\r
- Log("DP area with diags %.3g without %.3g pct saved %.3g %%\n",\r
- dDPAreaWithDiags, dDPAreaWithoutDiags, (1.0 - dDPAreaWithDiags/dDPAreaWithoutDiags)*100.0);\r
- }\r
-#endif\r
- g_dDPAreaWithDiags += dDPAreaWithDiags;\r
- return 0;\r
- }\r
-\r
-void ListDiagSavings()\r
- {\r
- if (!g_bVerbose || !g_bDiags)\r
- return;\r
- double dAreaSaved = g_dDPAreaWithoutDiags - g_dDPAreaWithDiags;\r
- double dPct = dAreaSaved*100.0/g_dDPAreaWithoutDiags;\r
- Log("DP area saved by diagonals %-4.1f%%\n", dPct);\r
- }\r