Next version of JABA
[jabaws.git] / binaries / src / mafft / extensions / mxscarna_src / StemCandidate.hpp
1 /////////////////////////////////////////////////////////////
2 // StemCandidate.hpp
3 // Profile Stem Candidate calcurated by profile base pairing
4 // probability matrix 
5 ////////////////////////////////////////////////////////////
6
7 #ifndef __STEMCANDIDATE_HPP__
8 #define __STEMCANDIDATE_HPP__
9
10 #include <string>
11 #include <vector>
12
13 using namespace std;
14
15 namespace MXSCARNA {
16 class StemCandidate {
17 private:
18     int numSeq;                      /* the number of sequences in the profile */
19     int length;                      /* length of profile stem candidate of fixed length */
20     int position;                    /* 5' start position of SC in profile */
21     int distance;
22     std::vector<std::string> substr; /* profile base string of SC */
23     std::vector<std::string> rvstr;  /* profile base string of stem partner of SC */
24     int rvposition;                  /* 3' end position of stem partner of SC */
25     int rvscnumber;                  /* SC number of stem partner */
26     int contPos;                     /* previous stem that corresponds continuous stem and has position -1. */
27     int beforePos;                   /* most recent stem that doesn't overlap to SC and has position -len. */
28     float score;                     /* score of the sum of base pairing probability matrix */
29     std::vector<float> baseScore;
30     float stacking;                  /* the mean of stacking energy */
31     float stemStacking;              /* the mean of 1-continuous stacking energy */
32
33 public:
34     StemCandidate() : numSeq(0), length(0), position(0), distance(0), 
35                       rvposition(0), rvscnumber(0), contPos(-1), beforePos(0),
36                       score(0), stacking(0), stemStacking(0) {}
37     StemCandidate(int numSeq, int length) : numSeq(numSeq), length(length), 
38                                             substr(numSeq), rvstr(numSeq), 
39                                             contPos(-1) { }
40
41     void SetNumSeq(int num) { numSeq = num; }
42     void SetLength(int len) { length = len; }
43     void SetNumSubstr(int num) {
44         substr.resize(num);
45         for(int i = 0; i < num; i++) {
46             string &tmpStr = substr[i];
47             tmpStr = "";
48             substr[i] = tmpStr;
49         }
50     }
51     void SetNumRvstr(int num) {
52         rvstr.resize(num);
53         
54         for(int i = 0; i < num; i++) {
55             string &tmpStr = rvstr[i];
56             tmpStr = "";
57             rvstr[i] = tmpStr;
58         }
59     }
60     void SetPosition(int pos) { position = pos; }
61
62     void AddSubstr(int num, char word) {
63         std::string &tmpStr = substr[num];
64         tmpStr += word;
65         substr[num] = tmpStr;
66     }
67
68     void AddRvstr(int num, char word) {
69         std::string &tmpStr = rvstr[num];
70         tmpStr += word;
71         rvstr[num] = tmpStr;
72     }
73
74     void AddBaseScore(float score) {
75         baseScore.push_back(score);
76     }
77
78     void SetRvposition(int pos) { rvposition = pos; }
79     void SetRvscnumber(int num) { rvscnumber = num; }
80     void SetContPos(int pos) { contPos = pos; }
81     void SetBeforePos(int pos) { beforePos = pos; }
82     void SetDistance(int d) { distance = d; }
83     void SetScore(float s) { score = s; }
84     void AddScore(float s) { score += s; }
85     void SetStacking(float s) { stacking = s; }
86     void AddStacking(float s) { stacking += s; }
87     void SetStemStacking(float s) { stemStacking = s; }
88     int  GetNumSeq() const { return numSeq; }
89     int  GetLength() const { return length; }
90     int  GetPosition() const { return position; }
91     
92     string GetSubstr(int num) const { 
93         const std::string &tmpStr = substr[num];
94         return tmpStr;
95     }
96     string GetRvstr(int num) const {
97         const std::string &tmpStr = rvstr[num];
98         return tmpStr;
99     }
100     float GetBaseScore(int i) const  {
101         return baseScore[i];
102     }
103     int GetRvposition() const {
104         return rvposition;
105     }
106     int GetRvscnumber() const {
107         return rvscnumber;
108     }
109     int GetContPos() const {
110         return contPos;
111     }
112     int GetBeforePos() const {
113         return beforePos;
114     }
115     int GetDistance() const {
116         return distance;
117     }
118     float GetScore() const {
119         return score;
120     }
121     float GetStacking() const  {
122         return stacking;
123     }
124     float GetStemStacking() const {
125         return stemStacking;
126     }
127 };
128 }
129 #endif // __STEMCANDIDATE_HPP__