SNPFeatures.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2010 Soeren Sonnenburg
00008  * Copyright (C) 2010 Berlin Institute of Technology
00009  */
00010 
00011 #ifndef _SNPFEATURES_H___
00012 #define _SNPFEATURES_H___
00013 
00014 #include "lib/common.h"
00015 #include "features/DotFeatures.h"
00016 #include "features/StringFeatures.h"
00017 
00018 namespace shogun
00019 {
00020 template <class ST> class CStringFeatures;
00021 
00027 class CSNPFeatures : public CDotFeatures
00028 {
00029     public:
00030 
00035         CSNPFeatures(CStringFeatures<uint8_t>* str);
00036 
00038         CSNPFeatures(const CSNPFeatures & orig);
00039 
00041         virtual ~CSNPFeatures();
00042 
00050         inline virtual int32_t get_dim_feature_space()
00051         {
00052             return w_dim;
00053         }
00054 
00061         virtual float64_t dot(int32_t vec_idx1, int32_t vec_idx2);
00062 
00069         virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
00070 
00079         virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00080 
00086         virtual inline int32_t get_nnz_features_for_vector(int32_t num)
00087         {
00088             return w_dim/3;
00089         }
00090 
00100         virtual void* get_feature_iterator(int32_t vector_index);
00101 
00112         virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
00113 
00119         virtual void free_feature_iterator(void* iterator);
00120 
00125         virtual CFeatures* duplicate() const;
00126 
00131         inline virtual EFeatureType get_feature_type()
00132         {
00133             return F_UNKNOWN;
00134         }
00135 
00140         inline virtual EFeatureClass get_feature_class()
00141         {
00142             return C_WD;
00143         }
00144 
00149         inline virtual int32_t get_num_vectors()
00150         {
00151             return num_strings;
00152         }
00153 
00158         inline virtual int32_t get_size()
00159         {
00160             return sizeof(float64_t);
00161         }
00162 
00165         void set_normalization_const(float64_t n=0);
00166 
00168         inline float64_t get_normalization_const()
00169         {
00170             return normalization_const;
00171         }
00172 
00177         void set_minor_base_string(const char* str)
00178         {
00179             m_str_min=(uint8_t*) strdup(str);
00180         }
00181 
00182 
00187         void set_major_base_string(const char* str)
00188         {
00189             m_str_maj=(uint8_t*) strdup(str);
00190         }
00191 
00192 
00197         char* get_minor_base_string()
00198         {
00199             return (char*) m_str_min;
00200         }
00201 
00202 
00207         char* get_major_base_string()
00208         {
00209             return (char*) m_str_maj;
00210         }
00211 
00213         void obtain_base_strings();
00214 
00215 
00217         inline virtual const char* get_name() const { return "SNPFeatures"; }
00218 
00219     protected:
00221         CStringFeatures<uint8_t>* strings;
00222 
00224         int32_t string_length;
00226         int32_t num_strings;
00228         int32_t w_dim;
00229 
00231         float64_t normalization_const;
00232 
00234         uint8_t* m_str_min;
00236         uint8_t* m_str_maj;
00237 
00238 };
00239 }
00240 #endif // _SNPFEATURES_H___
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation