1 | #include "muscle.h" |
---|
2 | #include "distfunc.h" |
---|
3 | #include "distcalc.h" |
---|
4 | #include "msa.h" |
---|
5 | |
---|
6 | void DistCalcDF::Init(const DistFunc &DF) |
---|
7 | { |
---|
8 | m_ptrDF = &DF; |
---|
9 | } |
---|
10 | |
---|
11 | void DistCalcDF::CalcDistRange(unsigned i, dist_t Dist[]) const |
---|
12 | { |
---|
13 | for (unsigned j = 0; j < i; ++j) |
---|
14 | Dist[j] = m_ptrDF->GetDist(i, j); |
---|
15 | } |
---|
16 | |
---|
17 | unsigned DistCalcDF::GetCount() const |
---|
18 | { |
---|
19 | return m_ptrDF->GetCount(); |
---|
20 | } |
---|
21 | |
---|
22 | unsigned DistCalcDF::GetId(unsigned i) const |
---|
23 | { |
---|
24 | return m_ptrDF->GetId(i); |
---|
25 | } |
---|
26 | |
---|
27 | const char *DistCalcDF::GetName(unsigned i) const |
---|
28 | { |
---|
29 | return m_ptrDF->GetName(i); |
---|
30 | } |
---|
31 | |
---|
32 | void DistCalcMSA::Init(const MSA &msa, DISTANCE Distance) |
---|
33 | { |
---|
34 | m_ptrMSA = &msa; |
---|
35 | m_Distance = Distance; |
---|
36 | } |
---|
37 | |
---|
38 | void DistCalcMSA::CalcDistRange(unsigned i, dist_t Dist[]) const |
---|
39 | { |
---|
40 | for (unsigned j = 0; j < i; ++j) |
---|
41 | { |
---|
42 | switch (m_Distance) |
---|
43 | { |
---|
44 | case DISTANCE_PctIdKimura: |
---|
45 | { |
---|
46 | const float PctId = (float) m_ptrMSA->GetPctIdentityPair(i, j); |
---|
47 | Dist[j] = (float) KimuraDist(PctId); |
---|
48 | break; |
---|
49 | } |
---|
50 | case DISTANCE_PctIdLog: |
---|
51 | { |
---|
52 | const float PctId = (float) m_ptrMSA->GetPctIdentityPair(i, j); |
---|
53 | Dist[j] = (float) PctIdToMAFFTDist(PctId); |
---|
54 | break; |
---|
55 | } |
---|
56 | case DISTANCE_ScoreDist: |
---|
57 | { |
---|
58 | double GetScoreDist(const MSA &msa, unsigned SeqIndex1, unsigned SeqIndex2); |
---|
59 | Dist[j] = (float) GetScoreDist(*m_ptrMSA, i, j); |
---|
60 | continue; |
---|
61 | } |
---|
62 | case DISTANCE_Edit: |
---|
63 | { |
---|
64 | const float PctId = (float) m_ptrMSA->GetPctIdentityPair(i, j); |
---|
65 | if (PctId > 1.0) |
---|
66 | Quit("Internal error, DISTANCE_Edit, pct id=%.3g", PctId); |
---|
67 | Dist[j] = (float) 1.0 - PctId; |
---|
68 | break; |
---|
69 | } |
---|
70 | default: |
---|
71 | Quit("DistCalcMSA: Invalid DISTANCE_%u", m_Distance); |
---|
72 | } |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | unsigned DistCalcMSA::GetCount() const |
---|
77 | { |
---|
78 | return m_ptrMSA->GetSeqCount(); |
---|
79 | } |
---|
80 | |
---|
81 | unsigned DistCalcMSA::GetId(unsigned i) const |
---|
82 | { |
---|
83 | return m_ptrMSA->GetSeqId(i); |
---|
84 | } |
---|
85 | |
---|
86 | const char *DistCalcMSA::GetName(unsigned i) const |
---|
87 | { |
---|
88 | return m_ptrMSA->GetSeqName(i); |
---|
89 | } |
---|