| 1 | #ifndef diaglist_h |
|---|
| 2 | #define diaglist_h |
|---|
| 3 | |
|---|
| 4 | const unsigned EMPTY = (unsigned) ~0; |
|---|
| 5 | const unsigned MAX_DIAGS = 1024; |
|---|
| 6 | |
|---|
| 7 | struct Diag |
|---|
| 8 | { |
|---|
| 9 | unsigned m_uStartPosA; |
|---|
| 10 | unsigned m_uStartPosB; |
|---|
| 11 | unsigned m_uLength; |
|---|
| 12 | }; |
|---|
| 13 | |
|---|
| 14 | struct Rect |
|---|
| 15 | { |
|---|
| 16 | unsigned m_uStartPosA; |
|---|
| 17 | unsigned m_uStartPosB; |
|---|
| 18 | unsigned m_uLengthA; |
|---|
| 19 | unsigned m_uLengthB; |
|---|
| 20 | }; |
|---|
| 21 | |
|---|
| 22 | class DiagList |
|---|
| 23 | { |
|---|
| 24 | public: |
|---|
| 25 | DiagList() |
|---|
| 26 | { |
|---|
| 27 | m_uCount = 0; |
|---|
| 28 | } |
|---|
| 29 | ~DiagList() |
|---|
| 30 | { |
|---|
| 31 | Free(); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | public: |
|---|
| 35 | // Creation |
|---|
| 36 | void Clear() |
|---|
| 37 | { |
|---|
| 38 | Free(); |
|---|
| 39 | } |
|---|
| 40 | void FromPath(const PWPath &Path); |
|---|
| 41 | void Add(const Diag &d); |
|---|
| 42 | void Add(unsigned uStartPosA, unsigned uStartPosB, unsigned uLength); |
|---|
| 43 | void DeleteIncompatible(); |
|---|
| 44 | |
|---|
| 45 | // Accessors |
|---|
| 46 | unsigned GetCount() const |
|---|
| 47 | { |
|---|
| 48 | return m_uCount; |
|---|
| 49 | } |
|---|
| 50 | const Diag &Get(unsigned uIndex) const; |
|---|
| 51 | |
|---|
| 52 | // Operations |
|---|
| 53 | void Sort(); |
|---|
| 54 | void Copy(const DiagList &DL); |
|---|
| 55 | |
|---|
| 56 | // Query |
|---|
| 57 | // returns true iff given diagonal is included in the list |
|---|
| 58 | // in whole or in part. |
|---|
| 59 | bool NonZeroIntersection(const Diag &d) const; |
|---|
| 60 | bool IsSorted() const; |
|---|
| 61 | |
|---|
| 62 | // Diagnostics |
|---|
| 63 | void LogMe() const; |
|---|
| 64 | |
|---|
| 65 | private: |
|---|
| 66 | void Free() |
|---|
| 67 | { |
|---|
| 68 | m_uCount = 0; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | private: |
|---|
| 72 | unsigned m_uCount; |
|---|
| 73 | Diag m_Diags[MAX_DIAGS]; |
|---|
| 74 | }; |
|---|
| 75 | |
|---|
| 76 | unsigned DiagOverlap(const Diag &d1, const Diag &d2); |
|---|
| 77 | unsigned DiagOverlapA(const Diag &d1, const Diag &d2); |
|---|
| 78 | unsigned DiagOverlapB(const Diag &d1, const Diag &d2); |
|---|
| 79 | unsigned DiagBreak(const Diag &d1, const Diag &d2); |
|---|
| 80 | bool DiagCompatible(const Diag &d1, const Diag &d2); |
|---|
| 81 | void CheckDiags(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 82 | unsigned uLengthB, const MSA &msaA, const MSA &msaB, const PWPath &Path); |
|---|
| 83 | void FindDiags(const ProfPos *PX, unsigned uLengthX, const ProfPos *PY, |
|---|
| 84 | unsigned uLengthY, DiagList &DL); |
|---|
| 85 | void FindDiagsNuc(const ProfPos *PX, unsigned uLengthX, const ProfPos *PY, |
|---|
| 86 | unsigned uLengthY, DiagList &DL); |
|---|
| 87 | void MergeDiags(DiagList &DL); |
|---|
| 88 | |
|---|
| 89 | #endif // diaglist_h |
|---|