SHOGUN
v3.2.0
|
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/lib/memory.h> 00016 #include <shogun/kernel/string/StringKernel.h> 00017 00018 namespace shogun 00019 { 00037 class CSNPStringKernel: public CStringKernel<char> 00038 { 00039 public: 00041 CSNPStringKernel(); 00042 00050 CSNPStringKernel(int32_t size, int32_t degree, int32_t win_len, bool inhomogene); 00051 00060 CSNPStringKernel( 00061 CStringFeatures<char>* l, CStringFeatures<char>* r, 00062 int32_t degree, int32_t win_len, bool inhomogene); 00063 00064 virtual ~CSNPStringKernel(); 00065 00072 virtual bool init(CFeatures* l, CFeatures* r); 00073 00075 virtual void cleanup(); 00076 00081 virtual EKernelType get_kernel_type() 00082 { 00083 return K_POLYMATCH; 00084 } 00085 00090 void set_minor_base_string(const char* str) 00091 { 00092 m_str_min=get_strdup(str); 00093 } 00094 00099 void set_major_base_string(const char* str) 00100 { 00101 m_str_maj=get_strdup(str); 00102 } 00103 00108 char* get_minor_base_string() 00109 { 00110 return m_str_min; 00111 } 00112 00117 char* get_major_base_string() 00118 { 00119 return m_str_maj; 00120 } 00121 00123 void obtain_base_strings(); 00124 00129 virtual const char* get_name() const { return "SNPStringKernel"; } 00130 00131 /* register the parameters 00132 */ 00133 virtual void register_params(); 00134 00135 protected: 00144 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00145 00146 protected: 00148 int32_t m_degree; 00150 int32_t m_win_len; 00151 00153 bool m_inhomogene; 00154 00157 int32_t m_str_len; 00158 00160 char* m_str_min; 00162 char* m_str_maj; 00163 00164 private: 00165 void init(); 00166 }; 00167 } 00168 #endif /* _SNPSTRINGKERNEL_H___ */