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 <shogun/lib/common.h>
00015 #include <shogun/features/DotFeatures.h>
00016 #include <shogun/features/StringFeatures.h>
00017 
00018 namespace shogun
00019 {
00020 template <class ST> class CStringFeatures;
00021 
00027 class CSNPFeatures : public CDotFeatures
00028 {
00029     public:
00031         CSNPFeatures();
00032 
00037         CSNPFeatures(CStringFeatures<uint8_t>* str);
00038 
00040         CSNPFeatures(const CSNPFeatures & orig);
00041 
00043         virtual ~CSNPFeatures();
00044 
00052         virtual int32_t get_dim_feature_space() const;
00053 
00061         virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, 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,
00080                 float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00081 
00087         virtual int32_t get_nnz_features_for_vector(int32_t num);
00088 
00098         virtual void* get_feature_iterator(int32_t vector_index);
00099 
00110         virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
00111 
00117         virtual void free_feature_iterator(void* iterator);
00118 
00123         virtual CFeatures* duplicate() const;
00124 
00129         virtual EFeatureType get_feature_type();
00130 
00135         virtual EFeatureClass get_feature_class();
00136 
00141         virtual int32_t get_num_vectors() const;
00142 
00147         virtual int32_t get_size();
00148 
00151         void set_normalization_const(float64_t n=0);
00152 
00154         float64_t get_normalization_const();
00155 
00160         void set_minor_base_string(const char* str);
00161 
00166         void set_major_base_string(const char* str);
00167 
00172         char* get_minor_base_string();
00173 
00178         char* get_major_base_string();
00179 
00185         void obtain_base_strings(CSNPFeatures* snp=NULL);
00186 
00188         virtual const char* get_name() const { return "SNPFeatures"; }
00189 
00192         virtual SGMatrix<float64_t> get_histogram(bool normalize=true);
00193 
00197         static SGMatrix<float64_t> get_2x3_table(CSNPFeatures* pos, CSNPFeatures* neg);
00198 
00199     private:
00206         void find_minor_major_strings(uint8_t* minor, uint8_t* major);
00207 
00208     protected:
00210         CStringFeatures<uint8_t>* strings;
00211 
00213         int32_t string_length;
00215         int32_t num_strings;
00217         int32_t w_dim;
00218 
00220         float64_t normalization_const;
00221 
00223         uint8_t* m_str_min;
00225         uint8_t* m_str_maj;
00226 };
00227 }
00228 #endif // _SNPFEATURES_H___
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation