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 #define LOGSUM_TBL 10000      /* span of the logsum table */
00018 
00025 class CLocalAlignmentStringKernel: public CStringKernel<char>
00026 {
00027     public:
00031         CLocalAlignmentStringKernel(int32_t size);
00032 
00038         CLocalAlignmentStringKernel(
00039             CStringFeatures<char>* l, CStringFeatures<char>* r);
00040 
00041         virtual ~CLocalAlignmentStringKernel();
00042 
00049         virtual bool init(CFeatures* l, CFeatures* r);
00050 
00052         virtual void cleanup();
00053 
00059         virtual bool load_init(FILE* src) { return false; }
00060 
00066         virtual bool save_init(FILE* dest) { return false; }
00067 
00072         virtual EKernelType get_kernel_type()
00073         {
00074             return K_LOCALALIGNMENT;
00075         }
00076 
00081         virtual const char* get_name() const { return "LocalAlignment"; }
00082 
00083     private:
00085         void init_logsum();
00086 
00093         int32_t LogSum(int32_t p1, int32_t p2);
00094 
00101         float32_t LogSum2(float32_t p1, float32_t p2);
00102 
00104         void initialize();
00105 
00114         float64_t LAkernelcompute(
00115             int32_t* aaX, int32_t* aaY, int32_t nX, int32_t nY);
00116 
00117     protected:
00126         virtual float64_t compute(int32_t idx_a, int32_t idx_b);
00127 
00128     protected:
00130         bool initialized;
00131 
00133         int32_t *isAA;
00135         int32_t *aaIndex;
00136 
00138         int32_t opening;
00140         int32_t extension;
00141 
00143         static int32_t logsum_lookup[LOGSUM_TBL];
00145         static const int32_t blosum[];
00147         int32_t* scaled_blosum;
00148 };
00149 
00150 #endif /* _LOCALALIGNMENTSTRINGKERNEL_H__ */
00151 

SHOGUN Machine Learning Toolbox - Documentation