]> git.donarmstrong.com Git - mothur.git/blob - chime.h
f143ea10795df3ed995660b0862bb0142f2db91b
[mothur.git] / chime.h
1 //uchime by Robert C. Edgar http://drive5.com/uchime This code is donated to the public domain.\r
2 \r
3 #ifndef chime_h\r
4 #define chime_h\r
5 \r
6 #include "seq.h"\r
7 \r
8 struct ChimeHit2\r
9         {\r
10         string QLabel;\r
11         string ALabel;\r
12         string BLabel;\r
13         string Q3;\r
14         string A3;\r
15         string B3;\r
16 \r
17         //unsigned LY, LN, LA, LD;\r
18         //unsigned RY, RN, RA, RD;\r
19         double PctIdQT, PctIdQA, PctIdQB, PctIdQM, PctIdAB;\r
20 \r
21         unsigned ColLo;\r
22         unsigned ColXLo;\r
23         unsigned ColXHi;\r
24         unsigned ColHi;\r
25         unsigned QXLo;\r
26         unsigned QXHi;\r
27 \r
28         double Div;\r
29         double Score;\r
30         double H;\r
31 \r
32         unsigned CS_LY, CS_LN, CS_LA, CS_RY, CS_RN, CS_RA;\r
33 \r
34         float AbQ;\r
35         float AbA;\r
36         float AbB;\r
37 \r
38         ChimeHit2()\r
39                 {\r
40                 Clear();\r
41                 }\r
42 \r
43         void Clear()\r
44                 {\r
45                 Q3.clear();\r
46                 A3.clear();\r
47                 B3.clear();\r
48                 QLabel.clear();\r
49                 ALabel.clear();\r
50                 BLabel.clear();\r
51 \r
52                 //LY = LN = LA = LD = UINT_MAX;\r
53                 //RY = RN = RA = RD = UINT_MAX;\r
54                 ColLo = ColHi = QXLo = QXHi = ColXLo = ColXHi = UINT_MAX;\r
55                 CS_LY = CS_LN = CS_LA = CS_RY = CS_RN = CS_RA = UINT_MAX;\r
56                 PctIdQT = PctIdQA = PctIdQB = PctIdQM = PctIdAB = -1.0;\r
57                 Div = -1.0;\r
58                 H = -1.0;\r
59                 Score = -1.0;\r
60                 AbQ = AbA = AbB = -1.0f;\r
61                 };\r
62 \r
63         bool Accept() const\r
64                 {\r
65                 return Score >= opt_minh && Div >= opt_mindiv && CS_LY >= opt_mindiffs && CS_RY >= opt_mindiffs;\r
66                 }\r
67 \r
68         void LogMe() const\r
69                 {\r
70                 Log("@L %c ", yon(Score >= 1.0 && Div >= 1.0));\r
71                 Log(" %.4f", Score);\r
72                 Log(" LY %u LN %u LA %u", CS_LY, CS_LN, CS_LA);\r
73                 Log(" RY %u RN %u RA %u", CS_RY, CS_RN, CS_RA);\r
74                 Log(" Div %.1f%%", Div);\r
75                 Log(" Q=%s", QLabel.c_str());\r
76                 Log(" A=%s", ALabel.c_str());\r
77                 Log(" B=%s", BLabel.c_str());\r
78                 Log(" QA %.1f%% QB=%.1f%% AB=%.1f%% QM=%.1f%%", PctIdQA, PctIdQB, PctIdAB, PctIdQM);\r
79                 Log("\n");\r
80                 }\r
81 \r
82         bool operator<(const ChimeHit2 &rhs) const\r
83                 {\r
84                 if (Score == rhs.Score)\r
85                         return Div > rhs.Div;\r
86                 return Score > rhs.Score;\r
87                 }\r
88         };\r
89 \r
90 static inline bool isacgt(char c)\r
91         {\r
92         return c == 'A' || c == 'C' || c == 'G' || c == 'T';\r
93         }\r
94 \r
95 static bool inline isgap(char c)\r
96         {\r
97         return c == '-' || c == '.';\r
98         }\r
99 \r
100 void GetChunkInfo(unsigned L, unsigned &Length, vector<unsigned> &Los);\r
101 float GetAbFromLabel(const string &Label);\r
102 void WriteChimeHitCS(FILE *f, const ChimeHit2 &Hit);\r
103 void WriteChimeHit(FILE *f, const ChimeHit2 &Hit);\r
104 void WriteChimeFileHdr(FILE *f);\r
105 \r
106 #endif // chime_h\r