SecondaryStructure.h
3.65 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
#ifndef __INC_IP_SOL__
#define __INC_IP_SOL__
#define IL_STD
#include "rna.h"
#include <ilconcert/ilomodel.h>
#include <ilcplex/ilocplex.h>
#include <iostream>
#include <string>
#include <vector>
using std::pair;
using std::string;
using std::vector;
typedef struct Comp_ {
pair<uint, uint> pos;
size_t k;
Comp_(pair<int, int> p) : pos(p) { k = 1 + pos.second - pos.first; }
} Component;
typedef struct {
string atlas_id;
vector<Component> comp;
bool reversed;
int score;
string pos_string(void) const
{
std::stringstream s;
s << atlas_id << " ( ";
for (auto c : comp) {
s << c.pos.first << '-' << c.pos.second << ' ';
}
s << ')';
return s.str();
}
} Motif;
class SecondaryStructure
{
public:
SecondaryStructure(void);
SecondaryStructure(const RNA& rna);
SecondaryStructure(bool empty);
void set_basepair(uint i, uint j);
void sort(void);
void insert_motif(const Motif& m);
double get_objective_score(int i) const;
void set_objective_score(int i, double s);
void set_pareto_set(uint k);
uint get_pareto_set(void) const;
uint get_n_motifs(void) const;
uint get_n_bp(void) const;
void print(void) const;
string to_DBN() const;
string to_string() const;
vector<double> objective_scores_; // values of the different objective functions for that SecondaryStructure
vector<pair<uint, uint>> basepairs_; // values of the decision variable of the integer program
vector<Motif> motif_info_; // information about known motives in this secondary structure and their positions
size_t n_; // length of the RNA
size_t nBP_; // number of basepairs
uint k_; // Secondary Structure belongs to the kth Pareto set
RNA rna_; // RNA object which is folded
bool is_empty_structure; // Empty structure, returned when the solver does not find solutions anymore
IloConstraint forbid_this_; // Add it to a cplex model to forbid that solution
};
// return if this SecondaryStructure s1 dominates s2
bool operator>(const SecondaryStructure& s1, const SecondaryStructure& s2);
bool operator>=(const SecondaryStructure& s1, const SecondaryStructure& s2);
// return if this SecondaryStructure s2 dominates s1
bool operator<(const SecondaryStructure& s1, const SecondaryStructure& s2);
bool operator<=(const SecondaryStructure& s1, const SecondaryStructure& s2);
// return wether SecondaryStructures are identical or not
bool operator==(const SecondaryStructure& s1, const SecondaryStructure& s2);
bool operator!=(const SecondaryStructure& s1, const SecondaryStructure& s2);
// utilities to compare secondary structures:
bool operator==(const Motif& m1, const Motif& m2);
bool operator!=(const Motif& m1, const Motif& m2);
bool operator==(const Component& c1, const Component& c2);
bool operator!=(const Component& c1, const Component& c2);
bool motif_sorter(Motif& m1, Motif& m2);
bool basepair_sorter(pair<uint, uint>& i, pair<uint, uint>& j);
inline double SecondaryStructure::get_objective_score(int i) const { return objective_scores_[i - 1]; }
inline void SecondaryStructure::set_objective_score(int i, double s) { objective_scores_[i - 1] = s; }
inline uint SecondaryStructure::get_n_motifs(void) const { return motif_info_.size(); }
inline uint SecondaryStructure::get_n_bp(void) const { return nBP_; }
inline uint SecondaryStructure::get_pareto_set(void) const { return k_; }
inline void SecondaryStructure::set_pareto_set(uint k) { k_ = k; }
#endif