LocalAlignmentStringKernel.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) 1999-2009 Soeren Sonnenburg
00008  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _LOCALALIGNMENTSTRINGKERNEL_H___
00012 #define _LOCALALIGNMENTSTRINGKERNEL_H___
00013 
00014 #include "lib/common.h"
00015 #include "kernel/StringKernel.h"
00016 
00017 namespace shogun
00018 {
00019 #define LOGSUM_TBL 10000      /* span of the logsum table */
00020 
00027 class CLocalAlignmentStringKernel: public CStringKernel<char>
00028 {
00029     public:
00033         CLocalAlignmentStringKernel(int32_t size);
00034 
00040         CLocalAlignmentStringKernel(
00041             CStringFeatures<char>* l, CStringFeatures<char>* r);
00042 
00043         virtual ~CLocalAlignmentStringKernel();
00044 
00051         virtual bool init(CFeatures* l, CFeatures* r);
00052 
00054         virtual void cleanup();
00055 
00060         virtual EKernelType get_kernel_type()
00061         {
00062             return K_LOCALALIGNMENT;
00063         }
00064 
00069         virtual const char* get_name() const { return "LocalAlignment"; }
00070 
00071     private:
00073         void init_logsum();
00074 
00081         int32_t LogSum(int32_t p1, int32_t p2);
00082 
00089         float32_t LogSum2(float32_t p1, float32_t p2);
00090 
00092         void initialize();
00093 
00102         float64_t LAkernelcompute(
00103             int32_t* aaX, int32_t* aaY, int32_t nX, int32_t nY);
00104 
00105     protected:
00114         virtual float64_t compute(int32_t idx_a, int32_t idx_b);
00115 
00116     protected:
00118         bool initialized;
00119 
00121         int32_t *isAA;
00123         int32_t *aaIndex;
00124 
00126         int32_t opening;
00128         int32_t extension;
00129 
00131         static int32_t logsum_lookup[LOGSUM_TBL];
00133         static const int32_t blosum[];
00135         int32_t* scaled_blosum;
00137         static const char* aaList;
00138 };
00139 }
00140 #endif /* _LOCALALIGNMENTSTRINGKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation