| 1 | #include "muscle.h" |
|---|
| 2 | #include "profile.h" |
|---|
| 3 | |
|---|
| 4 | char ConsensusChar(const ProfPos &PP) |
|---|
| 5 | { |
|---|
| 6 | unsigned uMostCommonLetter = 0; |
|---|
| 7 | FCOUNT fcMostCommon = PP.m_fcCounts[0]; |
|---|
| 8 | bool bMoreThanOneLetter = false; |
|---|
| 9 | bool bAnyLetter = false; |
|---|
| 10 | for (unsigned uLetter = 0; uLetter < g_AlphaSize; ++uLetter) |
|---|
| 11 | { |
|---|
| 12 | const FCOUNT fc = PP.m_fcCounts[uLetter]; |
|---|
| 13 | if (fc > 0) |
|---|
| 14 | { |
|---|
| 15 | if (bAnyLetter) |
|---|
| 16 | bMoreThanOneLetter = true; |
|---|
| 17 | bAnyLetter = true; |
|---|
| 18 | } |
|---|
| 19 | if (fc > fcMostCommon) |
|---|
| 20 | { |
|---|
| 21 | uMostCommonLetter = uLetter; |
|---|
| 22 | fcMostCommon = fc; |
|---|
| 23 | } |
|---|
| 24 | } |
|---|
| 25 | if (!bAnyLetter) |
|---|
| 26 | return '-'; |
|---|
| 27 | char c = LetterToChar(uMostCommonLetter); |
|---|
| 28 | if (bMoreThanOneLetter) |
|---|
| 29 | return UnalignChar(c); |
|---|
| 30 | return c; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | SCORE ScoreProfPos2LA(const ProfPos &PPA, const ProfPos &PPB) |
|---|
| 34 | { |
|---|
| 35 | SCORE Score = 0; |
|---|
| 36 | for (unsigned n = 0; n < 20; ++n) |
|---|
| 37 | { |
|---|
| 38 | const unsigned uLetter = PPA.m_uSortOrder[n]; |
|---|
| 39 | const FCOUNT fcLetter = PPA.m_fcCounts[uLetter]; |
|---|
| 40 | if (0 == fcLetter) |
|---|
| 41 | break; |
|---|
| 42 | Score += fcLetter*PPB.m_AAScores[uLetter]; |
|---|
| 43 | } |
|---|
| 44 | if (0 == Score) |
|---|
| 45 | return -2.5; |
|---|
| 46 | SCORE logScore = logf(Score); |
|---|
| 47 | return (SCORE) ((logScore - g_scoreCenter)*(PPA.m_fOcc * PPB.m_fOcc)); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | SCORE ScoreProfPos2NS(const ProfPos &PPA, const ProfPos &PPB) |
|---|
| 51 | { |
|---|
| 52 | SCORE Score = 0; |
|---|
| 53 | for (unsigned n = 0; n < 20; ++n) |
|---|
| 54 | { |
|---|
| 55 | const unsigned uLetter = PPA.m_uSortOrder[n]; |
|---|
| 56 | const FCOUNT fcLetter = PPA.m_fcCounts[uLetter]; |
|---|
| 57 | if (0 == fcLetter) |
|---|
| 58 | break; |
|---|
| 59 | Score += fcLetter*PPB.m_AAScores[uLetter]; |
|---|
| 60 | } |
|---|
| 61 | return Score - g_scoreCenter; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | SCORE ScoreProfPos2SP(const ProfPos &PPA, const ProfPos &PPB) |
|---|
| 65 | { |
|---|
| 66 | SCORE Score = 0; |
|---|
| 67 | for (unsigned n = 0; n < 20; ++n) |
|---|
| 68 | { |
|---|
| 69 | const unsigned uLetter = PPA.m_uSortOrder[n]; |
|---|
| 70 | const FCOUNT fcLetter = PPA.m_fcCounts[uLetter]; |
|---|
| 71 | if (0 == fcLetter) |
|---|
| 72 | break; |
|---|
| 73 | Score += fcLetter*PPB.m_AAScores[uLetter]; |
|---|
| 74 | } |
|---|
| 75 | return Score - g_scoreCenter; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | SCORE ScoreProfPos2SPN(const ProfPos &PPA, const ProfPos &PPB) |
|---|
| 79 | { |
|---|
| 80 | SCORE Score = 0; |
|---|
| 81 | for (unsigned n = 0; n < 4; ++n) |
|---|
| 82 | { |
|---|
| 83 | const unsigned uLetter = PPA.m_uSortOrder[n]; |
|---|
| 84 | const FCOUNT fcLetter = PPA.m_fcCounts[uLetter]; |
|---|
| 85 | if (0 == fcLetter) |
|---|
| 86 | break; |
|---|
| 87 | Score += fcLetter*PPB.m_AAScores[uLetter]; |
|---|
| 88 | } |
|---|
| 89 | return Score - g_scoreCenter; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | SCORE ScoreProfPos2(const ProfPos &PPA, const ProfPos &PPB) |
|---|
| 93 | { |
|---|
| 94 | if (PPSCORE_SP == g_PPScore) |
|---|
| 95 | return ScoreProfPos2NS(PPA, PPB); |
|---|
| 96 | else if (PPSCORE_LE == g_PPScore) |
|---|
| 97 | return ScoreProfPos2LA(PPA, PPB); |
|---|
| 98 | else if (PPSCORE_SV == g_PPScore) |
|---|
| 99 | return ScoreProfPos2SP(PPA, PPB); |
|---|
| 100 | else if (PPSCORE_SPN == g_PPScore) |
|---|
| 101 | return ScoreProfPos2SPN(PPA, PPB); |
|---|
| 102 | Quit("Invalid g_PPScore"); |
|---|
| 103 | return 0; |
|---|
| 104 | } |
|---|