| 1 | #ifndef Seq_h |
|---|
| 2 | #define Seq_h |
|---|
| 3 | |
|---|
| 4 | #include <vector> |
|---|
| 5 | |
|---|
| 6 | class TextFile; |
|---|
| 7 | class MSA; |
|---|
| 8 | |
|---|
| 9 | typedef std::vector<char> CharVect; |
|---|
| 10 | |
|---|
| 11 | class Seq : public CharVect |
|---|
| 12 | { |
|---|
| 13 | public: |
|---|
| 14 | Seq() |
|---|
| 15 | { |
|---|
| 16 | m_ptrName = 0; |
|---|
| 17 | // Start with moderate size to avoid |
|---|
| 18 | // thrashing the heap. |
|---|
| 19 | reserve(200); |
|---|
| 20 | } |
|---|
| 21 | virtual ~Seq() |
|---|
| 22 | { |
|---|
| 23 | delete[] m_ptrName; |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | private: |
|---|
| 27 | // Not implemented; prevent use of copy c'tor and assignment. |
|---|
| 28 | Seq(const Seq &); |
|---|
| 29 | Seq &operator=(const Seq &); |
|---|
| 30 | |
|---|
| 31 | public: |
|---|
| 32 | void Clear() |
|---|
| 33 | { |
|---|
| 34 | clear(); |
|---|
| 35 | delete[] m_ptrName; |
|---|
| 36 | m_ptrName = 0; |
|---|
| 37 | m_uId = uInsane; |
|---|
| 38 | } |
|---|
| 39 | const char *GetName() const |
|---|
| 40 | { |
|---|
| 41 | return m_ptrName; |
|---|
| 42 | } |
|---|
| 43 | unsigned GetId() const |
|---|
| 44 | { |
|---|
| 45 | if (uInsane == m_uId) |
|---|
| 46 | Quit("Seq::GetId, id not set"); |
|---|
| 47 | return m_uId; |
|---|
| 48 | } |
|---|
| 49 | void SetId(unsigned uId) { m_uId = uId; } |
|---|
| 50 | |
|---|
| 51 | bool FromFASTAFile(TextFile &File); |
|---|
| 52 | void ToFASTAFile(TextFile &File) const; |
|---|
| 53 | void ExtractUngapped(MSA &msa) const; |
|---|
| 54 | |
|---|
| 55 | void FromString(const char *pstrSeq, const char *pstrName); |
|---|
| 56 | void Copy(const Seq &rhs); |
|---|
| 57 | void CopyReversed(const Seq &rhs); |
|---|
| 58 | void StripGaps(); |
|---|
| 59 | void StripGapsAndWhitespace(); |
|---|
| 60 | void ToUpper(); |
|---|
| 61 | void SetName(const char *ptrName); |
|---|
| 62 | unsigned GetLetter(unsigned uIndex) const; |
|---|
| 63 | unsigned Length() const { return (unsigned) size(); } |
|---|
| 64 | bool Eq(const Seq &s) const; |
|---|
| 65 | bool EqIgnoreCase(const Seq &s) const; |
|---|
| 66 | bool EqIgnoreCaseAndGaps(const Seq &s) const; |
|---|
| 67 | bool HasGap() const; |
|---|
| 68 | unsigned GetUngappedLength() const; |
|---|
| 69 | void LogMe() const; |
|---|
| 70 | char GetChar(unsigned uIndex) const { return operator[](uIndex); } |
|---|
| 71 | void SetChar(unsigned uIndex, char c) { operator[](uIndex) = c; } |
|---|
| 72 | void AppendChar(char c) { push_back(c); } |
|---|
| 73 | void FixAlpha(); |
|---|
| 74 | |
|---|
| 75 | #ifndef _WIN32 |
|---|
| 76 | reference at(size_type i) { return operator[](i); } |
|---|
| 77 | const_reference at(size_type i) const { return operator[](i); } |
|---|
| 78 | #endif |
|---|
| 79 | |
|---|
| 80 | private: |
|---|
| 81 | char *m_ptrName; |
|---|
| 82 | unsigned m_uId; |
|---|
| 83 | }; |
|---|
| 84 | |
|---|
| 85 | #endif // Seq.h |
|---|