]> git.donarmstrong.com Git - mothur.git/blob - uchime_src/seqdb.h
changes while testing
[mothur.git] / uchime_src / seqdb.h
1 #ifndef seqdb_h\r
2 #define seqdb_h\r
3 \r
4 #include <vector>\r
5 #include <map>\r
6 \r
7 struct SeqData;\r
8 \r
9 using namespace std;\r
10 \r
11 struct SeqDB\r
12         {\r
13 private:\r
14         SeqDB(const SeqDB &rhs);\r
15         SeqDB &operator=(const SeqDB &rhs);\r
16 \r
17 public:\r
18         string m_FileName;\r
19         char **m_Labels;\r
20         byte **m_Seqs;\r
21         unsigned *m_SeqLengths;\r
22         unsigned m_SeqCount;\r
23         unsigned m_Size;\r
24 \r
25         bool m_Aligned;\r
26         bool m_IsNucleo;\r
27         bool m_IsNucleoSet;\r
28 \r
29 public:\r
30         SeqDB();\r
31         ~SeqDB();\r
32         void Clear(bool ctor = false);\r
33         void InitEmpty(bool Nucleo);\r
34 \r
35         unsigned AddSeq(const char *Label, const byte *Seq, unsigned L);\r
36 \r
37         byte *GetSeq(unsigned SeqIndex) const\r
38                 {\r
39                 asserta(SeqIndex < m_SeqCount);\r
40                 return m_Seqs[SeqIndex];\r
41                 }\r
42 \r
43         const char *GetLabel(unsigned SeqIndex) const\r
44                 {\r
45                 asserta(SeqIndex < m_SeqCount);\r
46                 return m_Labels[SeqIndex];\r
47                 }\r
48 \r
49         unsigned GetSeqLength(unsigned SeqIndex) const\r
50                 {\r
51                 asserta(SeqIndex < m_SeqCount);\r
52                 return m_SeqLengths[SeqIndex];\r
53                 }\r
54 \r
55         unsigned GetSeqCount() const\r
56                 {\r
57                 return m_SeqCount;\r
58                 }\r
59 \r
60         unsigned GetPairCount() const\r
61                 {\r
62                 unsigned SeqCount = GetSeqCount();\r
63                 return (SeqCount*(SeqCount - 1))/2;\r
64                 }\r
65 \r
66         unsigned GetPairIndex(unsigned SeqIndex1, unsigned SeqIndex2) const\r
67                 {\r
68                 if (SeqIndex1 > SeqIndex2)\r
69                         return (SeqIndex1*(SeqIndex1 - 1))/2 + SeqIndex2;\r
70                 return (SeqIndex2*(SeqIndex2 - 1))/2 + SeqIndex1;\r
71                 }\r
72 \r
73         unsigned GetColCount() const\r
74                 {\r
75                 if (!m_Aligned)\r
76                         Die("SeqDB::GetColCount, not aligned");\r
77                 if (m_SeqCount == 0)\r
78                         Die("SeqDB::GetColCount, empty");\r
79                 return m_SeqLengths[0];\r
80                 }\r
81 \r
82         bool IsNucleo() const\r
83                 {\r
84                 asserta(m_IsNucleoSet);\r
85                 return m_IsNucleo;\r
86                 }\r
87 \r
88         void GetSeqData(unsigned Id, SeqData &Buffer) const;\r
89 \r
90         unsigned GetMaxLabelLength() const;\r
91         unsigned GetMaxSeqLength() const;\r
92         void SetIsNucleo();\r
93         unsigned GetIndex(const char *Label) const;\r
94         void MakeLabelToIndex(map<string, unsigned> &LabelToIndex);\r
95 \r
96         void LogMe() const;\r
97         void FromFasta(const string &FileName, bool AllowGaps = false);\r
98 \r
99         void ToFasta(const string &FileName) const;\r
100         void ToFasta(FILE *f, unsigned SeqIndex) const;\r
101         void SeqToFasta(FILE *f, unsigned SeqIndex, bool WithLabel = false) const;\r
102 \r
103         unsigned GetTotalLength() const;\r
104         };\r
105 \r
106 bool isgap(byte c);\r
107 \r
108 #endif\r