20 const Angle& SEC_oriented::calc_abs_angle()
const {
26 static int avoid_deep_recursion = 0;
27 avoid_deep_recursion++;
34 avoid_deep_recursion--;
38 abs_angle = rel_angle;
40 abs_angle_valid =
true;
44 const Angle& SEC_oriented::calc_rel_angle() {
50 rel_angle = abs_angle;
52 abs_angle_valid =
true;
60 void SEC_segment::calculate_segment_size() {
61 alpha = ((get_region()->get_base_count()+1) / loop->get_circumference()) * (2*
M_PI);
64 void SEC_loop::compute_circumference() {
76 void SEC_loop::compute_radius() {
77 compute_circumference();
78 setStandardSize(Circumference / (2 *
M_PI));
81 void SEC_loop::calculate_loop_size() {
85 seg->calculate_segment_size();
86 SEC_helix_strand *strand = seg->get_next_strand();
87 if (strand->isRootsideFixpoint()) {
88 strand->get_helix()->calculate_helix_size();
93 void SEC_helix::calculate_helix_size() {
94 SEC_region *reg1 = strandToRoot()->get_region();
95 SEC_region *reg2 = strandToOutside()->get_region();
104 if (base_length == 0) {
106 printf(
"Helix w/o size faking length=1\n");
110 setStandardSize(base_length-1);
112 strandToRoot()->get_origin_loop()->calculate_loop_size();
115 void SEC_root::calculate_size() {
116 SEC_loop *rootLoop = get_root_loop();
117 if (rootLoop) rootLoop->calculate_loop_size();
127 const Position& loopCenter = loop->get_center();
129 Vector start_center(start, loopCenter);
130 Vector end_center(end, loopCenter);
132 double radius = loop->drawnSize();
134 start_center.normalize() *= radius;
135 end_center.normalize() *= radius;
137 center1 = start+start_center;
138 center2 = end+end_center;
141 void SEC_loop::calculate_loop_coordinates() {
143 SEC_helix *fixpoint_helix = get_fixpoint_helix();
144 SEC_helix_strand *strand_away = fixpoint_helix->strandAwayFrom(
this);
145 const Position& loop_fixpoint = strand_away->get_fixpoint();
147 Angle current(center, loop_fixpoint);
149 double dbs = get_root()->display_params().distance_between_strands;
150 double angle_between_strands = (dbs / Circumference) * (2*
M_PI);
152 SEC_segment *seg = strand_away->get_next_segment();
153 SEC_helix_strand *pstrand = strand_away;
156 static int avoid_deep_recursion = 0;
157 avoid_deep_recursion++;
162 SEC_helix_strand *strand = seg->get_next_strand();
163 SEC_segment *next_seg =
NULp;
165 if (strand != strand_away) {
166 current +=
Angle(seg->get_alpha()+angle_between_strands);
167 strand->setFixpoint(center + current.normal()*drawnSize());
168 strand->get_helix()->calculate_helix_coordinates();
170 next_seg = strand->get_next_segment();
173 seg->calculate_segment_coordinates(pstrand->rightAttachPoint(), strand->leftAttachPoint());
180 avoid_deep_recursion--;
185 void SEC_helix::calculate_helix_coordinates() {
187 SEC_helix_strand *strand1 = strandToOutside();
188 const Position& fix1 = strand1->get_fixpoint();
190 const Angle& loopAngle = strand1->get_origin_loop()->get_abs_angle();
191 Angle strandAngle = loopAngle+get_rel_angle();
194 SEC_helix_strand *strand2 = strand1->get_other_strand();
195 strand2->setFixpoint(fix2);
198 double dbs = get_root()->display_params().distance_between_strands;
199 Vector fix1_rAttach = strandAngle.
normal() * (dbs * 0.5);
202 strand1->setAttachPoints(fix1-fix1_rAttach, fix1+fix1_rAttach);
203 strand2->setAttachPoints(fix2+fix1_rAttach, fix2-fix1_rAttach);
206 SEC_loop *nextLoop = outsideLoop();
207 Angle fix2_center = strandAngle + nextLoop->get_rel_angle();
208 Position loopCenter = fix2 + fix2_center.
normal()*nextLoop->drawnSize();
210 nextLoop->set_center(loopCenter);
211 nextLoop->calculate_loop_coordinates();
214 void SEC_root::calculate_coordinates() {
215 SEC_loop *rootLoop = get_root_loop();
218 rootLoop->set_center(
Origin);
219 rootLoop->mark_angle_absolute();
221 SEC_helix *primary_helix = rootLoop->get_fixpoint_helix();
224 const Angle& loopAngle = rootLoop->get_abs_angle();
226 Position outside = rootside +
Angle(loopAngle + primary_helix->get_abs_angle()).normal() * primary_helix->drawnSize();
228 primary_helix->setFixpoints(rootside, outside);
229 primary_helix->calculate_helix_coordinates();
231 rootLoop->calculate_loop_coordinates();
239 if (abs_angle_valid) {
240 invalidate_sub_angles();
241 abs_angle_valid =
false;
245 void SEC_helix::invalidate_sub_angles() {
246 SEC_loop *outLoop = outsideLoop();
248 outLoop->invalidate();
255 void SEC_loop::invalidate_sub_angles() {
257 if (strand->isRootsideFixpoint()) {
258 strand->get_helix()->invalidate();
267 delete [] abspos_array;
269 #if defined(ASSERTION_USED)
270 abspos_array_size = 0;
271 #endif // ASSERTION_USED
276 void SEC_region::create_abspos_array(
const int *static_array) {
281 abspos_array =
new int[baseCount];
282 memcpy(abspos_array, static_array, baseCount*
sizeof(*static_array));
284 #if defined(ASSERTION_USED)
285 abspos_array_size = baseCount;
286 #endif // ASSERTION_USED
289 void SEC_region::count_bases(
SEC_root *root) {
290 invalidate_base_count();
292 bool is_endings_seg =
false;
301 if (sequence_end < sequence_start) {
302 size = (max_index - sequence_start + 1) + sequence_end;
304 is_endings_seg =
true;
307 size = sequence_end - sequence_start;
308 last = sequence_end-1;
312 static int *static_array =
NULp;
313 static int sizeof_static_array = 0;
315 if (size > sizeof_static_array) {
316 delete [] static_array;
317 static_array =
new int[size];
318 sizeof_static_array = size;
324 for (i = sequence_start; i <= last; ++i) {
327 static_array[baseCount++] = i;
331 if (is_endings_seg) {
332 for (i = 0; i < sequence_end; ++i) {
335 static_array[baseCount++] = i;
341 create_abspos_array(static_array);
int get_base_count() const
void invalidate_base_count()
void align_helix_strands(SEC_root *root, SEC_region *other_region)
void update_base_count(SEC_root *root)
const SEC_db_interface * get_db() const
const SEC_displayParams & display_params() const
const Vector & normal() const
const Angle & get_abs_angle() const
static HelixNrInfo * start
double distance_between_strands
bool shallDisplayPosition(int abspos) const