9 #ifndef __REDESIGNC__BasepairState__
10 #define __REDESIGNC__BasepairState__
16 #include "math/xyz_vector.h"
17 #include "math/xyz_matrix.h"
18 #include "math/transform.h"
19 #include "math/numerical.h"
20 #include "structure/basepair_state.fwd.h"
31 sugars_ ( Points(2) ),
32 diff_ ( Vector(0.0) ),
33 diff_sugars_( Vectors(2) )
40 Points
const & sugars):
45 diff_ ( Vector(0.0) ),
46 diff_sugars_( Vectors(2) )
47 { transpose(r_, r_T_); }
55 diff_ ( Vector(0.0) ),
56 diff_sugars_( Vectors(2) )
57 { transpose(r_, r_T_); }
75 calculate_r_T() { transpose(r_, r_T_); }
79 get_transforming_r_and_t (
87 dot(r_T_,o_state.r_,r_state.r_);
88 r_state.calculate_r_T();
91 dot_vectors(r_state.r_T_,o_state.sugars_,r_state.sugars_);
93 diff_ = -o_state.d() + d_;
96 for(i = 0; i < 2; i+=1) {
97 r_state.sugars_[i] += diff_;
100 for(i = 0; i < 2; i+=1) {
101 diff_sugars_[i] = sugars_[i] - r_state.sugars_[i];
104 diff_ = (diff_sugars_[0] + diff_sugars_[1]) / 2.0f;
105 r_state.d_ = -o_state.d() + diff_ + d_;
111 get_transformed_state(
115 dot (r_, o_state.r_T_, r_state.r_);
116 dot_vector (o_state.r_T_, d_, r_state.d_);
117 dot_vectors(o_state.r_T_, sugars_, r_state.sugars_);
120 for(i = 0; i < 2; i++) {
121 r_state.sugars_[i] += o_state.d_;
123 r_state.d_ += o_state.d_;
130 r_ = transform_1(r_);
137 BasepairStateOP
const & state) {
138 float diff = d_.distance(state->d());
139 diff += _rot_diff(state)*2;
146 BasepairStateOP
const & state) {
147 float r_diff = r_.difference(state->r());
149 float r_diff_2 = r_.difference(state->r());
152 if( r_diff > r_diff_2) { r_diff = r_diff_2;}
161 String s = vector_to_str(d_) +
";" + matrix_to_str(r_) +
";" + vector_to_str(sugars_[0]) + vector_to_str(sugars_[1]);
229 d(Point
const & newd) { d_ = newd; }
233 r( Matrix
const & newr) { r_ = newr; }
237 sugars( Points
const & newsug) { sugars_ = newsug; }
244 sugars_ = nstate_.sugars_;
263 Vectors diff_sugars_;
269 str_to_basepairstate(
276 get_bpstate_rotation_diff(
291 BasepairStateOP
const & current,
292 BasepairStateOP
const & end,
293 BasepairStateOP
const & endflip) {
295 float score = current->d().distance(end->d());
297 float r_diff = end->r().difference(current->r());
298 float r_diff_flip = endflip->r().difference(current->r());
300 if(r_diff > r_diff_flip) {
301 r_diff = r_diff_flip;
314 BasepairStateOP
const & current,
315 BasepairStateOP
const & end,
316 BasepairStateOP
const & endflip) {
318 float d_diff = current->d().distance(end->d());
320 if(d_diff > 25) {
return d_diff; }
322 float r_diff = current->r().difference(end->r());
323 float r_diff_flip = current->r().difference(endflip->r());
325 if(r_diff > r_diff_flip) {
326 r_diff = r_diff_flip;
329 float scale = (log(150/d_diff) - 1);
330 if (scale > 2) { scale = 2; }
331 if (scale < 0) { scale = 0; }
333 return d_diff + scale*r_diff;
339 new_score_function_new(
340 BasepairStateOP
const & current,
341 BasepairStateOP
const & end,
342 BasepairStateOP
const & endflip) {
344 float d_diff = (current->sugars()[0].distance(end->sugars()[1]) +
345 current->sugars()[1].distance(end->sugars()[0]))*0.50;
347 if(d_diff > 25) {
return d_diff; }
349 float r_diff = current->r().difference(end->r());
350 float r_diff_flip = current->r().difference(endflip->r());
352 if(r_diff > r_diff_flip) {
353 r_diff = r_diff_flip;
356 float scale = (log(150/d_diff) - 1);
357 if (scale > 2) { scale = 2; }
358 if (scale < 0) { scale = 0; }
360 return d_diff + scale*r_diff;
365 are_BasepairStates_equal(
Definition: basepair_state.h:22