feature.h
4.54 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
184
185
#ifndef FEATURE_H
#define FEATURE_H
#include <unordered_map>
#include <string>
#include "Importer/entry.h"
#include "multithread/callable.h"
#include "data/data_basic.h"
namespace feature{
class Feature : public data::Data_basic{
protected:
virtual void init(const Data_basic *db);
public:
static const std::string TYPE;
static const std::string ENTRY_TYPE;
Feature(std::string name):data::Data_basic(name){}
Feature(const data::Data_basic *db):data::Data_basic(db){this->init(db);}
virtual ~Feature(){}
virtual float dist(feature::Feature *a)=0;
std::string to_dict()=0;
std::string to_csv()=0;
virtual std::string getID(){
return this->TYPE;
}
virtual data::Data_basic *clone()=0;
std::string getEntry_name() const;
};
class SeqLength: public feature::Feature{
protected:
int l;
void init(const Data_basic *db);
public:
static const std::string TYPE;
static const std::string ENTRY_TYPE;
static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable();
int getL() const;
SeqLength(const entry::Sequence &s):
feature::Feature(s.getName()),l(s.getLength()){}
SeqLength(const std::string &name,const int &seql):
feature::Feature(name),l(seql){}
SeqLength(const data::Data_basic *db):feature::Feature(db){this->init(db);}
~SeqLength(){}
float dist(Feature *a);
data::Data_basic *clone();
std::string to_dict();
std::string to_csv();
std::string getID(){
return this->TYPE;
}
};
class Kmer: public feature::Feature{
protected:
unsigned int k;
std::unordered_map<std::string,float> kmer;
void init(const Data_basic *db);
public:
static const std::string TYPE;
static const std::string ENTRY_TYPE;
static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable(const unsigned int &k);
Kmer(entry::Sequence &s, const unsigned int &k);
Kmer(const std::string &name,
const unsigned int &k, const std::unordered_map<std::string,float> kmer):
feature::Feature(name),
k(k),kmer(kmer){}
Kmer(const data::Data_basic *db):feature::Feature(db){this->init(db);}
~Kmer(){}
float dist(feature::Feature *a);
unsigned int getK() const;
std::unordered_map<std::string, float> getKmer() const;
data::Data_basic *clone();
std::string to_dict();
std::string to_csv();
std::string getID(){
return this->TYPE;
}
};
class ORF: public feature::Feature{
protected:
static const std::vector<std::string> START;
static const std::vector<std::string> END;
static bool in_start(const std::string &c);
static bool in_end(const std::string &c);
float length=0;
float coverage=0;
float coverage_all_mean=0;
float coverage_all_std=0;
float frame_biases=0;
float frequency=0;
float start_mean=0;
float start_std=0;
float end_mean=0;
float end_std=0;
/*
float start_center, start_std;
float end_center, end_std;
*/
void init(const Data_basic *db);
public:
static const std::string TYPE;
static const std::string ENTRY_TYPE;
static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable();
~ORF(){}
ORF(const entry::Sequence &s);
ORF(const std::string &name,
const unsigned int &length, const float &coverage):
feature::Feature(name),
length(length),coverage(coverage){}
ORF(const data::Data_basic *db):feature::Feature(db){this->init(db);}
float dist(feature::Feature *a);
data::Data_basic *clone();
std::string to_dict();
std::string to_csv();
std::string getID(){
return this->TYPE;
}
float getCoverage() const;
float getStart_center() const;
float getStart_std() const;
float getEnd_center() const;
float getEnd_std() const;
unsigned int getMax_length() const;
unsigned int getLength() const;
};
class CodonBiases: public feature::Feature{
protected:
float position[4] = {0,0,0,0};
float gc_content = 0;
float composition[4] = {0,0,0,0};
void init(const Data_basic *db);
public:
static const std::string TYPE;
static const std::string ENTRY_TYPE;
static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable();
~CodonBiases();
CodonBiases(const entry::Sequence &s);
CodonBiases(
const std::string &name,
const float (&position)[4],
const float (&composition)[4]):
feature::Feature(name){
std::copy(std::begin(position),std::end(position),std::begin(this->position));
std::copy(std::begin(composition),std::end(composition),std::begin(this->composition));
}
CodonBiases(const data::Data_basic *db):feature::Feature(db){this->init(db);}
const float *getPosition();
float dist(Feature *a);
data::Data_basic *clone();
std::string to_dict();
std::string to_csv();
std::string getID(){
return this->TYPE;
}
};
}
#endif // FEATURE_H