1 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
2 | // postProcessings.cpp |
---|
3 | // |
---|
4 | // several post process functions after aligning two profile stem candidate sequences |
---|
5 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
6 | |
---|
7 | #include <iostream> |
---|
8 | #include "scarna.hpp" |
---|
9 | #include "StemCandidate.hpp" |
---|
10 | #include <vector> |
---|
11 | #include <string> |
---|
12 | |
---|
13 | using namespace::MXSCARNA; |
---|
14 | |
---|
15 | void printStructure(std::vector<StemCandidate> *pscs1, std::vector<StemCandidate> *pscs2, std::vector<int> *matchPSCS1, std::vector<int> *matchPSCS2); |
---|
16 | |
---|
17 | void removeConflicts(std::vector<StemCandidate> *pscs1, std::vector<StemCandidate> *pscs2, std::vector<int> *matchPSCS1, std::vector<int> *matchPSCS2) |
---|
18 | { |
---|
19 | int size = matchPSCS1->size(); |
---|
20 | |
---|
21 | std::vector<int> found(size, 0); |
---|
22 | for(int k = size - 1; k >= 0; k--) { |
---|
23 | int i = matchPSCS1->at(k); |
---|
24 | int i_rv = pscs1->at(i).GetRvscnumber(); |
---|
25 | int j = matchPSCS2->at(k); |
---|
26 | int j_rv = pscs2->at(j).GetRvscnumber(); |
---|
27 | |
---|
28 | found[k] = 0; |
---|
29 | |
---|
30 | for(int m = size - 1; m >= 0; m--) { |
---|
31 | if ( (matchPSCS1->at(m) == i_rv) && (matchPSCS2->at(m) == j_rv) ) { |
---|
32 | found[k] = 1; |
---|
33 | break; |
---|
34 | } |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | int pt = 0; |
---|
39 | for(int k = 0; k < size; k++) { |
---|
40 | matchPSCS1->at(pt) = matchPSCS1->at(k); |
---|
41 | matchPSCS2->at(pt) = matchPSCS2->at(k); |
---|
42 | if(found[k] == 1) ++pt; |
---|
43 | } |
---|
44 | |
---|
45 | matchPSCS1->resize(pt); |
---|
46 | matchPSCS2->resize(pt); |
---|
47 | |
---|
48 | //printStructure (pscs1, pscs2, matchPSCS1, matchPSCS2); |
---|
49 | } |
---|
50 | |
---|
51 | void printStructure(std::vector<StemCandidate> *pscs1, std::vector<StemCandidate> *pscs2, std::vector<int> *matchPSCS1, std::vector<int> *matchPSCS2) |
---|
52 | { |
---|
53 | int size = matchPSCS1->size(); |
---|
54 | int len = WORDLENGTH; |
---|
55 | std::vector<char> structure1(100, '.'); |
---|
56 | std::vector<char> structure2(100, '.'); |
---|
57 | for(int k = 0; k < size; k++) { |
---|
58 | int i = matchPSCS1->at(k); |
---|
59 | int pos1 = pscs1->at(i).GetPosition(); |
---|
60 | int j = matchPSCS2->at(k); |
---|
61 | int pos2 = pscs2->at(j).GetPosition(); |
---|
62 | for(int l = 0; l < len; l++) { |
---|
63 | if(pscs1->at(i).GetDistance() > 0) { |
---|
64 | structure1[pos1 + l] = '('; |
---|
65 | } |
---|
66 | else { |
---|
67 | structure1[pos1 + l] = ')'; |
---|
68 | } |
---|
69 | |
---|
70 | if(pscs2->at(j).GetDistance() > 0) { |
---|
71 | structure2[pos2 + l] = '('; |
---|
72 | } |
---|
73 | else { |
---|
74 | structure2[pos2 + l] = ')'; |
---|
75 | } |
---|
76 | } |
---|
77 | /* |
---|
78 | std::cout << i << "\t" << pscs1->at(i).GetLength() << "\t" << pscs1->at(i).GetPosition() << "\t" << pscs1->at(i).GetRvposition() << "\t" << pscs1->at(i).GetDistance() << "\t" << pscs1->at(i).GetContPos() << "\t" << pscs1->at(i).GetBeforePos() << "\t" << pscs1->at(i).GetRvscnumber() << endl; |
---|
79 | */ |
---|
80 | } |
---|
81 | size = structure1.size(); |
---|
82 | for(int k = 0; k < size; k++) { |
---|
83 | std::cout << structure1[k]; |
---|
84 | } |
---|
85 | std::cout << endl; |
---|
86 | for(int k = 0; k < size; k++) { |
---|
87 | std::cout << structure2[k]; |
---|
88 | } |
---|
89 | std::cout << endl; |
---|
90 | } |
---|
91 | |
---|