1 | //////////////////////////////////////////////////////////////// |
---|
2 | // Globaldp.hpp |
---|
3 | // Global Alignment of two profile computed by SCARNA algorithm |
---|
4 | //////////////////////////////////////////////////////////////// |
---|
5 | |
---|
6 | |
---|
7 | #ifndef __GLOBALDP_HPP__ |
---|
8 | #define __GLOBALDP_HPP__ |
---|
9 | |
---|
10 | #include <string> |
---|
11 | #include <iostream> |
---|
12 | #include "nrutil.h" |
---|
13 | #include "Util.hpp" |
---|
14 | #include "Beta.hpp" |
---|
15 | #include "scarna.hpp" |
---|
16 | #include "StemCandidate.hpp" |
---|
17 | #include "MultiSequence.h" |
---|
18 | #include "Sequence.h" |
---|
19 | #include "BPPMatrix.hpp" |
---|
20 | |
---|
21 | using namespace ProbCons; |
---|
22 | using namespace std; |
---|
23 | namespace MXSCARNA { |
---|
24 | |
---|
25 | typedef std::vector<StemCandidate> stemcandidate; |
---|
26 | class Globaldp { |
---|
27 | private: |
---|
28 | static double ribosum_matrix[16][16]; |
---|
29 | |
---|
30 | NRMat<float> VM, VG; |
---|
31 | NRMat<int> traceMI, traceMJ, traceGI, traceGJ; |
---|
32 | |
---|
33 | const stemcandidate *pscs1, *pscs2; |
---|
34 | const MultiSequence *seqs1, *seqs2; |
---|
35 | std::vector<int> *matchPSCS1, *matchPSCS2; |
---|
36 | SafeVector<BPPMatrix*> &BPPMatrices; |
---|
37 | NRMat<float> posterior; |
---|
38 | NRMat3d<int> countConp1, countConp2; |
---|
39 | NRMat<int> countContConp1, countContConp2; |
---|
40 | Trimat<float> *profileBPPMat1; |
---|
41 | Trimat<float> *profileBPPMat2; |
---|
42 | float multiDeltaScore; |
---|
43 | float multiDeltaStacking; |
---|
44 | float multiScore; |
---|
45 | float multiStacking; |
---|
46 | float multiPenalty; |
---|
47 | |
---|
48 | float scorePSCPair(const StemCandidate &sc1, const StemCandidate &sc2); |
---|
49 | float wordSimilarity(const StemCandidate &sc1, const StemCandidate &sc2, int i, int j); |
---|
50 | int returnBasePairType(char s, char r); |
---|
51 | float probabilityScore(const StemCandidate &sc1, const StemCandidate &sc2); |
---|
52 | float stackingScore(const StemCandidate &sc1, const StemCandidate &sc2); |
---|
53 | float distancePenalty(const StemCandidate &sc1, const StemCandidate &sc2); |
---|
54 | float incrementalScorePSCPair(const StemCandidate &sc1, const StemCandidate &sc2); |
---|
55 | float incrementalProbabilityScore(const StemCandidate &sc1, const StemCandidate &sc2); |
---|
56 | float incrementalStackingScore(const StemCandidate &sc1, const StemCandidate &sc2); |
---|
57 | float incrementalWordSimilarity(const StemCandidate &sc1, const StemCandidate &sc2, int i, int j); |
---|
58 | Trimat<float>* makeProfileBPPMatrix(const MultiSequence *Sequences); |
---|
59 | |
---|
60 | void Initialize(); |
---|
61 | void DP(); |
---|
62 | float traceBack(); |
---|
63 | void printMatch(); |
---|
64 | public: |
---|
65 | |
---|
66 | Globaldp(const stemcandidate *mypscs1, const stemcandidate *mypscs2, |
---|
67 | const MultiSequence *myseqs1, const MultiSequence *myseqs2, |
---|
68 | std::vector<int> *matchPSCS1, std::vector<int> *matchPSCS2, |
---|
69 | VF *myPosterior, SafeVector<BPPMatrix*> &myBPPMatrices, |
---|
70 | float myMultiDeltaScore = MULTIDELTASCORE, float myMultiDeltaStacking = MULTIDELTASTACKING, |
---|
71 | float myMultiScore = MULTISCORE, float myMultiStacking = MULTISTACKING, |
---|
72 | float myMultiPenalty = MULTIPENALTY) |
---|
73 | : VM(mypscs1->size(), mypscs2->size()), |
---|
74 | VG(mypscs1->size(), mypscs2->size()), |
---|
75 | traceMI(mypscs1->size(), mypscs2->size()), |
---|
76 | traceMJ(mypscs1->size(), mypscs2->size()), |
---|
77 | traceGI(mypscs1->size(), mypscs2->size()), |
---|
78 | traceGJ(mypscs1->size(), mypscs2->size()), |
---|
79 | pscs1(mypscs1), pscs2(mypscs2), |
---|
80 | seqs1(myseqs1), seqs2(myseqs2), |
---|
81 | matchPSCS1(matchPSCS1), matchPSCS2(matchPSCS2), |
---|
82 | BPPMatrices(myBPPMatrices), posterior(myseqs1->GetSequence(0)->GetLength() + 1, myseqs2->GetSequence(0)->GetLength() + 1), |
---|
83 | countConp1(WORDLENGTH, 17, mypscs1->size()+1), countConp2(WORDLENGTH, 17, mypscs2->size()+1), |
---|
84 | countContConp1(0, 17, mypscs1->size()+1), countContConp2(0, 17, mypscs2->size()+1), |
---|
85 | multiDeltaScore(myMultiDeltaScore), multiDeltaStacking(myMultiDeltaStacking), |
---|
86 | multiScore(myMultiScore), multiStacking(myMultiStacking), |
---|
87 | multiPenalty(myMultiPenalty) { |
---|
88 | |
---|
89 | VF::iterator myPosteriorPtr = myPosterior->begin(); |
---|
90 | for (int i = 0; i <= seqs1->GetSequence(0)->GetLength(); i++) { |
---|
91 | for (int j = 0; j <= seqs2->GetSequence(0)->GetLength(); j++) { |
---|
92 | posterior[i][j] = (*myPosteriorPtr)/(seqs1->GetSequence(0)->GetLength()*seqs2->GetSequence(0)->GetLength()); |
---|
93 | myPosteriorPtr++; |
---|
94 | } |
---|
95 | } |
---|
96 | } |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | float Run(); |
---|
101 | |
---|
102 | void setMultiDeltaScore(float score) { multiDeltaScore = score; } |
---|
103 | void setMultiDeltaStacking(float score) { multiDeltaStacking = score; } |
---|
104 | void setMultiScore(float score) { multiScore = score; } |
---|
105 | void setMultiStacking(float score) { multiStacking = score; } |
---|
106 | void setMultiPenalty(float score) { multiPenalty = score; } |
---|
107 | }; |
---|
108 | } |
---|
109 | #endif // __GLOBALDP_HPP__ |
---|