File: tracebackopt.cpp

package info (click to toggle)
muscle 3.52-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,196 kB
  • ctags: 1,763
  • sloc: cpp: 21,335; xml: 185; makefile: 104
file content (73 lines) | stat: -rw-r--r-- 1,463 bytes parent folder | download | duplicates (14)
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
#include "muscle.h"
#include "pwpath.h"

void TraceBackToPath(int **TraceBack, unsigned uLengthA,
  unsigned uLengthB, PWPath &Path)
	{
	Path.Clear();

	PWEdge Edge;
	Edge.uPrefixLengthA = uLengthA;
	Edge.uPrefixLengthB = uLengthB;

	for (;;)
		{
		if (0 == Edge.uPrefixLengthA && 0 == Edge.uPrefixLengthB)
			break;

		int iDelta = TraceBack[Edge.uPrefixLengthA][Edge.uPrefixLengthB];
#if	TRACE
		Log("TraceBack[%u][%u] = %d\n",
		  Edge.uPrefixLengthA, Edge.uPrefixLengthB, iDelta);
#endif
		if (0 == iDelta)
			{
			assert(Edge.uPrefixLengthA > 0);
			assert(Edge.uPrefixLengthB > 0);

			Edge.cType = 'M';
			Path.PrependEdge(Edge);
			--(Edge.uPrefixLengthA);
			--(Edge.uPrefixLengthB);
			continue;
			}
		else if (iDelta > 0)
			{
			Edge.cType = 'D';
			while (iDelta-- > 0)
				{
				assert(Edge.uPrefixLengthA > 0);

				Path.PrependEdge(Edge);
				--(Edge.uPrefixLengthA);
				}
			}
		else if (iDelta < 0)
			{
			Edge.cType = 'I';
			while (iDelta++ < 0)
				{
				assert(Edge.uPrefixLengthB > 0);

				Path.PrependEdge(Edge);
				--(Edge.uPrefixLengthB);
				}
			}

		if (0 == Edge.uPrefixLengthA && 0 == Edge.uPrefixLengthB)
			break;

		assert(Edge.uPrefixLengthA > 0);
		assert(Edge.uPrefixLengthB > 0);

		Edge.cType = 'M';
		Path.PrependEdge(Edge);
		--(Edge.uPrefixLengthA);
		--(Edge.uPrefixLengthB);
		}

#if	TRACE
	Log("TraceBackToPath ");
	Path.LogMe();
#endif
	}