17 using namespace shogun;
20 :
CStringKernel<char>(0), width(0.0), degree(0), shift(0), window(0),
21 motif_positions_lhs(NULL), motif_positions_rhs(NULL),
22 position_weights(NULL), weights(NULL)
28 int32_t size,
float64_t w, int32_t d, int32_t s, int32_t wl)
29 :
CStringKernel<char>(size), width(w), degree(d), shift(s), window(wl),
30 motif_positions_lhs(NULL), motif_positions_rhs(NULL), position_weights(NULL), weights(NULL)
37 float64_t w, int32_t d, int32_t s, int32_t wl, int32_t size)
38 :
CStringKernel<char>(size), width(w), degree(d), shift(s), window(wl),
39 motif_positions_lhs(NULL), motif_positions_rhs(NULL), position_weights(NULL), weights(NULL)
58 SG_ERROR(
"Number of vectors does not agree (LHS: %d, Motif LHS: %d).\n",
61 SG_ERROR(
"Number of vectors does not agree (RHS: %d, Motif RHS: %d).\n",
77 SG_ERROR(
"Number of dimensions does not agree.\n");
90 bool free_avec, free_bvec;
94 int32_t alen_pos, blen_pos;
95 bool afree_pos, bfree_pos;
98 ASSERT(alen_pos==blen_pos);
99 int32_t num_pos=alen_pos;
105 for (int32_t p=0; p<num_pos; p++)
107 result_rbf+=
CMath::sq(positions_a[p]-positions_b[p]);
109 for (int32_t p2=0; p2<num_pos; p2++)
110 result_rbf+=
CMath::sq( (positions_a[p]-positions_a[p2]) - (positions_b[p]-positions_b[p2]) );
114 limit =
alen - positions_a[p];
119 result_wds+=
compute_wds(&avec[positions_a[p]], &bvec[positions_b[p]],
134 char* avec,
char* bvec, int32_t len)
138 for (int32_t i=0; i<
shift; i++)
142 for (int32_t i=0; i<len; i++)
148 for (int32_t j=0; (j<
degree) && (i+j<len); j++)
150 if (avec[i+j]!=bvec[i+j])
160 for (int32_t i=0; i<len; i++)
162 for (int32_t k=1; (k<=
shift) && (i+k<len); k++)
169 for (int32_t j=0; (j<
degree) && (i+j+k<len); j++)
171 if (avec[i+j+k]!=bvec[i+j])
177 for (int32_t j=0; (j<
degree) && (i+j+k<len); j++)
179 if (avec[i+j]!=bvec[i+j+k])
186 max_shift_vec[k-1] += sumi1 + sumi2 ;
191 for (int32_t i=0; i<
shift; i++)
192 result += max_shift_vec[i]/(2*(i+1)) ;
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
CSimpleFeatures< uint16_t > * motif_positions_lhs
ST * get_feature_vector(int32_t num, int32_t &len, bool &dofree)
virtual int32_t get_num_vectors() const
virtual bool init(CFeatures *l, CFeatures *r)
virtual int32_t get_num_vectors() const =0
float64_t compute_wds(char *avec, char *bvec, int32_t len)
CSimpleFeatures< uint16_t > * motif_positions_rhs
void set_motif_positions(CSimpleFeatures< uint16_t > *positions_lhs, CSimpleFeatures< uint16_t > *positions_rhs)
void add(bool *param, const char *name, const char *description="")
Class SGObject is the base class of all shogun objects.
virtual ~CRegulatoryModulesStringKernel()
virtual bool init_normalizer()
CFeatures * rhs
feature vectors to occur on right hand side
void add_vector(bool **param, index_t *length, const char *name, const char *description="")
CRegulatoryModulesStringKernel()
CFeatures * lhs
feature vectors to occur on left hand side
The class Features is the base class of all feature objects.
static T min(T a, T b)
return the minimum of two integers
float64_t * position_weights
Template class StringKernel, is the base class of all String Kernels.
#define SG_MALLOC(type, len)
int32_t get_num_features()
virtual void register_params()