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