Ludovic PLATON

Add new feature element in Featurer, remove KMER6

This diff is collapsed. Click to expand it.
...@@ -10,161 +10,170 @@ ...@@ -10,161 +10,170 @@
10 #include "data/data_basic.h" 10 #include "data/data_basic.h"
11 11
12 namespace feature{ 12 namespace feature{
13 - class Feature : public data::Data_basic{ 13 +class Feature : public data::Data_basic{
14 - protected: 14 +protected:
15 - virtual void init(const Data_basic *db); 15 + virtual void init(const Data_basic *db);
16 - public: 16 +public:
17 - static const std::string TYPE; 17 + static const std::string TYPE;
18 - static const std::string ENTRY_TYPE; 18 + static const std::string ENTRY_TYPE;
19 - 19 +
20 - Feature(std::string name):data::Data_basic(name){} 20 + Feature(std::string name):data::Data_basic(name){}
21 - Feature(const data::Data_basic *db):data::Data_basic(db){this->init(db);} 21 + Feature(const data::Data_basic *db):data::Data_basic(db){this->init(db);}
22 - virtual ~Feature(){} 22 + virtual ~Feature(){}
23 - 23 +
24 - virtual float dist(feature::Feature *a)=0; 24 + virtual float dist(feature::Feature *a)=0;
25 - std::string to_dict()=0; 25 + std::string to_dict()=0;
26 - std::string to_csv()=0; 26 + std::string to_csv()=0;
27 - virtual std::string getID(){ 27 + virtual std::string getID(){
28 - return this->TYPE; 28 + return this->TYPE;
29 - } 29 + }
30 - virtual data::Data_basic *clone()=0; 30 + virtual data::Data_basic *clone()=0;
31 - std::string getEntry_name() const; 31 + std::string getEntry_name() const;
32 - }; 32 +};
33 - 33 +
34 - class SeqLength: public feature::Feature{ 34 +class SeqLength: public feature::Feature{
35 - protected: 35 +protected:
36 - int l; 36 + int l;
37 - 37 +
38 - void init(const Data_basic *db); 38 + void init(const Data_basic *db);
39 - 39 +
40 - public: 40 +public:
41 - static const std::string TYPE; 41 + static const std::string TYPE;
42 - static const std::string ENTRY_TYPE; 42 + static const std::string ENTRY_TYPE;
43 - 43 +
44 - static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable(); 44 + static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable();
45 - int getL() const; 45 + int getL() const;
46 - 46 +
47 - SeqLength(const entry::Sequence &s): 47 + SeqLength(const entry::Sequence &s):
48 - feature::Feature(s.getName()),l(s.getLength()){} 48 + feature::Feature(s.getName()),l(s.getLength()){}
49 - SeqLength(const std::string &name,const int &seql): 49 + SeqLength(const std::string &name,const int &seql):
50 - feature::Feature(name),l(seql){} 50 + feature::Feature(name),l(seql){}
51 - SeqLength(const data::Data_basic *db):feature::Feature(db){this->init(db);} 51 + SeqLength(const data::Data_basic *db):feature::Feature(db){this->init(db);}
52 - ~SeqLength(){} 52 + ~SeqLength(){}
53 - 53 +
54 - float dist(Feature *a); 54 + float dist(Feature *a);
55 - data::Data_basic *clone(); 55 + data::Data_basic *clone();
56 - std::string to_dict(); 56 + std::string to_dict();
57 - std::string to_csv(); 57 + std::string to_csv();
58 - std::string getID(){ 58 + std::string getID(){
59 - return this->TYPE; 59 + return this->TYPE;
60 - } 60 + }
61 - }; 61 +};
62 - 62 +
63 - class Kmer: public feature::Feature{ 63 +class Kmer: public feature::Feature{
64 - protected: 64 +protected:
65 - unsigned int k; 65 + unsigned int k;
66 - std::unordered_map<std::string,float> kmer; 66 + std::unordered_map<std::string,float> kmer;
67 - 67 +
68 - void init(const Data_basic *db); 68 + void init(const Data_basic *db);
69 - 69 +
70 - public: 70 +public:
71 - static const std::string TYPE; 71 + static const std::string TYPE;
72 - static const std::string ENTRY_TYPE; 72 + static const std::string ENTRY_TYPE;
73 - 73 +
74 - static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable(const unsigned int &k); 74 + static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable(const unsigned int &k);
75 - 75 +
76 - Kmer(entry::Sequence &s, const unsigned int &k); 76 + Kmer(entry::Sequence &s, const unsigned int &k);
77 - Kmer(const std::string &name, 77 + Kmer(const std::string &name,
78 - const unsigned int &k, const std::unordered_map<std::string,float> kmer): 78 + const unsigned int &k, const std::unordered_map<std::string,float> kmer):
79 - feature::Feature(name), 79 + feature::Feature(name),
80 - k(k),kmer(kmer){} 80 + k(k),kmer(kmer){}
81 - Kmer(const data::Data_basic *db):feature::Feature(db){this->init(db);} 81 + Kmer(const data::Data_basic *db):feature::Feature(db){this->init(db);}
82 - ~Kmer(){} 82 + ~Kmer(){}
83 - 83 +
84 - float dist(feature::Feature *a); 84 + float dist(feature::Feature *a);
85 - unsigned int getK() const; 85 + unsigned int getK() const;
86 - std::unordered_map<std::string, float> getKmer() const; 86 + std::unordered_map<std::string, float> getKmer() const;
87 - data::Data_basic *clone(); 87 + data::Data_basic *clone();
88 - std::string to_dict(); 88 + std::string to_dict();
89 - std::string to_csv(); 89 + std::string to_csv();
90 - std::string getID(){ 90 + std::string getID(){
91 - return this->TYPE; 91 + return this->TYPE;
92 - } 92 + }
93 - }; 93 +};
94 - 94 +
95 - class ORF: public feature::Feature{ 95 +class ORF: public feature::Feature{
96 - protected: 96 +protected:
97 - static const std::vector<std::string> START; 97 + static const std::vector<std::string> START;
98 - static const std::vector<std::string> END; 98 + static const std::vector<std::string> END;
99 - static bool in_start(const std::string &c); 99 + static bool in_start(const std::string &c);
100 - static bool in_end(const std::string &c); 100 + static bool in_end(const std::string &c);
101 - unsigned int length; 101 + unsigned int length;
102 - float coverage; 102 + float coverage;
103 - /* 103 + float start_mean;
104 + float start_std;
105 + float end_mean;
106 + float end_std;
107 +
108 + /*
104 float start_center, start_std; 109 float start_center, start_std;
105 float end_center, end_std; 110 float end_center, end_std;
106 */ 111 */
107 - void init(const Data_basic *db); 112 + void init(const Data_basic *db);
108 - public: 113 +public:
109 - static const std::string TYPE; 114 + static const std::string TYPE;
110 - static const std::string ENTRY_TYPE; 115 + static const std::string ENTRY_TYPE;
111 - 116 +
112 - static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable(); 117 + static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable();
113 - 118 +
114 - ~ORF(){} 119 + ~ORF(){}
115 - ORF(const entry::Sequence &s); 120 + ORF(const entry::Sequence &s);
116 - ORF(const std::string &name, 121 + ORF(const std::string &name,
117 - const unsigned int &length, const float &coverage): 122 + const unsigned int &length, const float &coverage):
118 - feature::Feature(name), 123 + feature::Feature(name),
119 - length(length),coverage(coverage){} 124 + length(length),coverage(coverage){}
120 - ORF(const data::Data_basic *db):feature::Feature(db){this->init(db);} 125 + ORF(const data::Data_basic *db):feature::Feature(db){this->init(db);}
121 - 126 +
122 - float dist(feature::Feature *a); 127 + float dist(feature::Feature *a);
123 - data::Data_basic *clone(); 128 + data::Data_basic *clone();
124 - std::string to_dict(); 129 + std::string to_dict();
125 - std::string to_csv(); 130 + std::string to_csv();
126 - std::string getID(){ 131 + std::string getID(){
127 - return this->TYPE; 132 + return this->TYPE;
128 - } 133 + }
129 - 134 +
130 - float getCoverage() const; 135 + float getCoverage() const;
131 - float getStart_center() const; 136 + float getStart_center() const;
132 - float getStart_std() const; 137 + float getStart_std() const;
133 - float getEnd_center() const; 138 + float getEnd_center() const;
134 - float getEnd_std() const; 139 + float getEnd_std() const;
135 - unsigned int getMax_length() const; 140 + unsigned int getMax_length() const;
136 - unsigned int getLength() const; 141 + unsigned int getLength() const;
137 - }; 142 +};
138 - 143 +
139 - class CodonPosition: public feature::Feature{ 144 +class CodonBiases: public feature::Feature{
140 - protected: 145 +protected:
141 - float position[4]; 146 + float position[4] = {0,0,0,0};
142 - void init(const Data_basic *db); 147 + float composition[4] = {0,0,0,0};
143 - public: 148 + void init(const Data_basic *db);
144 - static const std::string TYPE; 149 +public:
145 - static const std::string ENTRY_TYPE; 150 + static const std::string TYPE;
146 - 151 + static const std::string ENTRY_TYPE;
147 - static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable(); 152 +
148 - 153 + static callable::Callable<data::Data_basic*,data::Data_basic*> *get_callable();
149 - ~CodonPosition(){} 154 +
150 - CodonPosition(const entry::Sequence &s); 155 + ~CodonBiases();
151 - CodonPosition(const std::string &name, 156 + CodonBiases(const entry::Sequence &s);
152 - const float (&position)[4]): 157 + CodonBiases(
153 - feature::Feature(name){ 158 + const std::string &name,
154 - std::copy(std::begin(position),std::end(position),std::begin(this->position)); 159 + const float (&position)[4],
155 - } 160 + const float (&composition)[4]):
156 - CodonPosition(const data::Data_basic *db):feature::Feature(db){this->init(db);} 161 + feature::Feature(name){
157 - 162 + std::copy(std::begin(position),std::end(position),std::begin(this->position));
158 - const float *getPosition(); 163 + std::copy(std::begin(composition),std::end(composition),std::begin(this->composition));
159 - 164 + }
160 - float dist(Feature *a); 165 + CodonBiases(const data::Data_basic *db):feature::Feature(db){this->init(db);}
161 - data::Data_basic *clone(); 166 +
162 - std::string to_dict(); 167 + const float *getPosition();
163 - std::string to_csv(); 168 +
164 - std::string getID(){ 169 + float dist(Feature *a);
165 - return this->TYPE; 170 + data::Data_basic *clone();
166 - } 171 + std::string to_dict();
167 - }; 172 + std::string to_csv();
173 + std::string getID(){
174 + return this->TYPE;
175 + }
176 +};
168 } 177 }
169 178
170 #endif // FEATURE_H 179 #endif // FEATURE_H
......
...@@ -57,10 +57,10 @@ int main(int argc, char* argv[]) ...@@ -57,10 +57,10 @@ int main(int argc, char* argv[])
57 ds["KMER3"] = tmp_ds; 57 ds["KMER3"] = tmp_ds;
58 create_feature_maker(kmer,feature::Kmer::TYPE+std::to_string(6),tmp_ds,&re); 58 create_feature_maker(kmer,feature::Kmer::TYPE+std::to_string(6),tmp_ds,&re);
59 59
60 - kmer = static_cast<feature::Feature_callable*>(feature::Kmer::get_callable(6)); 60 +// kmer = static_cast<feature::Feature_callable*>(feature::Kmer::get_callable(6));
61 - tmp_ds = new data::Data_Store_Map(output+"KMER6.txt"); 61 +// tmp_ds = new data::Data_Store_Map(output+"KMER6.txt");
62 - ds["KMER6"] = tmp_ds; 62 +// ds["KMER6"] = tmp_ds;
63 - create_feature_maker(kmer,feature::Kmer::TYPE+std::to_string(6),tmp_ds,&re); 63 +// create_feature_maker(kmer,feature::Kmer::TYPE+std::to_string(6),tmp_ds,&re);
64 64
65 /* *********** ORF *********************/ 65 /* *********** ORF *********************/
66 /* ORF callable */ 66 /* ORF callable */
...@@ -70,12 +70,12 @@ int main(int argc, char* argv[]) ...@@ -70,12 +70,12 @@ int main(int argc, char* argv[])
70 ds["ORF"] = tmp_ds; 70 ds["ORF"] = tmp_ds;
71 create_feature_maker(orf,feature::ORF::TYPE,tmp_ds,&re); 71 create_feature_maker(orf,feature::ORF::TYPE,tmp_ds,&re);
72 72
73 - /* *********** Codon Position ***************/ 73 + /* *********** Codon Biases ***************/
74 74
75 - feature::Feature_callable *cp = static_cast<feature::Feature_callable*>(feature::CodonPosition::get_callable()); 75 + feature::Feature_callable *cb = static_cast<feature::Feature_callable*>(feature::CodonBiases::get_callable());
76 - tmp_ds = new data::Data_Store_Map(output+"CP.txt"); 76 + tmp_ds = new data::Data_Store_Map(output+"CB.txt");
77 - ds["CP"] = tmp_ds; 77 + ds["CB"] = tmp_ds;
78 - create_feature_maker(cp,feature::CodonPosition::TYPE,tmp_ds,&re); 78 + create_feature_maker(cb,feature::CodonBiases::TYPE,tmp_ds,&re);
79 79
80 /* *********** Fasta reader *************/ 80 /* *********** Fasta reader *************/
81 81
......