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 "lib/common.h" 00015 #include "kernel/StringKernel.h" 00016 00017 namespace shogun 00018 { 00036 class CSNPStringKernel: public CStringKernel<char> 00037 { 00038 public: 00046 CSNPStringKernel(int32_t size, int32_t degree, int32_t win_len, bool inhomogene); 00047 00056 CSNPStringKernel( 00057 CStringFeatures<char>* l, CStringFeatures<char>* r, 00058 int32_t degree, int32_t win_len, bool inhomogene); 00059 00060 virtual ~CSNPStringKernel(); 00061 00068 virtual bool init(CFeatures* l, CFeatures* r); 00069 00071 virtual void cleanup(); 00072 00077 virtual EKernelType get_kernel_type() 00078 { 00079 return K_POLYMATCH; 00080 } 00081 00082 void set_minor_base_string(const char* str) 00083 { 00084 m_str_min=strdup(str); 00085 } 00086 00087 void set_major_base_string(const char* str) 00088 { 00089 m_str_maj=strdup(str); 00090 } 00091 00092 char* get_minor_base_string() 00093 { 00094 return m_str_min; 00095 } 00096 00097 char* get_major_base_string() 00098 { 00099 return m_str_maj; 00100 } 00101 00102 void obtain_base_strings(); 00103 00108 virtual const char* get_name() const { return "SNPStringKernel"; } 00109 00110 protected: 00119 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00120 00121 protected: 00123 int32_t m_degree; 00125 int32_t m_win_len; 00126 00128 bool m_inhomogene; 00129 00132 int32_t m_str_len; 00133 00135 char* m_str_min; 00137 char* m_str_maj; 00138 }; 00139 } 00140 #endif /* _SNPSTRINGKERNEL_H___ */