| 1 | #ifndef FastProf2_h |
|---|
| 2 | #define FastProf2_h |
|---|
| 3 | |
|---|
| 4 | #include "msa.h" |
|---|
| 5 | #include "pwpath.h" |
|---|
| 6 | #include <math.h> // for log function |
|---|
| 7 | |
|---|
| 8 | class DiagList; |
|---|
| 9 | class WeightList; |
|---|
| 10 | |
|---|
| 11 | struct ProfPos |
|---|
| 12 | { |
|---|
| 13 | bool m_bAllGaps; |
|---|
| 14 | unsigned m_uSortOrder[21]; |
|---|
| 15 | FCOUNT m_fcCounts[20]; |
|---|
| 16 | FCOUNT m_LL; |
|---|
| 17 | FCOUNT m_LG; |
|---|
| 18 | FCOUNT m_GL; |
|---|
| 19 | FCOUNT m_GG; |
|---|
| 20 | SCORE m_AAScores[20]; |
|---|
| 21 | unsigned m_uResidueGroup; |
|---|
| 22 | FCOUNT m_fOcc; |
|---|
| 23 | FCOUNT m_fcStartOcc; |
|---|
| 24 | FCOUNT m_fcEndOcc; |
|---|
| 25 | SCORE m_scoreGapOpen; |
|---|
| 26 | SCORE m_scoreGapClose; |
|---|
| 27 | #if DOUBLE_AFFINE |
|---|
| 28 | SCORE m_scoreGapOpen2; |
|---|
| 29 | SCORE m_scoreGapClose2; |
|---|
| 30 | #endif |
|---|
| 31 | // SCORE m_scoreGapExtend; |
|---|
| 32 | }; |
|---|
| 33 | |
|---|
| 34 | struct ProgNode |
|---|
| 35 | { |
|---|
| 36 | ProgNode() |
|---|
| 37 | { |
|---|
| 38 | m_Prof = 0; |
|---|
| 39 | m_EstringL = 0; |
|---|
| 40 | m_EstringR = 0; |
|---|
| 41 | } |
|---|
| 42 | MSA m_MSA; |
|---|
| 43 | ProfPos *m_Prof; |
|---|
| 44 | PWPath m_Path; |
|---|
| 45 | short *m_EstringL; |
|---|
| 46 | short *m_EstringR; |
|---|
| 47 | unsigned m_uLength; |
|---|
| 48 | WEIGHT m_Weight; |
|---|
| 49 | }; |
|---|
| 50 | |
|---|
| 51 | extern unsigned ResidueGroup[]; |
|---|
| 52 | const unsigned RESIDUE_GROUP_MULTIPLE = (unsigned) ~0; |
|---|
| 53 | |
|---|
| 54 | extern PTR_SCOREMATRIX g_ptrScoreMatrix; |
|---|
| 55 | |
|---|
| 56 | ProfPos *ProfileFromMSA(const MSA &a); |
|---|
| 57 | |
|---|
| 58 | SCORE TraceBack(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 59 | unsigned uLengthB, const SCORE *DPM_, const SCORE *DPD_, const SCORE *DPI_, |
|---|
| 60 | PWPath &Path); |
|---|
| 61 | SCORE GlobalAlign(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB, |
|---|
| 62 | unsigned uLengthB, PWPath &Path); |
|---|
| 63 | void ProgressiveAlign(const SeqVect &v, const Tree &tree, MSA &a); |
|---|
| 64 | SCORE MSAPairSP(const MSA &msa1, const MSA &msa2); |
|---|
| 65 | |
|---|
| 66 | void AlignTwoMSAsGivenPath(const PWPath &Path, const MSA &msaA, const MSA &msaB, |
|---|
| 67 | MSA &msaCombined); |
|---|
| 68 | |
|---|
| 69 | void ListProfile(const ProfPos *Prof, unsigned uLength, const MSA *ptrMSA = 0); |
|---|
| 70 | SCORE ScoreProfPos2(const ProfPos &PPA, const ProfPos &PPB); |
|---|
| 71 | SCORE FastScorePath2(const ProfPos *PA, unsigned uLengthA, |
|---|
| 72 | const ProfPos *PB, unsigned uLengthB, const PWPath &Path); |
|---|
| 73 | bool IsHydrophilic(const FCOUNT fcCounts[]); |
|---|
| 74 | int PAM200_Letter(unsigned uLetter1, unsigned uLetter2); |
|---|
| 75 | SCORE AverageMatchScore(const PWPath &Path, unsigned uEdgeIndex, |
|---|
| 76 | unsigned uWindowLength); |
|---|
| 77 | void WindowSmooth(const SCORE Score[], unsigned uCount, unsigned uWindowLength, |
|---|
| 78 | SCORE SmoothScore[], double dCeil = 9e29); |
|---|
| 79 | SCORE FastScoreMSA_LA(const MSA &msa, SCORE MatchScore[] = 0); |
|---|
| 80 | SCORE FastScoreMSA_NS(const MSA &msa, SCORE MatchScore[] = 0); |
|---|
| 81 | SCORE FastScoreMSA_SP(const MSA &msa, SCORE MatchScore[] = 0); |
|---|
| 82 | bool RefineMSA(MSA &msa, const Tree &tree); |
|---|
| 83 | SCORE MSAQScore(const MSA &msa, SCORE MatchScore[] = 0); |
|---|
| 84 | bool RefineBiParts(MSA &msa, const Tree &tree, bool R); |
|---|
| 85 | void FindAnchorCols(const MSA &msa, unsigned AnchorCols[], |
|---|
| 86 | unsigned *ptruAnchorColCount); |
|---|
| 87 | double PctIdToHeight(double dPctId); |
|---|
| 88 | double PctIdToHeightKimura(double dPctId); |
|---|
| 89 | double PctIdToHeightMAFFT(double dPctId); |
|---|
| 90 | double PctIdToMAFFTDist(double dPctId); |
|---|
| 91 | bool RefineBlocks(MSA &msa, const Tree &tree); |
|---|
| 92 | bool RefineSubfams(MSA &msaIn, const Tree &tree, unsigned uIters); |
|---|
| 93 | void SetMuscleTree(const Tree &tree); |
|---|
| 94 | void CalcClustalWWeights(const Tree &tree, WEIGHT Weights[]); |
|---|
| 95 | void RealignDiffs(const MSA &msaIn, const Tree &Diffs, |
|---|
| 96 | const unsigned IdToDiffsTreeNodeIndex[], MSA &msaOut); |
|---|
| 97 | void RealignDiffsE(const MSA &msaIn, const SeqVect &v, |
|---|
| 98 | const Tree &NewTree, const Tree &OldTree, |
|---|
| 99 | const unsigned uNewNodeIndexToOldNodeIndex[], |
|---|
| 100 | MSA &msaOut, ProgNode *OldProgNodes); |
|---|
| 101 | void RefineTree(MSA &msa, Tree &tree); |
|---|
| 102 | void RefineTreeE(MSA &msa, const SeqVect &v, Tree &tree, ProgNode *ProgNodes); |
|---|
| 103 | bool IsHydrophobic(const FCOUNT fcCounts[]); |
|---|
| 104 | void Hydro(ProfPos *Prof, unsigned uLength); |
|---|
| 105 | void SetTermGaps(const ProfPos *Prof, unsigned uLength); |
|---|
| 106 | |
|---|
| 107 | // Macros to simulate 2D matrices |
|---|
| 108 | #define DPL(PLA, PLB) DPL_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 109 | #define DPM(PLA, PLB) DPM_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 110 | #define DPD(PLA, PLB) DPD_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 111 | #define DPE(PLA, PLB) DPE_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 112 | #define DPI(PLA, PLB) DPI_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 113 | #define DPJ(PLA, PLB) DPJ_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 114 | #define DPU(PLA, PLB) DPU_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 115 | #define TBM(PLA, PLB) TBM_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 116 | #define TBD(PLA, PLB) TBD_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 117 | #define TBE(PLA, PLB) TBE_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 118 | #define TBI(PLA, PLB) TBI_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 119 | #define TBJ(PLA, PLB) TBJ_[(PLB)*uPrefixCountA + (PLA)] |
|---|
| 120 | |
|---|
| 121 | SCORE ScoreProfPos2LA(const ProfPos &PPA, const ProfPos &PPB); |
|---|
| 122 | SCORE ScoreProfPos2NS(const ProfPos &PPA, const ProfPos &PPB); |
|---|
| 123 | SCORE ScoreProfPos2SP(const ProfPos &PPA, const ProfPos &PPB); |
|---|
| 124 | SCORE ScoreProfPos2SPN(const ProfPos &PPA, const ProfPos &PPB); |
|---|
| 125 | |
|---|
| 126 | #endif // FastProf_h |
|---|