1 | #include "muscle.h" |
---|
2 | #include "msa.h" |
---|
3 | #include "objscore.h" |
---|
4 | #include "profile.h" |
---|
5 | #include "timing.h" |
---|
6 | |
---|
7 | #if TIMING |
---|
8 | TICKS g_ticksObjScore = 0; |
---|
9 | #endif |
---|
10 | |
---|
11 | SCORE ObjScore(const MSA &msa, const unsigned SeqIndexes1[], |
---|
12 | unsigned uSeqCount1, const unsigned SeqIndexes2[], unsigned uSeqCount2) |
---|
13 | { |
---|
14 | #if TIMING |
---|
15 | TICKS t1 = GetClockTicks(); |
---|
16 | #endif |
---|
17 | const unsigned uSeqCount = msa.GetSeqCount(); |
---|
18 | |
---|
19 | OBJSCORE OS = g_ObjScore; |
---|
20 | if (g_ObjScore == OBJSCORE_SPM) |
---|
21 | { |
---|
22 | if (uSeqCount <= 100) |
---|
23 | OS = OBJSCORE_XP; |
---|
24 | else |
---|
25 | OS = OBJSCORE_SPF; |
---|
26 | } |
---|
27 | |
---|
28 | MSA msa1; |
---|
29 | MSA msa2; |
---|
30 | |
---|
31 | switch (OS) |
---|
32 | { |
---|
33 | case OBJSCORE_DP: |
---|
34 | case OBJSCORE_XP: |
---|
35 | MSAFromSeqSubset(msa, SeqIndexes1, uSeqCount1, msa1); |
---|
36 | MSAFromSeqSubset(msa, SeqIndexes2, uSeqCount2, msa2); |
---|
37 | |
---|
38 | SetMSAWeightsMuscle(msa1); |
---|
39 | SetMSAWeightsMuscle(msa2); |
---|
40 | break; |
---|
41 | |
---|
42 | case OBJSCORE_SP: |
---|
43 | case OBJSCORE_SPF: |
---|
44 | case OBJSCORE_PS: |
---|
45 | // Yuck -- casting away const (design flaw) |
---|
46 | SetMSAWeightsMuscle((MSA &) msa); |
---|
47 | break; |
---|
48 | } |
---|
49 | |
---|
50 | SCORE Score = 0; |
---|
51 | switch (OS) |
---|
52 | { |
---|
53 | case OBJSCORE_SP: |
---|
54 | Score = ObjScoreSP(msa); |
---|
55 | break; |
---|
56 | |
---|
57 | case OBJSCORE_DP: |
---|
58 | Score = ObjScoreDP(msa1, msa2); |
---|
59 | break; |
---|
60 | |
---|
61 | case OBJSCORE_XP: |
---|
62 | Score = ObjScoreXP(msa1, msa2); |
---|
63 | break; |
---|
64 | |
---|
65 | case OBJSCORE_PS: |
---|
66 | Score = ObjScorePS(msa); |
---|
67 | break; |
---|
68 | |
---|
69 | case OBJSCORE_SPF: |
---|
70 | Score = ObjScoreSPDimer(msa); |
---|
71 | break; |
---|
72 | |
---|
73 | default: |
---|
74 | Quit("Invalid g_ObjScore=%d", g_ObjScore); |
---|
75 | } |
---|
76 | #if TIMING |
---|
77 | TICKS t2 = GetClockTicks(); |
---|
78 | g_ticksObjScore += (t2 - t1); |
---|
79 | #endif |
---|
80 | return Score; |
---|
81 | } |
---|
82 | |
---|
83 | SCORE ObjScoreIds(const MSA &msa, const unsigned Ids1[], |
---|
84 | unsigned uCount1, const unsigned Ids2[], unsigned uCount2) |
---|
85 | { |
---|
86 | #if TIMING |
---|
87 | TICKS t1 = GetClockTicks(); |
---|
88 | #endif |
---|
89 | unsigned *SeqIndexes1 = new unsigned[uCount1]; |
---|
90 | unsigned *SeqIndexes2 = new unsigned[uCount2]; |
---|
91 | |
---|
92 | for (unsigned n = 0; n < uCount1; ++n) |
---|
93 | SeqIndexes1[n] = msa.GetSeqIndex(Ids1[n]); |
---|
94 | |
---|
95 | for (unsigned n = 0; n < uCount2; ++n) |
---|
96 | SeqIndexes2[n] = msa.GetSeqIndex(Ids2[n]); |
---|
97 | |
---|
98 | #if DOUBLE_AFFINE |
---|
99 | extern SCORE ObjScoreDA(const MSA &msa, SCORE *ptrLetters, SCORE *ptrGaps); |
---|
100 | SCORE Letters, Gaps; |
---|
101 | SCORE dObjScore = ObjScoreDA(msa, &Letters, &Gaps); |
---|
102 | |
---|
103 | delete[] SeqIndexes1; |
---|
104 | delete[] SeqIndexes2; |
---|
105 | #else |
---|
106 | SCORE dObjScore = ObjScore(msa, SeqIndexes1, uCount1, SeqIndexes2, uCount2); |
---|
107 | #endif |
---|
108 | #if TIMING |
---|
109 | TICKS t2 = GetClockTicks(); |
---|
110 | g_ticksObjScore += (t2 - t1); |
---|
111 | #endif |
---|
112 | return dObjScore; |
---|
113 | } |
---|