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 
35 struct ProgNode
36 	{
ProgNodeProgNode37 	ProgNode()
38 		{
39 		m_Prof = 0;
40 		m_EstringL = 0;
41 		m_EstringR = 0;
42         m_Prof = 0;
43 		}
~ProgNodeProgNode44     ~ProgNode(){
45         delete[] m_EstringL;
46         delete[] m_EstringR;
47         delete[] m_Prof;
48     }
49 	MSA m_MSA;
50 	ProfPos *m_Prof;
51 	PWPath m_Path;
52     int *m_EstringL;
53     int *m_EstringR;
54 	unsigned m_uLength;
55 	WEIGHT m_Weight;
56 	};
57 
58 extern unsigned ResidueGroup[];
59 
60 const unsigned RESIDUE_GROUP_MULTIPLE = (unsigned) ~0;
61 
62 ProfPos *ProfileFromMSA(const MSA &a);
63 
64 SCORE TraceBack(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB,
65   unsigned uLengthB, const SCORE *DPM_, const SCORE *DPD_, const SCORE *DPI_,
66   PWPath &Path);
67 SCORE GlobalAlign(const ProfPos *PA, unsigned uLengthA, const ProfPos *PB,
68   unsigned uLengthB, PWPath &Path);
69 void ProgressiveAlign(const SeqVect &v, const Tree &tree, MSA &a);
70 SCORE MSAPairSP(const MSA &msa1, const MSA &msa2);
71 
72 void AlignTwoMSAsGivenPath(const PWPath &Path, const MSA &msaA, const MSA &msaB,
73   MSA &msaCombined);
74 
75 void ListProfile(const ProfPos *Prof, unsigned uLength, const MSA *ptrMSA = 0);
76 SCORE ScoreProfPos2(const ProfPos &PPA, const ProfPos &PPB, MuscleContext* ctx);
77 
78 SCORE FastScorePath2(const ProfPos *PA, unsigned uLengthA,
79   const ProfPos *PB, unsigned uLengthB, const PWPath &Path);
80 bool IsHydrophilic(const FCOUNT fcCounts[]);
81 int PAM200_Letter(unsigned uLetter1, unsigned uLetter2);
82 SCORE AverageMatchScore(const PWPath &Path, unsigned uEdgeIndex,
83   unsigned uWindowLength);
84 void WindowSmooth(const SCORE Score[], unsigned uCount, unsigned uWindowLength,
85   SCORE SmoothScore[], double dCeil = 9e29);
86 SCORE FastScoreMSA_LA(const MSA &msa, SCORE MatchScore[] = 0);
87 SCORE FastScoreMSA_NS(const MSA &msa, SCORE MatchScore[] = 0);
88 SCORE FastScoreMSA_SP(const MSA &msa, SCORE MatchScore[] = 0);
89 bool RefineMSA(MSA &msa, const Tree &tree);
90 SCORE MSAQScore(const MSA &msa, SCORE MatchScore[] = 0);
91 bool RefineBiParts(MSA &msa, const Tree &tree, bool R);
92 void FindAnchorCols(const MSA &msa, unsigned AnchorCols[],
93   unsigned *ptruAnchorColCount);
94 double PctIdToHeight(double dPctId);
95 double PctIdToHeightKimura(double dPctId);
96 double PctIdToHeightMAFFT(double dPctId);
97 double PctIdToMAFFTDist(double dPctId);
98 bool RefineBlocks(MSA &msa, const Tree &tree);
99 bool RefineSubfams(MSA &msaIn, const Tree &tree, unsigned uIters);
100 void SetMuscleTree(const Tree &tree);
101 void CalcClustalWWeights(const Tree &tree, WEIGHT Weights[]);
102 void RealignDiffs(const MSA &msaIn, const Tree &Diffs,
103   const unsigned IdToDiffsTreeNodeIndex[], MSA &msaOut);
104 void RealignDiffsE(const MSA &msaIn, const SeqVect &v,
105   const Tree &NewTree, const Tree &OldTree,
106   const unsigned uNewNodeIndexToOldNodeIndex[],
107   MSA &msaOut, ProgNode *OldProgNodes);
108 void RefineTree(MSA &msa, Tree &tree);
109 void RefineTreeE(MSA &msa, const SeqVect &v, Tree &tree, ProgNode *ProgNodes);
110 bool IsHydrophobic(const FCOUNT fcCounts[]);
111 void Hydro(ProfPos *Prof, unsigned uLength);
112 void SetTermGaps(const ProfPos *Prof, unsigned uLength);
113 
114 // Macros to simulate 2D matrices
115 #define DPL(PLA, PLB)	DPL_[(PLB)*uPrefixCountA + (PLA)]
116 #define DPM(PLA, PLB)	DPM_[(PLB)*uPrefixCountA + (PLA)]
117 #define DPD(PLA, PLB)	DPD_[(PLB)*uPrefixCountA + (PLA)]
118 #define DPE(PLA, PLB)	DPE_[(PLB)*uPrefixCountA + (PLA)]
119 #define DPI(PLA, PLB)	DPI_[(PLB)*uPrefixCountA + (PLA)]
120 #define DPJ(PLA, PLB)	DPJ_[(PLB)*uPrefixCountA + (PLA)]
121 #define DPU(PLA, PLB)	DPU_[(PLB)*uPrefixCountA + (PLA)]
122 #define TBM(PLA, PLB)	TBM_[(PLB)*uPrefixCountA + (PLA)]
123 #define TBD(PLA, PLB)	TBD_[(PLB)*uPrefixCountA + (PLA)]
124 #define TBE(PLA, PLB)	TBE_[(PLB)*uPrefixCountA + (PLA)]
125 #define TBI(PLA, PLB)	TBI_[(PLB)*uPrefixCountA + (PLA)]
126 #define TBJ(PLA, PLB)	TBJ_[(PLB)*uPrefixCountA + (PLA)]
127 
128 SCORE ScoreProfPos2LA(const ProfPos &PPA, const ProfPos &PPB, MuscleContext* ctx);
129 SCORE ScoreProfPos2NS(const ProfPos &PPA, const ProfPos &PPB, MuscleContext* ctx);
130 SCORE ScoreProfPos2SP(const ProfPos &PPA, const ProfPos &PPB, MuscleContext* ctx);
131 SCORE ScoreProfPos2SPN(const ProfPos &PPA, const ProfPos &PPB, MuscleContext* ctx);
132 
133 #endif // FastProf_h
134