SHOGUN  v2.0.0
 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/common.h>
17 
18 namespace shogun
19 {
20 template <class ST> class CStringFeatures;
21 
27 class CSNPFeatures : public CDotFeatures
28 {
29  public:
31  CSNPFeatures();
32 
38 
40  CSNPFeatures(const CSNPFeatures & orig);
41 
43  virtual ~CSNPFeatures();
44 
52  virtual int32_t get_dim_feature_space() const;
53 
61  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
62 
69  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
70 
79  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
80  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
81 
87  virtual int32_t get_nnz_features_for_vector(int32_t num);
88 
98  virtual void* get_feature_iterator(int32_t vector_index);
99 
110  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
111 
117  virtual void free_feature_iterator(void* iterator);
118 
123  virtual CFeatures* duplicate() const;
124 
129  virtual EFeatureType get_feature_type() const;
130 
135  virtual EFeatureClass get_feature_class() const;
136 
141  virtual int32_t get_num_vectors() const;
142 
147  virtual int32_t get_size() const;
148 
152 
155 
160  void set_minor_base_string(const char* str);
161 
166  void set_major_base_string(const char* str);
167 
172  char* get_minor_base_string();
173 
178  char* get_major_base_string();
179 
185  void obtain_base_strings(CSNPFeatures* snp=NULL);
186 
188  virtual const char* get_name() const { return "SNPFeatures"; }
189 
192  virtual SGMatrix<float64_t> get_histogram(bool normalize=true);
193 
198 
199  private:
206  void find_minor_major_strings(uint8_t* minor, uint8_t* major);
207 
208  protected:
211 
213  int32_t string_length;
215  int32_t num_strings;
217  int32_t w_dim;
218 
221 
223  uint8_t* m_str_min;
225  uint8_t* m_str_maj;
226 };
227 }
228 #endif // _SNPFEATURES_H___

SHOGUN Machine Learning Toolbox - Documentation