20 SEC_segment::SEC_segment()
24 next_helix_strand(
NULp),
28 SEC_helix_strand::SEC_helix_strand()
45 SEC_helix::SEC_helix(
SEC_root *root_, SEC_helix_strand *to_root, SEC_helix_strand *from_root)
47 strand_to_root(to_root),
55 to_root->set_other_strand(from_root);
56 from_root->set_other_strand(to_root);
58 to_root->set_helix_info(
this);
59 from_root->set_helix_info(
this);
78 bg_linewidth[i] = -1.0;
90 sequence_start(start),
94 #
if defined(ASSERTION_USED)
98 sec_assert((start == -1 && end == -1) || start != end);
103 delete [] abspos_array;
106 SEC_segment::~SEC_segment() {
110 SEC_helix_strand::~SEC_helix_strand() {
112 next_segment->delete_pointer_2(
this);
118 if (other_strand->next_segment) {
119 other_strand->next_segment->delete_pointer_2(other_strand);
121 other_strand->helix_info =
NULp;
122 other_strand->other_strand =
NULp;
123 other_strand->next_segment =
NULp;
133 SEC_loop::~SEC_loop() {
134 if (primary_strand) {
135 sec_assert(get_root()->get_root_loop() !=
this);
142 SEC_segment *seg = strand->get_next_segment();
151 set_fixpoint_strand(
NULp);
155 for (j=0; j<i; j++) {
156 SEC_helix_strand *strand = segment[j]->get_next_strand();
158 sec_assert(strand->get_origin_loop() ==
this);
159 strand->set_origin_loop(
NULp);
164 for (j=0; j<i; j++)
delete segment[j];
176 delete_announced_positions();
182 #if defined(CHECK_INTEGRITY)
184 void SEC_region::check_integrity(
const SEC_root *root, SEC_CHECK_TYPE what)
const {
185 if (what&CHECK_SIZE) {
193 void SEC_segment::check_integrity(SEC_CHECK_TYPE what)
const {
194 if (what&CHECK_STRUCTURE) {
198 if (what&CHECK_SIZE) {
202 if (what&CHECK_POSITIONS) {
206 get_region()->check_integrity(get_root(), what);
209 void SEC_helix_strand::check_integrity(SEC_CHECK_TYPE what)
const {
210 if (what&CHECK_STRUCTURE) {
212 sec_assert(other_strand->other_strand ==
this);
214 sec_assert(helix_info == other_strand->helix_info);
217 if (what&CHECK_SIZE) {
218 get_region()->get_base_count();
220 if (what&CHECK_POSITIONS) {
225 get_region()->check_integrity(get_root(), what);
228 void SEC_helix::check_integrity(SEC_CHECK_TYPE what)
const {
231 SEC_helix_strand *other_strand = strand_to_root->get_other_strand();
234 if (what&CHECK_STRUCTURE) {
235 sec_assert(strand_to_root->get_helix() ==
this);
236 sec_assert(other_strand->get_other_strand() == strand_to_root);
241 if (what&CHECK_SIZE) {
246 strand_to_root->check_integrity(what);
247 other_strand->check_integrity(what);
250 void SEC_loop::check_integrity(SEC_CHECK_TYPE what)
const {
254 if (what&CHECK_STRUCTURE) {
256 sec_assert(primary_strand->get_origin_loop() ==
this);
261 if (what&CHECK_STRUCTURE) {
262 sec_assert(
this == strand->get_origin_loop());
265 const SEC_helix *helix = strand->get_helix();
266 if (
this == helix->rootsideLoop()) {
267 helix->check_integrity(what);
273 const SEC_segment *seg = strand->get_next_segment();
275 if (what&CHECK_STRUCTURE) {
278 seg->check_integrity(what);
283 if (what&CHECK_STRUCTURE) {
284 if (is_root_loop()) {
286 sec_assert(primary_strand->pointsToOutside());
296 if (what&CHECK_SIZE) {
300 if (what&CHECK_POSITIONS) {
302 if (is_root_loop()) {
309 SEC_loop *outsideLoop = strand->get_helix()->outsideLoop();
310 if (outsideLoop !=
this) outsideLoop->check_integrity(what);
314 void SEC_root::check_integrity(SEC_CHECK_TYPE what)
const {
318 root_loop->check_integrity(what);
322 const SEC_base_part *start_part = root_loop->get_fixpoint_strand();
334 region = next_region;
339 while (part != start_part);
342 #endif // CHECK_INTEGRITY
347 void SEC_helix_strand::unlink(
bool fromOtherStrandAsWell) {
354 if (fromOtherStrandAsWell) other_strand =
NULp;
357 void SEC_segment::unlink() {
358 next_helix_strand =
NULp;
364 SEC_helix_strand *SEC_segment::split(
size_t start,
size_t end, SEC_segment **segment2_ptr) {
369 sec_assert(get_region()->contains_seq_position(start));
370 sec_assert(get_region()->contains_seq_position(end-1));
372 SEC_helix_strand *strand =
new SEC_helix_strand;
373 SEC_segment *segment2 =
new SEC_segment;
375 segment2->set_sequence_portion(end, get_region()->get_sequence_end());
376 strand->set_sequence_portion(start, end);
377 set_sequence_portion(get_region()->get_sequence_start(), start);
379 segment2->set_loop(get_loop());
380 strand->set_origin_loop(get_loop());
382 segment2->set_next_strand(get_next_strand());
383 set_next_strand(strand);
385 *segment2_ptr = segment2;
390 void SEC_segment::mergeWith(SEC_segment *other, SEC_loop *target_loop) {
391 set_sequence_portion(get_region()->get_sequence_start(),
392 other->get_region()->get_sequence_end());
394 set_next_strand(other->get_next_strand());
395 set_loop(target_loop);
402 void SEC_loop::reset_angles() {
404 if (strand->pointsToOutside()) {
405 Angle abs(center, strand->get_fixpoint());
406 strand->get_helix()->set_abs_angle(
abs);
412 void SEC_helix::reset_angles() {
413 outsideLoop()->set_rel_angle(0);
414 SEC_loop *rloop = rootsideLoop();
416 Angle toFix(rloop->get_center(), strandToOutside()->get_fixpoint());
417 set_abs_angle(toFix);
436 SEC_segment *SEC_helix_strand::get_previous_segment() {
437 SEC_segment *segment_before;
438 SEC_helix_strand *strand_pointer = next_segment->get_next_strand();
440 if (strand_pointer ==
this) {
441 segment_before = next_segment;
444 while (strand_pointer !=
this) {
445 segment_before = strand_pointer->get_next_segment();
446 strand_pointer = segment_before->get_next_strand();
449 return segment_before;
453 const char *longestHelixNr =
NULp;
454 size_t longestLength = 0;
456 const char *lastHelixNr =
NULp;
457 size_t lastHelixLen = 0;
459 const char *currHelixNr = helix->
helixNr(
size_t(pos));
460 if (currHelixNr != lastHelixNr) {
461 if (lastHelixLen>longestLength) {
462 longestLength = lastHelixLen;
463 longestHelixNr = lastHelixNr;
465 lastHelixNr = currHelixNr;
473 if (lastHelixLen>longestLength) longestHelixNr = lastHelixNr;
487 SEC_loop *loop1 =
new SEC_loop(
this);
488 SEC_loop *loop2 =
new SEC_loop(
this);
492 SEC_segment *segment1 =
new SEC_segment;
493 SEC_segment *segment2 =
new SEC_segment;
495 segment1->set_loop(loop1);
496 segment2->set_loop(loop2);
498 SEC_helix_strand *strand1 =
new SEC_helix_strand;
499 SEC_helix_strand *strand2 =
new SEC_helix_strand;
501 loop1->set_fixpoint_strand(strand1);
502 loop2->set_fixpoint_strand(strand2);
504 segment1->set_next_strand(strand1);
505 segment2->set_next_strand(strand2);
507 strand1->set_origin_loop(loop1);
508 strand2->set_origin_loop(loop2);
510 SEC_helix *helix =
new SEC_helix(
this, strand1, strand2);
512 strand1->set_next_segment(segment1);
513 strand2->set_next_segment(segment2);
515 size_t start1, end1, start2, end2;
518 strand1->set_sequence_portion(start1, end1+1); segment2->set_sequence_portion(end1+1, start2);
519 strand2->set_sequence_portion(start2, end2+1); segment1->set_sequence_portion(end2+1, start1);
521 root_loop = helix->rootsideLoop();
523 loop1->set_rel_angle(0);
524 loop2->set_rel_angle(0);
525 helix->set_rel_angle(0);
527 root_loop->mark_angle_absolute();
528 root_loop->set_center(
Origin);
void set_under_construction(bool construct)
void invalidate_base_count()
int get_sequence_start() const
const SEC_db_interface * get_db() const
int get_sequence_end() const
bool are_adjacent_regions(const SEC_region *reg1, const SEC_region *reg2)
const BI_helix * get_helixDef() const
void create_default_bone()
size_t getNextAbspos() const
long first_position(const char *helixNr) const
size_t opposite_position(size_t pos) const
SEC_region(int start, int end)
void init(SEC_graphic *gfx, AWT_canvas *scr, ED4_plugin_host &host)
#define SEC_GC_DATA_COUNT
static HelixNrInfo * start
long last_position(const char *helixNr) const
bool isOrigin(const Position &p)
long first_pair_position() const
const SEC_region * get_region() const
long next_pair_position(size_t pos) const
GB_write_int const char GB_write_autoconv_string WRITE_SKELETON(write_pointer, GBDATA *,"%p", GB_write_pointer) char *AW_awa if)(!gb_var) return strdup("")
const char * helixNr(size_t pos) const
CONSTEXPR_INLINE bool valid(SpeciesCreationMode m)
bool under_construction() const
void set_root_loop(SEC_loop *loop)
static void findLongestHelix(const BI_helix *helix, size_t &start1, size_t &end1, size_t &start2, size_t &end2)