16 using namespace shogun;
25 int32_t size,
float64_t w, int32_t d, int32_t s, int32_t wl)
33 float64_t w, int32_t d, int32_t s, int32_t wl, int32_t size)
47 void CRegulatoryModulesStringKernel::init()
57 SG_ADD(&
degree,
"degree",
"the degree of weighted degree kernel part",
60 "the shift of weighted degree with shifts kernel part",
MS_AVAILABLE);
63 "the matrix of motif positions from sequences left-hand side",
MS_NOT_AVAILABLE);
65 "the matrix of motif positions from sequences right-hand side",
MS_NOT_AVAILABLE);
76 SG_ERROR(
"Number of vectors does not agree (LHS: %d, Motif LHS: %d).\n",
79 SG_ERROR(
"Number of vectors does not agree (RHS: %d, Motif RHS: %d).\n",
95 SG_ERROR(
"Number of dimensions does not agree.\n")
108 bool free_avec, free_bvec;
114 int32_t alen_pos, blen_pos;
115 bool afree_pos, bfree_pos;
118 ASSERT(alen_pos==blen_pos)
119 int32_t num_pos=alen_pos;
125 for (int32_t p=0; p<num_pos; p++)
127 result_rbf+=
CMath::sq(positions_a[p]-positions_b[p]);
129 for (int32_t p2=0; p2<num_pos; p2++)
130 result_rbf+=
CMath::sq( (positions_a[p]-positions_a[p2]) - (positions_b[p]-positions_b[p2]) );
133 if (
window + positions_a[p] > alen)
134 limit = alen - positions_a[p];
136 if (
window + positions_b[p] > blen)
137 limit =
CMath::min(limit, blen - positions_b[p]);
139 result_wds+=
compute_wds(&avec[positions_a[p]], &bvec[positions_b[p]],
154 char* avec,
char* bvec, int32_t len)
158 for (int32_t i=0; i<
shift; i++)
162 for (int32_t i=0; i<len; i++)
168 for (int32_t j=0; (j<
degree) && (i+j<len); j++)
170 if (avec[i+j]!=bvec[i+j])
180 for (int32_t i=0; i<len; i++)
182 for (int32_t k=1; (k<=
shift) && (i+k<len); k++)
189 for (int32_t j=0; (j<
degree) && (i+j+k<len); j++)
191 if (avec[i+j+k]!=bvec[i+j])
197 for (int32_t j=0; (j<
degree) && (i+j+k<len); j++)
199 if (avec[i+j]!=bvec[i+j+k])
206 max_shift_vec[k-1] += sumi1 + sumi2 ;
211 for (int32_t i=0; i<
shift; i++)
212 result += max_shift_vec[i]/(2*(i+1)) ;
214 SG_FREE(max_shift_vec);