Merge pull request #5 from solgenomics/topic/fix_il_maps
[cview.git] / lib / CXGN / Cview / Marker.pm
blobd13ac8f4ab3d2a62c95e340d1334cc66ddc0a508
1 package CXGN::Cview::Marker;
3 =head1 NAME
5 CXGN::Cview::Marker - a class for drawing markers
7 =head1 DESCRIPTION
9 Inherits from L<CXGN::Cview::ImageObject>. Defines a marker object on a Cview image. Markers can be rendered in different colors, and have labels associated with them, L<CXGN::Cview::Label>, that can be hilited, rendered in different colors, etc. See the L<CXGN::Cview::Label> class for more information. The two label objects that are associated with each marker are:
11 =over 5
13 =item o
15 a name label object. The label object can in theory be accessed using the accessors for this label are get_label() and set_label(), however it is best to use the standard accessors of the marker object and let it deal with the label object itself.
17 =item o
19 an offset label that gives the distance in cM (or in the current map units) and is drawn symmetrically on the other side of the chromosome to the name label. The accessors for this label are get_offset_label() and set_offset_label(). It is currently not drawn by default in the Cview programs. The accessor show_offset_label() will cause the offset label to be displayed.
21 =back
23 Labels also have a mark associated with them. That's a small round circle after the label that can be colored to provide some additional visual information about the marker. See the mark related functions below.
25 Markers can be hidden using the set_hidden(1) accessor. Only the small tick on the chromosome will be drawn, and the label will be omitted.
27 For a marker that can define a range on the chromosome instead of a specific location use the L<CXGN::Cview::Marker::RangeMarker> class. See that class for more information.
29 Other Marker properties are inherited from ImageObject, such as the enclosing_rect accessors, set_url and get_url, and others. See L<CXGN::Cview::ImageObject>.
31 =head1 SEE ALSO
33 See also the documentation in L<CXGN::Cview>.
35 =head1 AUTHOR(S)
37 Lukas Mueller (lam87@cornell.edu)
39 =head1 VERSION and CHANGE HISTORY
41 Original version July 2004
43 [2006-07-07] Replaced label functions with CXGN::Cview::Label class.
45 =head1 FUNCTIONS
48 =cut
50 return 1;
52 use strict;
53 use warnings;
54 use CXGN::Cview::ImageObject;
55 use CXGN::Cview::Label;
57 use base qw/ CXGN::Cview::ImageObject /;
59 =head2 function new()
61 my $m -> new ($chr, $marker_id, $marker_name, $marker_type, $confidence, $order_in_loc, $location_subscript, $cM_offset, $loc_type, $loc_order, $overgo, $bac_count);
63 Creates a new marker. The $chr is the chromosome object the marker belongs to. The marker_id has to be a unique id for the marker. The marker_name is any string, marker_type should be CAPS, COSII, RFLP, SNP etc, confidence is -1 for undefined, 0 = ? .. 4= LOD(3). order_in_loc is deprecated, location_subscript is the subscript of the marker on that chromosome, if any. cM_offset is the offset of the marker on the chr, in cM. overgo should be set to true if the marker has an overgo marker, has_bacs should be set to true if there are BACs associated to that overgo marker.
65 =cut
67 sub new {
68 my $class = shift;
69 my $self = $class -> SUPER::new(@_);
70 my $chromosome = shift;
72 $self->set_chromosome($chromosome);
73 my ($marker_id, $marker_name, $marker_type, $confidence, $order_in_loc, $location_subscript, $offset, $loc_type, $loc_order, $has_overgo, $has_bacs) = @_;
74 # print STDERR "\@_ = @_\n";
76 # initialize the marker object with what was supplied by
77 # the call and some reasonable default parameters
79 $self->set_id($marker_id);
81 $self->set_marker_type($marker_type);
82 $self->set_confidence($confidence);
83 $self->set_order_in_loc($order_in_loc);
84 $self->set_location_subscript($location_subscript);
85 $self->set_offset($offset);
86 $self->set_loc_type($loc_type);
87 $self->set_loc_order($loc_order);
88 $self->set_has_overgo($has_overgo);
89 $self->set_has_bacs($has_bacs);
90 $self->set_color(50, 50 , 50);
91 $self->set_label(CXGN::Cview::Label->new());
92 #$self->set_label_side("right");
93 $self->set_show_tick(1);
94 $self->set_north_range(0);
95 $self->set_south_range(0);
98 # initialize the label
100 $self->get_label()->set_hilite_color(255, 255, 0);
101 $self->get_label()->set_line_color(150,150,150);
102 if (!$location_subscript) { $location_subscript=""; }
103 if (!$marker_name) { $marker_name = ""; }
104 $self->get_label()->set_name($marker_name.$location_subscript);
105 $self->set_marker_name($marker_name);
107 $self->unhilite();
108 $self->unhide();
109 # $self->set_north_range(0);
110 # $self->set_south_range(0);
111 $self->set_mark_color(255, 255, 255);
112 $self->set_mark_size(8);
113 $self->set_mark_link("");
114 $self->hide_mark();
115 # the default for this is set in the label object. $self->set_label_spacer(); # the distance between the label and the midline of the chromosome
116 $self->set_font(GD::Font->Small());
118 # the offset label is shown on the opposite side of
119 # the name label
121 my $offset_label = CXGN::Cview::Label->new();
122 $offset_label->set_text_color(150, 150, 150);
123 $offset_label->set_name( (sprintf "%5.2f", ($offset || 0) ) . " ");
124 $self->set_offset_label($offset_label);
126 return $self;
129 =head2 function get_color()
131 Gets the color of the marker (more specifically, the line of the marker on the chromosome). Three numbers between 0 and 255 for red, green and blue channels are returned as a list.
133 =cut
135 sub get_color {
136 my $self = shift;
137 if (!exists($self->{marker_color})) { @{$self->{marker_color}}=(); }
138 return @{$self->{marker_color}};
141 =head2 function set_color()
143 Sets the color of the marker (more specifically, the line of the marker on the chromosome). Three numbers between 0 and 255 for red, green and blue channels are required. Default color is black.
145 =cut
147 sub set_color {
148 my $self = shift;
149 $self->{marker_color}[0]=shift;
150 $self->{marker_color}[1]=shift;
151 $self->{marker_color}[2]=shift;
155 =head2 function get_name()
157 Gets the complete name of the marker including the suffix.
159 =cut
161 sub get_name {
162 my $self = shift;
163 # test if there is anything in loation_subscript and set to empty string
164 # otherwise a 0 may be appended.
165 if (!$self->get_location_subscript()) { $self->set_location_subscript(""); }
166 return $self->get_marker_name().$self->get_location_subscript();
169 =head2 functions get_marker_name(), set_marker_name()
171 gets the marker name, excluding the suffix.
173 =cut
175 sub get_marker_name {
176 my $self = shift;
177 # this function returns the marker name without the subscript. This is useful for constructing links to the marker detail page
178 # which requires a type/name tuple
179 if (!exists($self->{marker_name}) || !defined($self->{marker_name})) { $self->{marker_name}=""; }
180 return $self->{marker_name};
183 sub set_marker_name {
184 my $self = shift;
185 my $name = shift;
186 $self->{marker_name}=$name;
189 =head2 accessors get_synonyms, set_synonyms
191 Usage:
192 Desc:
193 Property
194 Side Effects:
195 Example:
197 =cut
199 sub get_synonyms {
200 my $self = shift;
201 if (!exists($self->{synonyms})) {
202 $self->{synonyms} = [];
204 return @{$self->{synonyms}};
207 sub set_synonyms {
208 my $self = shift;
209 $self->{synonyms} = shift;
213 =head2 functions get_id(), set_id()
215 gets the unique id associated with the marker.
217 =cut
219 sub get_id {
220 my $self = shift;
221 if (!exists($self->{marker_id}) || !defined($self->{marker_id})) {
222 $self->{marker_id}="";
224 return $self->{marker_id};
227 sub set_id {
228 my $self = shift;
229 $self->{marker_id}=shift;
232 =head2 functions set_confidence() and get_confidence()
234 Synopsis: my $confidence = $m->get_confidence()
235 Arguments: setter function: -1 ... 3.
236 -1 means uncalculated confidence
237 1 is ILOD<3
238 2 is CFLOD=3
239 3 is FLOD>3
240 Returns: getter returns values above
241 defaults to -1 if confidence property has not been set.
242 Side effects: display in the chromosome viewer depends on confidence values.
243 Description:
245 =cut
247 sub set_confidence {
248 my $self = shift;
249 $self->{confidence}=shift;
252 sub get_confidence {
253 my $self= shift;
254 if (!exists($self->{confidence}) || !defined($self->{confidence}) || !$self->{confidence}) {
255 $self->{confidence}=-1;
257 return $self->{confidence};
262 =head2 accessors set_marker_type() and get_marker_type()
264 Synopsis: accessors for the marker_type property.
265 Arguments:
266 Returns:
267 Side effects: rendering in the chromosome viewer depends on
268 marker type.
269 Description: marker types are: RFLP, SSR, CAPS and COS.
271 =cut
273 sub set_marker_type {
274 my $self = shift;
275 $self->{marker_type} = shift;
278 sub get_marker_type {
279 my $self = shift;
280 if (!exists($self->{marker_type}) || !defined($self->{marker_type})) {
281 $self->{marker_type}="";
283 return $self->{marker_type};
286 =head2 function get_mark_color()
288 the mark is a little circle displayed after the marker name.
289 it can be used to add additional visual information for a marker.
290 The mark is clickable. The link can be set using set_mark_link().
291 The default color is white with no link.
293 =cut
295 sub get_mark_color {
296 my $self = shift;
297 return @{$self->{mark_color}};
300 =head2 function set_mark_color()
302 the mark is a little circle displayed after the marker name.
303 it can be used to add additional visual information for a marker.
304 The mark is clickable. The link can be set using set_mark_link().
305 The default color is white with no link.
307 =cut
309 sub set_mark_color {
310 # the mark is a little circle displayed after the marker name.
311 # it can be used to add additional visual information for a marker.
312 # The mark is clickable. The link can be set using set_mark_link().
313 # The default color is white with no link.
314 my $self = shift;
315 $self->{mark_color}[0] = shift;
316 $self->{mark_color}[1] = shift;
317 $self->{mark_color}[2] = shift;
320 =head2 function set_show_mark()
322 Synopsis: $m->set_show_mark()
323 Arguments: none
324 Returns: nothing
325 Side effects: causes the mark to be displayed when the marker
326 is renderd.
327 Description:
329 =cut
331 sub set_show_mark {
332 my $self = shift;
333 $self->{show_mark} = 1;
336 =head2 function hide_mark()
338 Synopsis: $m->hide_mark()
339 Arguments:
340 Returns:
341 Side effects: hides the mark
342 Description:
344 =cut
346 sub hide_mark {
347 my $self = shift;
348 $self->{show_mark}=0;
351 =head2 function get_show_mark()
353 Synopsis:
354 Arguments:
355 Returns:
356 Side effects:
357 Description:
359 =cut
361 sub get_show_mark {
362 my $self = shift;
363 return $self->{show_mark};
366 =head2 functions set_mark_link(), get_mark_link()
368 Synopsis:
369 Arguments:
370 Returns:
371 Side effects:
372 Description:
374 =cut
376 sub set_mark_link {
377 my $self = shift;
378 $self->{mark_link} = shift;
381 sub get_mark_link {
382 my $self = shift;
383 if (!exists($self->{mark_link})) { $self->{mark_link}=""; }
384 return $self ->{mark_link};
387 =head2 functions has_overgo(), set_has_overgo()
389 Synopsis: $m->has_overgo()
390 Arguments:
391 Returns:
392 Side effects: used to derive the mark\'s color
393 Description:
395 =cut
397 sub has_overgo {
398 my $self = shift;
399 return $self->{has_overgo};
402 sub set_has_overgo {
403 my $self = shift;
404 $self->{has_overgo}=1;
407 =head2 functions has_bacs(), set_has_bacs()
409 Synopsis: $m->set_has_bacs(1)
410 Arguments:
411 Returns: nothing
412 Side effects: causes the mark to be displayed in red.
413 Description:
415 =cut
417 sub set_has_bacs {
418 my $self = shift;
419 $self->{has_bacs} = shift; # the number of bacs associated with this marker
422 sub has_bacs {
423 my $self = shift;
424 return $self->{has_bacs};
427 =head2 functions get_mark_rect(), set_mark_rect()
429 Synopsis:
430 Arguments:
431 Returns:
432 Side effects:
433 Description:
435 =cut
437 sub get_mark_rect {
438 my $self = shift;
439 if (! exists($self->{mark_rect}) || !defined($self->{mark_rect})) { @{$self->{mark_rect}} = (0,0,0,0); }
440 return ($self ->{mark_rect}[0], $self->{mark_rect}[1], $self->{mark_rect}[2], $self->{mark_rect}[3]);
443 sub set_mark_rect {
444 my $self = shift;
445 ($self ->{mark_rect}[0], $self->{mark_rect}[1], $self->{mark_rect}[2], $self->{mark_rect}[3]) = @_;
448 =head2 functions set_mark_size(), get_mark_size()
450 Synopsis:
451 Arguments:
452 Returns:
453 Side effects:
454 Description:
456 =cut
458 sub set_mark_size {
459 my $self = shift;
460 $self->{mark_size} = shift;
463 sub get_mark_size {
464 my $self = shift;
465 if (!exists($self->{mark_size}) || !defined($self->{mark_size})) { $self->{mark_size}=0; }
466 return $self->{mark_size};
469 =head2 functions is_frame_marker(), set_frame_marker()
471 Synopsis:
472 Arguments: none
473 Returns: returns true if the object represents
474 a frame marker.
475 Side effects: the chromosome viewer may decide to render
476 these markers differently
477 Description: set_frame_marker just sets the property to 1.
478 It cannot be unset.
480 =cut
482 sub is_frame_marker {
483 my $self = shift;
484 if (!exists($self->{loc_type}) || !defined($self->{loc_type})) { $self->{loc_type}=""; }
485 return ($self->{loc_type} eq "frame");
488 sub set_frame_marker {
489 my $self = shift;
490 $self->{loc_type} = "frame";
494 =head2 functions set_chromosome(), get_chromosome()
496 Synopsis: accessors for the chromosome property, representing
497 the chromosome this marker is associated with.
498 Arguments: setter: a CXGN::Cview::Chromosome object.
499 Returns: getter: a CXGN::Cview::Chromosome object.
500 Side effects: the marker will be drawn on this chromosome. The
501 marker also needs to be added to the marker list of
502 the chromosome. Calling add_marker on the chromosome
503 object takes care of all that.
504 Description:
506 =cut
508 sub get_chromosome {
509 my $self=shift;
510 return $self->{chromosome};
513 sub set_chromosome {
514 my $self =shift;
515 $self->{chromosome}=shift;
518 =head2 function hide()
520 Hides the marker completely from the chromosome.
522 =cut
524 sub hide {
525 my $self = shift;
526 #$self -> {hidden} = 1;
527 $self->get_label()->set_hidden(1);
530 =head2 function unhide()
532 Unhides the marker.
534 =cut
536 sub unhide {
537 my $self = shift;
538 #$self -> {hidden} = 0;
539 $self->get_label()->set_hidden(0);
542 =head2 function is_hidden()
544 Returns true if marker is hidden.
546 =cut
548 sub is_hidden {
549 my $self = shift;
550 #return $self -> {hidden};
551 return $self->get_label()->is_hidden();
554 =head2 function hide_label()
556 Hides the label of the marker only. The marker 'tick' is still being drawn.
558 =cut
560 sub hide_label {
561 my $self= shift;
562 #$self->{label_hidden} = 1;
563 $self->get_label()->set_hidden(1);
566 =head2 function show_label()
568 Unhides the label if it was previously hidden. Otherwise has no effect.
570 =cut
572 sub show_label {
573 my $self=shift;
574 #$self ->{label_hidden} = 0;
575 $self->get_label()->set_hidden(0);
578 =head2 function is_label_visible()
580 Returns true if the label is not hidden.
582 =cut
584 sub is_label_visible {
585 my $self = shift;
586 return !$self->is_hidden();
589 =head2 function get_image_map()
591 Returns the image map for this label as a string. Usually the chromosome object calls this function.
593 =cut
595 sub get_image_map {
596 my $self = shift;
597 #print STDERR "get_image_mapo marker\n";
598 # my $coords = join ",", ($self -> get_label_rect());
599 my $s = "";
600 if ($self->get_url()) {
601 $s = $self->get_label()->get_image_map();
602 # $s = "<area shape=\"rect\" coords=\"".$coords."\" href=\"".$self->get_url()."\" alt=\"\" />\n";
604 if ($self->get_show_mark()) {
605 $s .= "<area shape=\"rect\" coords=\"".(join(",", $self->get_mark_rect()))."\" href=\"".$self->get_mark_link()."\" alt=\"\" title=\"".($self->get_tooltip())."\" />\n";
608 return $s;
612 =head2 function render()
614 $marker -> render($image);
616 Renders the marker on a GD image object. The chromosome object usually calls this function to render the entire chromosome.
618 =cut
620 sub render {
621 my $self = shift;
622 my $image = shift;
624 # calculate y position in pixels
626 my $y = $self->get_chromosome()->get_vertical_offset() + $self->get_chromosome()->mapunits2pixels($self->get_offset());
628 #warn "[Marker.pm] ".$self->get_offset()."cM is $y pixels...\n";
629 # determine the side which this label should be drawn on. If it was not set manually,
630 # retrieve the side from the chromosome as a default.
632 if (!$self->get_label_side()) {
633 $self->set_label_side($self->get_chromosome()->get_label_side());
636 # render marker only if it is visible (markers outside of sections or hidden markers are not visible)
637 if ($self -> is_visible()) {
639 # draw the tick on the chromosome
641 my $color = $image -> colorResolve($self->get_color());
642 my $chromosome_width = $self->get_chromosome()->get_width();
643 my $halfwidth = int($chromosome_width/2);
644 $self->draw_tick($image);
646 # deal with label stuff
648 # the $label object deals with displaying the marker's name
649 # the $offset_label object deals with displaying the marker's offset
650 # on the opposite side
652 my $label = $self->get_label();
653 my $offset_label = $self->get_offset_label();
655 if ($self->get_hilited()) {
656 $label->set_hilited(1);
659 # draw the labels left of the chromosome if label_side eq left
661 if ($self->get_label_side() eq "left") {
663 # define the Label's reference point
665 $label->set_reference_point($self->get_chromosome()->get_horizontal_offset()-$halfwidth,$y);
666 $label->set_horizontal_offset($self->get_chromosome()->get_horizontal_offset()- $label->get_label_spacer());
668 # draw the offset on the right if label_side eq left, if display_marker
669 # offset is true in the chromosome object
671 if ($self->get_chromosome()->{display_marker_offset}) {
673 # define the label's reference point
675 $offset_label->set_reference_point($self->get_chromosome()->get_horizontal_offset()+$halfwidth, $y);
676 $offset_label->set_horizontal_offset($self->get_chromosome()->get_horizontal_offset()+ $label->get_label_spacer()
678 $offset_label->set_vertical_offset($label->get_vertical_offset());
679 $offset_label->set_align_side("left");
681 $offset_label->set_hidden($label->is_hidden());
682 $offset_label->render($image);
686 # draw the labels on the right side if label_side is right
688 elsif ($self->get_label_side() eq "right") {
690 # define the Label's reference point (the point where the label points to)
691 # and the horizontal offset (the actual position of the text label)
693 $label->set_reference_point($self->get_chromosome()->get_horizontal_offset()+$halfwidth,$y);
694 $label->set_horizontal_offset($self->get_chromosome()->get_horizontal_offset()+$label->get_label_spacer());
696 # if show offset is turned on, draw a label on the opposite side of the chromosome
697 # showing the cM position
699 if ($self->get_chromosome()->{display_marker_offset}) {
701 $offset_label->set_reference_point(
702 $self->get_chromosome()->get_horizontal_offset()-$halfwidth, $y
705 $offset_label->set_horizontal_offset($self->get_chromosome()->get_horizontal_offset()-
706 $label->get_label_spacer()
708 $offset_label->set_vertical_offset($label->get_vertical_offset());
709 $offset_label->set_align_side("right");
710 $offset_label->set_hidden($label->is_hidden());
711 $offset_label->render($image);
715 $label->render($image);
717 # draw the offset on the left if label_side eq right, if display_marker
718 # offset is true in the chromosome object
720 $self->draw_mark($image);
725 =head2 function draw_tick
727 Synopsis:
728 Arguments:
729 Returns:
730 Side effects:
731 Description:
733 =cut
735 sub draw_tick {
736 my $self =shift;
737 my $image = shift;
739 my $color = $image -> colorResolve($self->get_color());
740 my $halfwidth = int($self->get_chromosome->get_width/2);
741 my $y = $self->get_chromosome()->get_vertical_offset() + $self->get_chromosome()->mapunits2pixels($self->get_offset());
743 if ($self->get_show_tick()) {
744 $image -> line($self->get_chromosome()->get_horizontal_offset() - $halfwidth +1, $y, $self->get_chromosome()->get_horizontal_offset()+$halfwidth-1, $y, $color);
748 =head2 functions get_label(), set_label()
750 Synopsis: Accessors for the label property, which
751 is a CXGN::Cview::Label object. This attribute
752 is set automatically in the constructor and the
753 label name set to the marker name.
754 Arguments: the setter takes a CXGN::Cview::Label object as a
755 parameter.
756 Returns: the getter returns the marker\'s label object.
757 Side effects: the label object attributes are used for rendering
758 the label.
759 Description:
761 =cut
763 sub get_label {
764 my $self=shift;
765 return $self->{label};
768 sub set_label {
769 my $self=shift;
770 $self->{label}=shift;
773 =head2 function is_visible()
775 returns true if the marker is visible, meaning it is not hidden and it lies not outside the chromosome section, if defined.
777 =cut
779 sub is_visible {
780 my $self = shift;
782 # if it is hidden, we know its not visible...
784 if ($self->{hidden}) { return 0; }
786 # if the chromosome is a section, we return true if the offset is in that inverval, not otherwise
787 if ($self->get_chromosome()->is_section()) {
788 if ($self->get_offset() >= $self->get_chromosome()->get_start_cM() && $self->get_offset() <= $self ->get_chromosome()->{end_cM}) {
789 return 1;
791 else {return 0; }
794 # it's not hidden, and it's not a section, so it has to be visible...
796 return 1;
799 sub get_type{
800 my $self = shift;
801 return $self -> {type};
804 =head2 function draw_mark()
806 Synopsis: draws the mark as specified with the other mark functions.
807 Arguments:
808 Returns:
809 Side effects:
810 Description: the mark is a little circle next to the marker name that
811 can be used to convey additional information about the marker.
812 The color can be set using set_mark_color() and the link can be
813 set using set_mark_url(). The mark should be its own object...
815 =cut
817 sub draw_mark {
818 my $self = shift;
819 my $image = shift;
821 my $halfwidth = $self -> get_chromosome()->get_width() / 2;
822 my $label = $self->get_label();
823 my $x = 0;
824 my $y = $label->get_vertical_offset();
825 my $circle_color = $image -> colorResolve($self->{mark_color}[0], $self->{mark_color}[1], $self->{mark_color}[2]);
827 if ($self->get_show_mark()) {
828 if ($self->get_label_side() eq "left") {
830 # draw the mark for the left labels
832 my $circle_color = $image -> colorResolve($self->get_mark_color());
834 $x = $self->get_chromosome()->get_horizontal_offset()-$label->get_label_spacer()-$label->get_width()-$self->get_mark_size();
836 $self->set_mark_rect($x, $y, $x+$self->get_mark_size(), $y+$self->get_mark_size());
838 elsif ($self->get_label_side() eq "right") {
839 $x = $self->get_chromosome()->get_horizontal_offset()+$label->get_label_spacer()+$self->get_label_width()+$self->get_mark_size();
841 $self->set_mark_rect($x, $y, $x+$self->get_mark_size(), $y+$self->get_mark_size());
843 for (my $i=1; $i<=$self->get_mark_size(); $i++) {
844 $image -> arc($x,$y, $i, $i, 0, 360, $circle_color);
849 =head2 accessors get_offset(), set_offset()
851 Returns the offset of the marker in map units (by default cM).
853 =cut
855 sub get_offset {
856 my $self = shift;
857 return $self->{offset};
860 sub set_offset {
861 my $self = shift;
862 $self->{offset}=shift;
865 =head2 functions get_north_range(), set_north_range
867 Synopsis: $m->set_north_range(5)
868 Args/returns: a range in cM that describes the uncertainty
869 of the marker\'s location
870 Side effects: the label is drawn reflecting the uncertainty.
871 Description:
873 =cut
875 sub get_north_range {
876 my $self=shift;
877 return $self->{north_range};
880 sub set_north_range {
881 my $self=shift;
882 $self->{north_range}=shift;
885 =head2 functions get_south_range(), set_south_range()
887 Synopsis: $m->set_south_range(4)
888 Description: see set_north_range()
890 =cut
892 sub get_south_range {
893 my $self=shift;
894 return $self->{south_range};
897 sub set_south_range {
898 my $self=shift;
899 $self->{south_range}=shift;
903 =head2 set_range_coords
905 Usage: $m->set_range_coords($start, $end)
906 Desc: for markers that require a range, sets
907 the feature start to $start and end to $end,
908 calling set_offset(), set_north_range(), and
909 set_south_range() with the appropriate values.
910 Ret: nothing
911 Args: start [int], end [int]
912 Side Effects:
913 Example:
915 =cut
917 sub set_range_coords {
918 my $self = shift;
919 my $start = shift;
920 my $end = shift;
921 $self->set_offset(($start + $end )/2);
922 $self->set_north_range(($end - $start)/2);
923 $self->set_south_range(($end-$start)/2);
927 =head2 get_start
929 Usage: my $s = $m->get_start();
930 Desc: accessor for the start coord of the marker.
931 no corresponding setter. Use set_range_coords().
932 Ret:
933 Args:
934 Side Effects:
935 Example:
937 =cut
939 sub get_start {
940 my $self = shift;
941 return $self->get_offset()-$self->get_north_range();
944 =head2 get_end
946 Usage: my $e = $m->get_end();
947 Desc: accessor for the end coord of the marker.
948 Ret: no corresponding setter. Use set_range_coords().
949 Args:
950 Side Effects:
951 Example:
953 =cut
955 sub get_end {
956 my $self = shift;
957 return $self->get_offset()+$self->get_south_range();
960 =head2 accessors get_orientation, set_orientation
962 Usage: $m->set_orientation("F");
963 Desc:
964 Property the orientation of the feature, either "F" or "R".
965 Side Effects:
966 Example:
968 =cut
970 sub get_orientation {
971 my $self = shift;
973 # make F the default
975 if (!exists($self->{orientation})) {
976 $self->{orientation} = "F";
978 return $self->{orientation};
981 sub set_orientation {
982 my $self = shift;
983 my $orientation = shift;
984 if ($orientation !~ /F|R/i) {
985 die "Orientation has to be either F or R!";
987 $self->{orientation} = uc($orientation);
991 =head2 functions get_label_side(), set_label_side()
993 Synopsis:
994 Args/Returns: either "right" or "left"
995 Side effects: labels are drawn on the right of the
996 chromosome object if this equals "right", on
997 the left if equal to "left".
998 Description:
1000 =cut
1002 sub get_label_side {
1003 my $self=shift;
1004 if (!exists($self->{label_side})) {
1005 return $self->get_chromosome()->get_label_side();
1007 return $self->{label_side};
1010 sub set_label_side {
1011 my $self=shift;
1012 my $side = shift;
1013 $self->{label_side}=$side;
1016 =head2 function get_offset_label()
1018 Synopsis:
1019 Arguments:
1020 Returns:
1021 Side effects:
1022 Description:
1024 =cut
1026 sub get_offset_label {
1027 my $self=shift;
1028 return $self->{offset_label};
1031 =head2 function set_offset_label()
1033 Synopsis:
1034 Arguments:
1035 Returns:
1036 Side effects:
1037 Description:
1039 =cut
1041 sub set_offset_label {
1042 my $self=shift;
1043 $self->{offset_label}=shift;
1046 =head2 function show_offset_label()
1048 Synopsis:
1049 Arguments:
1050 Returns:
1051 Side effects:
1052 Description:
1054 =cut
1056 sub show_offset_label {
1057 my $self = shift;
1058 my $show = shift;
1059 if ($show != undef) {
1060 my $self->{show_offset_label}=$show;
1062 else {
1063 return $self->{show_offset_label};
1067 =head2 function get_show_tick
1069 Synopsis:
1070 Arguments:
1071 Returns:
1072 Side effects:
1073 Description:
1075 =cut
1077 sub get_show_tick {
1078 my $self=shift;
1079 return $self->{show_tick};
1082 =head2 function set_show_tick
1084 Synopsis:
1085 Arguments:
1086 Returns:
1087 Side effects:
1088 Description:
1090 =cut
1092 sub set_show_tick {
1093 my $self=shift;
1094 $self->{show_tick}=shift;
1097 =head2 functions set_url(), get_url()
1099 sets the url that this marker links to.
1101 =cut
1103 sub set_url {
1104 my $self = shift;
1105 $self->get_label()->set_url(shift);
1108 sub get_url {
1109 my $self = shift;
1110 return $self->get_label()->get_url();
1113 =head2 accessors set_tooltip, get_tooltip
1115 Property:
1116 Setter Args:
1117 Getter Args:
1118 Getter Ret:
1119 Side Effects:
1120 Description:
1122 =cut
1124 sub get_tooltip {
1125 my $self=shift;
1126 if (!exists($self->{tooltip}) || !defined($self->{tooltip})) {
1127 $self->{tooltip} = '';
1129 return $self->{tooltip};
1132 sub set_tooltip {
1133 my $self=shift;
1134 $self->{tooltip}=shift;
1139 =head2 function hilite()
1141 Hilites the marker in the hilite color (default is yellow).
1143 =cut
1145 sub hilite {
1146 my $self = shift;
1147 $self->get_label()->set_hilited(1);
1150 sub unhilite {
1151 my $self = shift;
1152 $self->get_label()->set_hilited(0);
1155 sub get_hilited {
1156 my $self = shift;
1157 return $self->get_label()->get_hilited();
1162 =head2 functions get_label_height()
1164 Synopsis: gets the height of the label.
1165 note: the height can\'t be set because
1166 it depends on the font size.
1167 Arguments:
1168 Returns:
1169 Side effects:
1170 Description:
1172 =cut
1175 sub get_label_height {
1176 my $self = shift;
1177 return $self ->get_label()->get_font()->height();
1180 =head2 function get_label_width()
1182 Synopsis: gets the width of the label.
1183 note - the width can\'t be set because
1184 it depends on the text in the label
1185 and the current font size.
1186 Arguments:
1187 Returns:
1188 Side effects:
1189 Description:
1191 =cut
1194 sub get_label_width {
1195 my $self = shift;
1196 return $self->get_label()->get_width();
1199 =head2 functions set_label_pos(), get_label_pos()
1201 Synopsis:
1202 Arguments:
1203 Returns:
1204 Side effects:
1205 Description:
1207 =cut
1210 sub set_label_pos {
1212 # sets the position of the label in pixels.
1214 my $self = shift;
1215 my $vertical_position = shift;
1216 # $self -> {label_position} = $vertical_position;
1217 $self->get_label()->set_vertical_offset($vertical_position);
1220 sub get_label_pos {
1221 my $self = shift;
1222 #return $self->{label_position};
1223 return $self->get_label()->get_vertical_offset();
1226 =head2 functions set_label_spacer(), get_label_spacer()
1228 Synopsis: Accessors for the label_spacer property, which
1229 represents the number of pixels from the edge of the
1230 label to the mid-line of the chromosome.
1231 Arguments:
1232 Returns:
1233 Side effects:
1234 Description:
1236 =cut
1239 sub set_label_spacer {
1240 my $self = shift;
1241 my $label_spacer = shift;
1242 $self->get_label()->set_label_spacer($label_spacer);
1245 sub get_label_spacer {
1246 my $self = shift;
1248 return $self->get_label()->get_label_spacer();
1251 =head2 function get_label_line_color()
1253 Synopsis:
1254 Arguments:
1255 Returns:
1256 Side effects:
1257 Description:
1259 =cut
1261 sub get_label_line_color {
1262 my $self=shift;
1263 return $self->get_label()->get_line_color();
1266 =head2 function set_label_line_color()
1268 Synopsis:
1269 Arguments:
1270 Returns:
1271 Side effects:
1272 Description:
1274 =cut
1276 sub set_label_line_color {
1277 my $self=shift;
1278 $self->get_label()->set_line_color(@_);
1281 =head2 function get_hilite_color()
1283 Gets the hilite color. Returns the RGB components of the color
1284 as a list of three elements.
1286 =cut
1288 sub get_hilite_color {
1289 my $self = shift;
1290 # if (!exists($self->{hilite_color})) { @{$self->{hilite_color}}=(); }
1291 # return @{$self->{hilite_color}};
1292 return $self->get_label()->get_hilite_color();
1295 =head2 function set_hilite_color()
1297 Sets the hilite color. Default is yellow. Three numbers between 0 and 255 for red, green and blue channels are required.
1299 =cut
1301 sub set_hilite_color {
1302 my $self = shift;
1303 $self->get_label()->set_hilite_color(@_);
1306 =head2 function get_offset_text_color()
1308 Gets the current offset text color (the color of the line
1309 that connects the marker tick with the marker name).
1311 =cut
1313 sub get_offset_text_color {
1314 my $self = shift;
1315 #if (!exists($self->{offset_text_color})) { @{$self->{offset_text_color}}=(); }
1316 return $self->get_offset_label()->get_text_color();
1317 #return @{$self->{offset_text_color}};
1320 =head2 function set_offset_text_color()
1322 Sets the color of the offset scale text, if enabled.
1324 =cut
1326 sub set_offset_text_color {
1327 my $self = shift;
1328 $self->get_offset_label()->set_text_color(@_);
1331 =head2 function get_text_color()
1333 gets the color of the label text.
1335 =cut
1338 sub get_text_color {
1339 my $self = shift;
1340 return $self->get_label()->get_text_color();
1343 =head2 function set_text_color()
1345 sets the color of the label text.
1347 =cut
1349 sub set_text_color {
1350 my $self = shift;
1351 $self->get_label()->set_text_color(@_);
1355 =head2 accessors get_order_in_loc(), set_order_in_loc()
1357 Synopsis: I think this is deprecated...
1358 Arguments:
1359 Returns:
1360 Side effects:
1361 Description:
1363 =cut
1365 sub get_order_in_loc {
1366 my $self=shift;
1367 return $self->{order_in_loc};
1370 sub set_order_in_loc {
1371 my $self=shift;
1372 $self->{order_in_loc}=shift;
1376 =head2 functions get_location_subscript(), set_location_subscript()
1378 Synopsis: sets the location subscript of this marker position
1379 Arguments: setter: a subscript, usually "a".."c" or similar
1380 Returns: getter: the current subscript
1381 Side effects: the subscript will be rendered on the map,
1382 added to the marker name. The CXGN::Cview::Marker function
1383 get_name() will also include the subscript, whereas
1384 get_marker_name() will not.
1385 Description:
1387 =cut
1389 sub get_location_subscript {
1390 my $self=shift;
1391 return $self->{location_subscript};
1394 sub set_location_subscript {
1395 my $self=shift;
1396 $self->{location_subscript}=shift;
1399 =head2 accessors get_loc_type(), set_loc_type()
1401 Synopsis:
1402 Arguments:
1403 Returns:
1404 Side effects:
1405 Description:
1407 =cut
1409 sub get_loc_type {
1410 my $self=shift;
1411 return $self->{loc_type};
1414 sub set_loc_type {
1415 my $self=shift;
1416 $self->{loc_type}=shift;
1419 =head2 accessors get_loc_order(), set_loc_order()
1421 Synopsis: I think this is deprecated.
1422 Arguments:
1423 Returns:
1424 Side effects:
1425 Description:
1427 =cut
1429 sub get_loc_order {
1430 my $self=shift;
1431 return $self->{loc_order};
1434 sub set_loc_order {
1435 my $self=shift;
1436 $self->{loc_order}=shift;
1439 =head2 has_range
1441 Usage: my $flag = $m->has_range()
1442 Desc: returns true if the marker has a range defined
1443 (usually using set_north_range() and set_south_range())
1444 false otherwise.
1445 Side Effects: none
1446 Example:
1448 =cut
1450 sub has_range {
1451 my $self = shift;
1452 if ( ($self->get_end() - $self->get_start()) > 12) { return 1;}
1453 return 0;