SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
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, 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() const;
00130 
00135         virtual EFeatureClass get_feature_class() const;
00136 
00141         virtual int32_t get_num_vectors() const;
00142 
00145         void set_normalization_const(float64_t n=0);
00146 
00148         float64_t get_normalization_const();
00149 
00154         void set_minor_base_string(const char* str);
00155 
00160         void set_major_base_string(const char* str);
00161 
00166         char* get_minor_base_string();
00167 
00172         char* get_major_base_string();
00173 
00179         void obtain_base_strings(CSNPFeatures* snp=NULL);
00180 
00182         virtual const char* get_name() const { return "SNPFeatures"; }
00183 
00186         virtual SGMatrix<float64_t> get_histogram(bool normalize=true);
00187 
00191         static SGMatrix<float64_t> get_2x3_table(CSNPFeatures* pos, CSNPFeatures* neg);
00192 
00193     private:
00200         void find_minor_major_strings(uint8_t* minor, uint8_t* major);
00201 
00202     protected:
00204         CStringFeatures<uint8_t>* strings;
00205 
00207         int32_t string_length;
00209         int32_t num_strings;
00211         int32_t w_dim;
00212 
00214         float64_t normalization_const;
00215 
00217         uint8_t* m_str_min;
00219         uint8_t* m_str_maj;
00220 };
00221 }
00222 #endif // _SNPFEATURES_H___
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation