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-2008 Soeren Sonnenburg 00008 * Copyright (C) 1999-2008 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 00020 class CLocalAlignmentStringKernel: public CStringKernel<CHAR> 00021 { 00022 public: 00026 CLocalAlignmentStringKernel(INT size); 00027 00033 CLocalAlignmentStringKernel( 00034 CStringFeatures<CHAR>* l, CStringFeatures<CHAR>* r); 00035 00036 virtual ~CLocalAlignmentStringKernel(); 00037 00044 virtual bool init(CFeatures* l, CFeatures* r); 00045 00047 virtual void cleanup(); 00048 00054 virtual bool load_init(FILE* src) { return false; } 00055 00061 virtual bool save_init(FILE* dest) { return false; } 00062 00067 virtual EKernelType get_kernel_type() 00068 { 00069 return K_LOCALALIGNMENT; 00070 } 00071 00076 virtual const CHAR* get_name() 00077 { 00078 return "LocalAlignment"; 00079 } 00080 00081 private: 00083 void init_logsum(); 00084 00091 int LogSum(int p1, int p2); 00092 00099 float LogSum2(float p1, float p2); 00100 00102 void initialize(); 00103 00112 DREAL LAkernelcompute(int* aaX, int* aaY, int nX, int nY); 00113 00114 protected: 00123 virtual DREAL compute(INT idx_a, INT idx_b); 00124 00125 protected: 00127 bool initialized; 00128 00130 int *isAA; 00132 int *aaIndex; 00133 00135 int opening; 00137 int extension; 00138 00140 static int logsum_lookup[LOGSUM_TBL]; 00142 static const int blosum[]; 00144 int* scaled_blosum; 00145 }; 00146 00147 #endif /* _LOCALALIGNMENTSTRINGKERNEL_H__ */ 00148