Next version of JABA
[jabaws.git] / binaries / src / muscle / msadist.h
1 #ifndef MSADist_h\r
2 #define MSADist_h\r
3 \r
4 #include <math.h>\r
5 \r
6 double GetScoreDist(const MSA &msa, unsigned SeqIndex1, unsigned SeqIndex2);\r
7 \r
8 class MSADist\r
9         {\r
10 public:\r
11         MSADist(DISTANCE Distance)\r
12                 {\r
13                 m_Distance = Distance;\r
14                 }\r
15 \r
16         double ComputeDist(const MSA &msa, unsigned uSeqIndex1, unsigned uSeqIndex2)\r
17                 {\r
18                 if (m_Distance == DISTANCE_ScoreDist)\r
19                         return GetScoreDist(msa, uSeqIndex1, uSeqIndex2);\r
20 \r
21                 double dPctId = msa.GetPctIdentityPair(uSeqIndex1, uSeqIndex2);\r
22                 switch(m_Distance)\r
23                         {\r
24                 case DISTANCE_PctIdKimura:\r
25                         return KimuraDist(dPctId);\r
26                 case DISTANCE_PctIdLog:\r
27                         if (dPctId < 0.05)\r
28                                 dPctId = 0.05;\r
29                         return -log(dPctId);\r
30                         }\r
31                 Quit("MSADist::ComputeDist, invalid DISTANCE_%u", m_Distance);\r
32                 return 0;\r
33                 }\r
34 \r
35 private:\r
36         DISTANCE m_Distance;\r
37         };\r
38 \r
39 #endif  // MSADist_h\r