structure.h
5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#ifndef DEF_HSTR
#define DEF_HSTR
#include <utility>
#include "Motifs/motif.h"
// From RNAstructure
// New type defined to stock the motif helixs position of a secondary structure, its motif helix parent and its motif helix children
typedef struct helix{
std::pair<int,int> pos_start;
std::pair<int,int> pos_end;
helix *parent;
bool pseudo;
std::vector<helix*> child;
std::vector< helix * > crossingHelixs; //redundance in some other helixs DO NOT DELETE FROM HERE
} helix;
// From RNAstructure
// A stack useful for pseudoknot calculations. It stores intervals [i, j].
// An interval is pushed onto the stack with push(i', j') (which does NOT affect the members i or j)
// An interval is popped off the stack with pop(), which sets the members i and j.
struct IntervalStack {
std::vector<short> stack; unsigned short i, j; unsigned int pos; /** i and j are the Current values */
IntervalStack(int capacity = 8) : stack(capacity), pos(0) {}
void push(int i, int j) {
if (stack.size() < pos+2) stack.resize(pos+2); // ensure there is room for two more elements.
stack[pos++] = (short)i;
stack[pos++] = (short)j;
}
bool pop() {
if (pos==0) return false;
j = stack[--pos]; // pop in reverse order or push (j, then i)
i = stack[--pos];
return true;
}
};
class Structure
{
public:
Structure();
Structure (const int rna, const std::string &seq,
const std::vector < std::pair < unsigned int, unsigned int > > &listBp,
const int ct, const int nbCt, const int id, unsigned int energyModel, float energy,
const std::vector < float > &probingData, float lowerThresProbing, float upperThresProbing);
Structure(const Structure& that); //Copy
~Structure ();
int get_rna_() const;
std::string get_seq_() const;
float get_obj1_() const;
std::vector < std::pair < unsigned int, unsigned int > > get_listBp_() const;
int get_ct_() const;
float get_ic_() const;
int get_nbCt_() const;
int get_id_() const;
float get_probing_() const;
std::vector < Motif * > get_motifs_() const;
void set_obj1_(float obj1);
void set_id_(int id);
void set_nbCt_(int nbCt);
void set_ct_(int ct);
void set_ic_(float ic);
void set_probing_(float probing);
std::string convToDP() const;
std::string convToDP(char c1, std::vector<char> forbid, bool first) const;
std::string convToDPonly() const;
void getPseudoknotRanks(std::vector < uint > &ranks, std::vector < uint > basepr) const;
bool hasPseudoknots(const std::vector < int > &pairs) const;
void findPseudoknots(const std::vector < int > ¤tPairs,
std::vector < int > *pseudoknotPairs = NULL,
std::vector < int > *normalPairs = NULL) const;
std::string convToDPonly(char c1, std::vector<char> forbid, bool first) const;
std::string to_string() const;
std::string to_Json() const;
// int find_bp(std::pair< unsigned int, unsigned int > p) const;
// std::vector< unsigned int > find_bp_with_i(unsigned int i) const;
Structure& operator=(const Structure& that); //Copy assigment helix
bool operator<(const Structure &s);
bool operator<(const Structure &s) const;
bool operator>(const Structure &s);
bool operator>(const Structure &s) const;
bool operator<=(const Structure &s);
bool operator<=(const Structure &s) const;
bool operator>=(const Structure &s);
bool operator>=(const Structure &s) const;
bool operator==(const Structure &s);
bool operator==(const Structure &s) const;
static void makeListBp(std::string structureDP, std::vector < std::pair < unsigned int, unsigned int > > &listbp);
static bool checkStructure(std::string structure);
static bool checkListBp(std::string seq, std::vector < std::pair < unsigned int, unsigned int > > &listbp);
private:
void print(helix *tmp);
bool checkChildrenMulti(helix *child, helix *parent);
bool checkChildrenIntern(helix *child, helix *parent);
std::vector < Motif * > readTree(helix *tmp);
void freeHelixSS(helix *val);
void motifDetection();
std::string convToNUPACK() const;
void computeEnergyNUPACK();
void computeEnergyVienna();
void computeProbing(const std::vector < float > &probingData, float lowerThresProbing, float upperThresProbing);
int rna_;
std::string seq_;
float obj1_; //value of objective 1
std::vector < std::pair < unsigned int, unsigned int > > listBp_;
int ct_; // confidence Index of the complete Structure given in the structure file
float ic_; // confidence Index containing ct_ and the constraint from the constraint file, used for clique problem
unsigned int nbCt_; // Number of user constraint the solInteraction corresponds
float probing_; // probing data score
int id_; //id among the sub-optimal solution structure vector
std::vector < Motif * > motifs_;
};
#endif