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 00023 class CLocalAlignmentStringKernel: public CStringKernel<char> 00024 { 00025 public: 00029 CLocalAlignmentStringKernel(int32_t size); 00030 00036 CLocalAlignmentStringKernel( 00037 CStringFeatures<char>* l, CStringFeatures<char>* r); 00038 00039 virtual ~CLocalAlignmentStringKernel(); 00040 00047 virtual bool init(CFeatures* l, CFeatures* r); 00048 00050 virtual void cleanup(); 00051 00057 virtual bool load_init(FILE* src) { return false; } 00058 00064 virtual bool save_init(FILE* dest) { return false; } 00065 00070 virtual EKernelType get_kernel_type() 00071 { 00072 return K_LOCALALIGNMENT; 00073 } 00074 00079 virtual const char* get_name() 00080 { 00081 return "LocalAlignment"; 00082 } 00083 00084 private: 00086 void init_logsum(); 00087 00094 int32_t LogSum(int32_t p1, int32_t p2); 00095 00102 float32_t LogSum2(float32_t p1, float32_t p2); 00103 00105 void initialize(); 00106 00115 float64_t LAkernelcompute( 00116 int32_t* aaX, int32_t* aaY, int32_t nX, int32_t nY); 00117 00118 protected: 00127 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00128 00129 protected: 00131 bool initialized; 00132 00134 int32_t *isAA; 00136 int32_t *aaIndex; 00137 00139 int32_t opening; 00141 int32_t extension; 00142 00144 static int32_t logsum_lookup[LOGSUM_TBL]; 00146 static const int32_t blosum[]; 00148 int32_t* scaled_blosum; 00149 }; 00150 00151 #endif /* _LOCALALIGNMENTSTRINGKERNEL_H__ */ 00152