Motif.h
2.23 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
#ifndef MOTIF_H_
#define MOTIF_H_
#include <mutex>
#include <string>
#include <vector>
using std::pair;
using std::string;
using std::vector;
class Motif; // forward declaration
typedef struct args_ {
const string& descfile;
string rna;
vector<Motif>& final_results;
std::mutex& posInsertionSites_mutex;
args_(const string& descfile_, string rna_, vector<Motif>& vector_, std::mutex& mutex_) : descfile(descfile_), rna(rna_), final_results(vector_), posInsertionSites_mutex(mutex_){}
} args_of_parallel_func;
typedef struct Comp_ {
pair<uint, uint> pos;
size_t k;
string seq_;
Comp_(pair<int, int> p) : pos(p) { k = 1 + pos.second - pos.first; }
Comp_(uint start, uint length) : k(length)
{
pos.first = start;
pos.second = start + length - 1;
}
} Component;
class Motif
{
public:
Motif();
Motif(const vector<Component>& v, string PDB);
void load_from_csv(string csv_line);
static void build_from_desc(args_of_parallel_func arg_struct);
static char is_valid_DESC(const string& descfile);
string pos_string(void) const;
string get_origin(void) const;
string get_identifier(void) const;
vector<Component> comp;
double score_;
bool reversed_;
private:
static vector<vector<Component>> find_next_ones_in(string rna, uint offset, vector<string> vc);
string atlas_id; // if source = RNAMOTIFATLAS
string PDBID; // if source = RNA3DMOTIF
bool is_model_; // Wether the motif is a model or an extracted module from a 3D structure
enum { RNA3DMOTIF = 1, RNAMOTIFATLAS = 2, CARNAVAL = 3 } source_;
};
bool is_desc_insertible(const string& descfile, const string& rna, bool verbose);
vector<Motif> load_desc_folder(const string& path, const string& rna, bool verbose);
vector<Motif> load_jar3d_output(const string& path);
// 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);
#endif // MOTIF_H_