SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SNPFeatures.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2010 Soeren Sonnenburg
8  * Copyright (C) 2010 Berlin Institute of Technology
9  */
10 
11 #ifndef _SNPFEATURES_H___
12 #define _SNPFEATURES_H___
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/lib/common.h>
19 
20 namespace shogun
21 {
22 template <class ST> class CStringFeatures;
23 
29 class CSNPFeatures : public CDotFeatures
30 {
31  public:
33  CSNPFeatures();
34 
40 
42  CSNPFeatures(const CSNPFeatures & orig);
43 
45  virtual ~CSNPFeatures();
46 
54  virtual int32_t get_dim_feature_space() const;
55 
63  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
64 
71  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
72 
81  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
82  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
83 
89  virtual int32_t get_nnz_features_for_vector(int32_t num);
90 
100  virtual void* get_feature_iterator(int32_t vector_index);
101 
112  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
113 
119  virtual void free_feature_iterator(void* iterator);
120 
125  virtual CFeatures* duplicate() const;
126 
131  virtual EFeatureType get_feature_type() const;
132 
137  virtual EFeatureClass get_feature_class() const;
138 
143  virtual int32_t get_num_vectors() const;
144 
148 
151 
156  void set_minor_base_string(const char* str);
157 
162  void set_major_base_string(const char* str);
163 
168  char* get_minor_base_string();
169 
174  char* get_major_base_string();
175 
181  void obtain_base_strings(CSNPFeatures* snp=NULL);
182 
184  virtual const char* get_name() const { return "SNPFeatures"; }
185 
188  virtual SGMatrix<float64_t> get_histogram(bool normalize=true);
189 
194 
195  private:
202  void find_minor_major_strings(uint8_t* minor, uint8_t* major);
203 
204  protected:
207 
209  int32_t string_length;
211  int32_t num_strings;
213  int32_t w_dim;
214 
217 
219  uint8_t* m_str_min;
221  uint8_t* m_str_maj;
222 };
223 }
224 #endif // _SNPFEATURES_H___

SHOGUN Machine Learning Toolbox - Documentation