SNPStringKernel.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) 2009-2010 Soeren Sonnenburg
00008  * Copyright (C) 2009-2010 Berlin Institute of Technology
00009  */
00010 
00011 #ifndef _SNPSTRINGKERNEL_H___
00012 #define _SNPSTRINGKERNEL_H___
00013 
00014 #include <shogun/lib/common.h>
00015 #include <shogun/kernel/StringKernel.h>
00016 
00017 namespace shogun
00018 {
00036 class CSNPStringKernel: public CStringKernel<char>
00037 {
00038     public:
00040         CSNPStringKernel();
00041 
00049         CSNPStringKernel(int32_t size, int32_t degree, int32_t win_len, bool inhomogene);
00050 
00059         CSNPStringKernel(
00060             CStringFeatures<char>* l, CStringFeatures<char>* r,
00061             int32_t degree, int32_t win_len, bool inhomogene);
00062 
00063         virtual ~CSNPStringKernel();
00064 
00071         virtual bool init(CFeatures* l, CFeatures* r);
00072 
00074         virtual void cleanup();
00075 
00080         virtual EKernelType get_kernel_type()
00081         {
00082             return K_POLYMATCH;
00083         }
00084         
00089         void set_minor_base_string(const char* str)
00090         {
00091             m_str_min=strdup(str);
00092         }
00093 
00098         void set_major_base_string(const char* str)
00099         {
00100             m_str_maj=strdup(str);
00101         }
00102 
00107         char* get_minor_base_string()
00108         {
00109             return m_str_min;
00110         }
00111 
00116         char* get_major_base_string()
00117         {
00118             return m_str_maj;
00119         }
00120 
00122         void obtain_base_strings();
00123 
00128         virtual const char* get_name() const { return "SNPStringKernel"; }
00129 
00130         /* register the parameters
00131          */
00132         virtual void register_params();
00133 
00134     protected:
00143         virtual float64_t compute(int32_t idx_a, int32_t idx_b);
00144 
00145     protected:
00147         int32_t m_degree;
00149         int32_t m_win_len;
00150 
00152         bool m_inhomogene;
00153 
00156         int32_t m_str_len;
00157 
00159         char* m_str_min;
00161         char* m_str_maj;
00162     
00163     private:
00164         void init();
00165 };
00166 }
00167 #endif /* _SNPSTRINGKERNEL_H___ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation