Next version of JABA
[jabaws.git] / binaries / src / muscle / distpwkimura.cpp
1 #include "muscle.h"\r
2 #include "distfunc.h"\r
3 #include "msa.h"\r
4 #include "seqvect.h"\r
5 #include "pwpath.h"\r
6 \r
7 void DistPWKimura(const SeqVect &v, DistFunc &DF)\r
8         {\r
9         SEQWEIGHT SeqWeightSave = GetSeqWeightMethod();\r
10         SetSeqWeightMethod(SEQWEIGHT_Henikoff);\r
11 \r
12         const unsigned uSeqCount = v.Length();\r
13         DF.SetCount(uSeqCount);\r
14 \r
15         const unsigned uPairCount = (uSeqCount*(uSeqCount + 1))/2;\r
16         unsigned uCount = 0;\r
17         SetProgressDesc("PWKimura distance");\r
18         for (unsigned uSeqIndex1 = 0; uSeqIndex1 < uSeqCount; ++uSeqIndex1)\r
19                 {\r
20                 const Seq &s1 = v.GetSeq(uSeqIndex1);\r
21                 MSA msa1;\r
22                 msa1.FromSeq(s1);\r
23                 for (unsigned uSeqIndex2 = 0; uSeqIndex2 < uSeqIndex1; ++uSeqIndex2)\r
24                         {\r
25                         if (0 == uCount%20)\r
26                                 Progress(uCount, uPairCount);\r
27                         ++uCount;\r
28                         const Seq &s2 = v.GetSeq(uSeqIndex2);\r
29                         MSA msa2;\r
30                         msa2.FromSeq(s2);\r
31                 \r
32                         PWPath Path;\r
33                         MSA msaOut;\r
34                         AlignTwoMSAs(msa1, msa2, msaOut, Path, false, false);\r
35 \r
36                         double dPctId = msaOut.GetPctIdentityPair(0, 1);\r
37                         float f = (float) KimuraDist(dPctId);\r
38 \r
39                         DF.SetDist(uSeqIndex1, uSeqIndex2, f);\r
40                         }\r
41                 }\r
42         ProgressStepsDone();\r
43 \r
44         SetSeqWeightMethod(SeqWeightSave);\r
45         }\r