Next version of JABA
[jabaws.git] / binaries / src / muscle / pwpath.h
1 #ifndef PWPath_h\r
2 #define PWPath_h\r
3 \r
4 /***\r
5 Each PWEdge in a PWPath specifies a column in a pair-wise (PW) alignment.\r
6 "Path" is by analogy with the path through an HMM.\r
7 Edge types are:\r
8 \r
9         'M'             LetterA + LetterB\r
10         'D'             LetterA + GapB\r
11         'I'             GapB + LetterA\r
12 \r
13 The mnemomic is Match, Delete, Insert (with respect to A).\r
14 Here is a global alignment of sequences A and B.\r
15 \r
16         A:      AMQT-F\r
17         B:      -M-TIF\r
18 \r
19 The path for this example is:\r
20 \r
21         Edge    cType   uPrefixLengthA  uPrefixLengthB\r
22         0               D               1                               0\r
23         1               M               2                               1\r
24         2               D               3                               1\r
25         3               M               4                               2\r
26         4               I               4                               3\r
27         5               M               5                               4\r
28 \r
29 Given the starting positions in each alignment (e.g., column zero for\r
30 a global alignment), the prefix length fields are redundant; they are\r
31 included only for convenience and as a sanity check, we are not trying\r
32 to optimize for speed or space here. We use prefix lengths rather than\r
33 column indexes because of the problem of representing the special case\r
34 of a gap in the first position.\r
35 ***/\r
36 \r
37 class Seq;\r
38 class MSA;\r
39 class SatchmoParams;\r
40 class PW;\r
41 class TextFile;\r
42 class PWScore;\r
43 \r
44 class PWEdge\r
45         {\r
46 public:\r
47         char cType;\r
48         unsigned uPrefixLengthA;\r
49         unsigned uPrefixLengthB;\r
50 \r
51         bool Equal(const PWEdge &e) const\r
52                 {\r
53                 return uPrefixLengthA == e.uPrefixLengthA &&\r
54                   uPrefixLengthB == e.uPrefixLengthB &&\r
55                   cType == e.cType;\r
56                 }\r
57         };\r
58 \r
59 class PWPath\r
60         {\r
61 // Disable compiler defaults\r
62 private:\r
63         PWPath &operator=(const PWPath &rhs);\r
64         PWPath(const PWPath &rhs);\r
65 \r
66 public:\r
67         PWPath();\r
68         virtual ~PWPath();\r
69 \r
70 public:\r
71         void Clear();\r
72         void FromStr(const char Str[]);\r
73         void Copy(const PWPath &Path);\r
74         void AppendEdge(const PWEdge &Edge);\r
75         void AppendEdge(char cType, unsigned uPrefixLengthA, unsigned uPrefixLengthB);\r
76         void PrependEdge(const PWEdge &Edge);\r
77         unsigned GetEdgeCount() const { return m_uEdgeCount; }\r
78         const PWEdge &GetEdge(unsigned uEdgeIndex) const;\r
79         void Validate(const PWScore &PWS) const;\r
80         void Validate() const;\r
81         void LogMe() const;\r
82         void FromFile(TextFile &File);\r
83         void ToFile(TextFile &File) const;\r
84         void FromMSAPair(const MSA &msaA, const MSA &msaB);\r
85         void AssertEqual(const PWPath &Path) const;\r
86         bool Equal(const PWPath &Path) const;\r
87         unsigned GetMatchCount() const;\r
88         unsigned GetDeleteCount() const;\r
89         unsigned GetInsertCount() const;\r
90 \r
91 private:\r
92         void ExpandPath(unsigned uAdditionalEdgeCount);\r
93 \r
94 private:\r
95         unsigned m_uEdgeCount;\r
96         unsigned m_uArraySize;\r
97         PWEdge *m_Edges;\r
98         };\r
99 \r
100 #endif  // PWPath_h\r