SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OligoStringKernel.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2008 Christian Igel, Tobias Glasmachers
8  * Copyright (C) 2008 Christian Igel, Tobias Glasmachers
9  *
10  * Shogun adjustments (W) 2008-2009 Soeren Sonnenburg
11  * Copyright (C) 2008-2009 Fraunhofer Institute FIRST and Max-Planck-Society
12  */
13 #ifndef _OLIGOSTRINGKERNEL_H_
14 #define _OLIGOSTRINGKERNEL_H_
15 
17 
18 #include <vector>
19 #include <string>
20 
21 namespace shogun
22 {
41 class COligoStringKernel : public CStringKernel<char>
42 {
43  public:
46 
52  COligoStringKernel(int32_t cache_size, int32_t k, float64_t width);
53 
55  virtual ~COligoStringKernel();
56 
63  virtual bool init(CFeatures* l, CFeatures* r);
64 
69  virtual EKernelType get_kernel_type() { return K_OLIGO; }
70 
75  virtual const char* get_name() const { return "OligoStringKernel"; }
76 
77 
78  virtual float64_t compute(int32_t x, int32_t y);
79 
82  virtual void cleanup();
83 
84  protected:
98  static void encodeOligo(
99  const std::string& sequence, uint32_t k_mer_length,
100  const std::string& allowed_characters,
101  std::vector< std::pair<int32_t, float64_t> >& values);
102 
110  static void getSequences(
111  const std::vector<std::string>& sequences,
112  uint32_t k_mer_length, const std::string& allowed_characters,
113  std::vector< std::vector< std::pair<int32_t, float64_t> > >& encoded_sequences);
114 
131  const std::vector< std::pair<int32_t, float64_t> >& x,
132  const std::vector< std::pair<int32_t, float64_t> >& y,
133  int32_t max_distance = -1);
134 
135  private:
146  void getExpFunctionCache(uint32_t sequence_length);
147 
148  static inline bool cmpOligos_(std::pair<int32_t, float64_t> a,
149  std::pair<int32_t, float64_t> b )
150  {
151  return (a.second < b.second);
152  }
153 
154  void init();
155 
156  protected:
158  int32_t k;
165 };
166 }
167 #endif // _OLIGOSTRINGKERNEL_H_
virtual bool init(CFeatures *l, CFeatures *r)
virtual EKernelType get_kernel_type()
EKernelType
Definition: Kernel.h:52
virtual float64_t compute(int32_t x, int32_t y)
This class offers access to the Oligo Kernel introduced by Meinicke et al. in 2004.
int32_t cache_size
cache_size in MB
Definition: Kernel.h:799
static void encodeOligo(const std::string &sequence, uint32_t k_mer_length, const std::string &allowed_characters, std::vector< std::pair< int32_t, float64_t > > &values)
encodes the signals of the sequence
double float64_t
Definition: common.h:56
static void getSequences(const std::vector< std::string > &sequences, uint32_t k_mer_length, const std::string &allowed_characters, std::vector< std::vector< std::pair< int32_t, float64_t > > > &encoded_sequences)
encodes all sequences with the encodeOligo function and stores them in &#39;encoded_sequences&#39; ...
virtual const char * get_name() const
The class Features is the base class of all feature objects.
Definition: Features.h:56
Template class StringKernel, is the base class of all String Kernels.
Definition: StringKernel.h:24
float64_t kernelOligoFast(const std::vector< std::pair< int32_t, float64_t > > &x, const std::vector< std::pair< int32_t, float64_t > > &y, int32_t max_distance=-1)
returns the value of the oligo kernel for sequences &#39;x&#39; and &#39;y&#39;

SHOGUN Machine Learning Toolbox - Documentation