oops, this directory was missed...
[cview.git] / lib / CXGN / Marker.pm
blob70e6b1e3547d1f5777cf4782b6d7708018bfee81
2 =head1 NAME
4 CXGN::Cview::Marker - a class for drawing markers
6 =head1 DESCRIPTION
8 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:
10 =over 5
12 =item o
14 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.
16 =item o
18 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.
20 =back
22 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.
24 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.
26 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.
28 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>.
30 =head1 SEE ALSO
32 See also the documentation in L<CXGN::Cview>.
34 =head1 AUTHOR(S)
36 Lukas Mueller (lam87@cornell.edu)
38 =head1 VERSION and CHANGE HISTORY
40 Original version July 2004
42 [2006-07-07] Replaced label functions with CXGN::Cview::Label class.
44 =head1 FUNCTIONS
47 =cut
49 return 1;
51 use strict;
52 use CXGN::Cview::ImageObject;
53 use CXGN::Cview::Label;
55 package CXGN::Cview::Marker;
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)." ");
124 $self->set_offset_label($offset_label);
126 # print STDERR "Marker new: $self->{has_bacs}\n";
128 return $self;
131 =head2 function get_color()
133 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.
135 =cut
137 sub get_color {
138 my $self = shift;
139 if (!exists($self->{marker_color})) { @{$self->{marker_color}}=(); }
140 return @{$self->{marker_color}};
143 =head2 function set_color()
145 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.
147 =cut
149 sub set_color {
150 my $self = shift;
151 $self->{marker_color}[0]=shift;
152 $self->{marker_color}[1]=shift;
153 $self->{marker_color}[2]=shift;
157 =head2 function get_name()
159 Gets the complete name of the marker including the suffix.
161 =cut
163 sub get_name {
164 my $self = shift;
165 # test if there is anything in loation_subscript and set to empty string
166 # otherwise a 0 may be appended.
167 if (!$self->get_location_subscript()) { $self->set_location_subscript(""); }
168 return $self->get_marker_name().$self->get_location_subscript();
171 =head2 functions get_marker_name(), set_marker_name()
173 gets the marker name, excluding the suffix.
175 =cut
177 sub get_marker_name {
178 my $self = shift;
179 # this function returns the marker name without the subscript. This is useful for constructing links to the marker detail page
180 # which requires a type/name tuple
181 if (!exists($self->{marker_name}) || !defined($self->{marker_name})) { $self->{marker_name}=""; }
182 return $self->{marker_name};
185 sub set_marker_name {
186 my $self = shift;
187 my $name = shift;
188 $self->{marker_name}=$name;
191 =head2 functions get_id(), set_id()
193 gets the unique id associated with the marker.
195 =cut
197 sub get_id {
198 my $self = shift;
199 if (!exists($self->{marker_id}) || !defined($self->{marker_id})) {
200 $self->{marker_id}="";
202 return $self->{marker_id};
205 sub set_id {
206 my $self = shift;
207 $self->{marker_id}=shift;
210 =head2 functions set_confidence() and get_confidence()
212 Synopsis: my $confidence = $m->get_confidence()
213 Arguments: setter function: -1 ... 3.
214 -1 means uncalculated confidence
215 1 is ILOD<3
216 2 is CFLOD=3
217 3 is FLOD>3
218 Returns: getter returns values above
219 defaults to -1 if confidence property has not been set.
220 Side effects: display in the chromosome viewer depends on confidence values.
221 Description:
223 =cut
225 sub set_confidence {
226 my $self = shift;
227 $self->{confidence}=shift;
230 sub get_confidence {
231 my $self= shift;
232 if (!exists($self->{confidence}) || !defined($self->{confidence}) || !$self->{confidence}) {
233 $self->{confidence}=-1;
235 return $self->{confidence};
240 =head2 accessors set_marker_type() and get_marker_type()
242 Synopsis: accessors for the marker_type property.
243 Arguments:
244 Returns:
245 Side effects: rendering in the chromosome viewer depends on
246 marker type.
247 Description: marker types are: RFLP, SSR, CAPS and COS.
249 =cut
251 sub set_marker_type {
252 my $self = shift;
253 $self->{marker_type} = shift;
256 sub get_marker_type {
257 my $self = shift;
258 if (!exists($self->{marker_type}) || !defined($self->{marker_type})) {
259 $self->{marker_type}="";
261 return $self->{marker_type};
264 =head2 function get_mark_color()
266 the mark is a little circle displayed after the marker name.
267 it can be used to add additional visual information for a marker.
268 The mark is clickable. The link can be set using set_mark_link().
269 The default color is white with no link.
271 =cut
273 sub get_mark_color {
274 my $self = shift;
275 return @{$self->{mark_color}};
278 =head2 function set_mark_color()
280 the mark is a little circle displayed after the marker name.
281 it can be used to add additional visual information for a marker.
282 The mark is clickable. The link can be set using set_mark_link().
283 The default color is white with no link.
285 =cut
287 sub set_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.
292 my $self = shift;
293 $self->{mark_color}[0] = shift;
294 $self->{mark_color}[1] = shift;
295 $self->{mark_color}[2] = shift;
298 =head2 function set_show_mark()
300 Synopsis: $m->set_show_mark()
301 Arguments: none
302 Returns: nothing
303 Side effects: causes the mark to be displayed when the marker
304 is renderd.
305 Description:
307 =cut
309 sub set_show_mark {
310 my $self = shift;
311 $self->{show_mark} = 1;
314 =head2 function hide_mark()
316 Synopsis: $m->hide_mark()
317 Arguments:
318 Returns:
319 Side effects: hides the mark
320 Description:
322 =cut
324 sub hide_mark {
325 my $self = shift;
326 $self->{show_mark}=0;
329 =head2 function get_show_mark()
331 Synopsis:
332 Arguments:
333 Returns:
334 Side effects:
335 Description:
337 =cut
339 sub get_show_mark {
340 my $self = shift;
341 return $self->{show_mark};
344 =head2 functions set_mark_link(), get_mark_link()
346 Synopsis:
347 Arguments:
348 Returns:
349 Side effects:
350 Description:
352 =cut
354 sub set_mark_link {
355 my $self = shift;
356 $self->{mark_link} = shift;
359 sub get_mark_link {
360 my $self = shift;
361 if (!exists($self->{mark_link})) { $self->{mark_link}=""; }
362 return $self ->{mark_link};
365 =head2 functions has_overgo(), set_has_overgo()
367 Synopsis: $m->has_overgo()
368 Arguments:
369 Returns:
370 Side effects: used to derive the mark\'s color
371 Description:
373 =cut
375 sub has_overgo {
376 my $self = shift;
377 return $self->{has_overgo};
380 sub set_has_overgo {
381 my $self = shift;
382 $self->{has_overgo}=1;
385 =head2 functions has_bacs(), set_has_bacs()
387 Synopsis: $m->set_has_bacs(1)
388 Arguments:
389 Returns: nothing
390 Side effects: causes the mark to be displayed in red.
391 Description:
393 =cut
395 sub set_has_bacs {
396 my $self = shift;
397 $self->{has_bacs} = shift; # the number of bacs associated with this marker
400 sub has_bacs {
401 my $self = shift;
402 return $self->{has_bacs};
405 =head2 functions get_mark_rect(), set_mark_rect()
407 Synopsis:
408 Arguments:
409 Returns:
410 Side effects:
411 Description:
413 =cut
415 sub get_mark_rect {
416 my $self = shift;
417 if (! exists($self->{mark_rect})) { @{$self->{mark_rect}} = (0,0,0,0); }
418 return ($self ->{mark_rect}[0], $self->{mark_rect}[1], $self->{mark_rect}[2], $self->{mark_rect}[3]);
421 sub set_mark_rect {
422 my $self = shift;
423 ($self ->{mark_rect}[0], $self->{mark_rect}[1], $self->{mark_rect}[2], $self->{mark_rect}[3]) = @_;
426 =head2 functions set_mark_size(), get_mark_size()
428 Synopsis:
429 Arguments:
430 Returns:
431 Side effects:
432 Description:
434 =cut
436 sub set_mark_size {
437 my $self = shift;
438 $self->{mark_size} = shift;
441 sub get_mark_size {
442 my $self = shift;
443 if (!exists($self->{mark_size})) { $self->{mark_size}=0; }
444 return $self->{mark_size};
447 =head2 functions is_frame_marker(), set_frame_marker()
449 Synopsis:
450 Arguments: none
451 Returns: returns true if the object represents
452 a frame marker.
453 Side effects: the chromosome viewer may decide to render
454 these markers differently
455 Description: set_frame_marker just sets the property to 1.
456 It cannot be unset.
458 =cut
460 sub is_frame_marker {
461 my $self = shift;
462 if (!exists($self->{loc_type})) { $self->{loc_type}=""; }
463 return ($self->{loc_type} eq "frame");
466 sub set_frame_marker {
467 my $self = shift;
468 $self->{loc_type} = "frame";
472 =head2 functions set_chromosome(), get_chromosome()
474 Synopsis: accessors for the chromosome property, representing
475 the chromosome this marker is associated with.
476 Arguments: setter: a CXGN::Cview::Chromosome object.
477 Returns: getter: a CXGN::Cview::Chromosome object.
478 Side effects: the marker will be drawn on this chromosome. The
479 marker also needs to be added to the marker list of
480 the chromosome. Calling add_marker on the chromosome
481 object takes care of all that.
482 Description:
484 =cut
486 sub get_chromosome {
487 my $self=shift;
488 return $self->{chromosome};
491 sub set_chromosome {
492 my $self =shift;
493 $self->{chromosome}=shift;
496 =head2 function hide()
498 Hides the marker completely from the chromosome.
500 =cut
502 sub hide {
503 my $self = shift;
504 #$self -> {hidden} = 1;
505 $self->get_label()->set_hidden(1);
508 =head2 function unhide()
510 Unhides the marker.
512 =cut
514 sub unhide {
515 my $self = shift;
516 #$self -> {hidden} = 0;
517 $self->get_label()->set_hidden(0);
520 =head2 function is_hidden()
522 Returns true if marker is hidden.
524 =cut
526 sub is_hidden {
527 my $self = shift;
528 #return $self -> {hidden};
529 return $self->get_label()->is_hidden();
532 =head2 function hide_label()
534 Hides the label of the marker only. The marker 'tick' is still being drawn.
536 =cut
538 sub hide_label {
539 my $self= shift;
540 #$self->{label_hidden} = 1;
541 $self->get_label()->set_hidden(1);
544 =head2 function show_label()
546 Unhides the label if it was previously hidden. Otherwise has no effect.
548 =cut
550 sub show_label {
551 my $self=shift;
552 #$self ->{label_hidden} = 0;
553 $self->get_label()->set_hidden(0);
556 =head2 function is_label_visible()
558 Returns true if the label is not hidden.
560 =cut
562 sub is_label_visible {
563 my $self = shift;
564 return !$self->is_hidden();
567 =head2 function get_image_map()
569 Returns the image map for this label as a string. Usually the chromosome object calls this function.
571 =cut
573 sub get_image_map {
574 my $self = shift;
575 #print STDERR "get_image_mapo marker\n";
576 # my $coords = join ",", ($self -> get_label_rect());
577 my $s = "";
578 if ($self->get_url()) {
579 $s = $self->get_label()->get_image_map();
580 # $s = "<area shape=\"rect\" coords=\"".$coords."\" href=\"".$self->get_url()."\" alt=\"\" />\n";
582 if ($self->get_show_mark()) {
583 $s .= "<area shape=\"rect\" coords=\"".(join(",", $self->get_mark_rect()))."\" href=\"".$self->get_mark_link()."\" alt=\"\" title=\"".($self->get_tooltip())."\" />\n";
586 return $s;
590 =head2 function render()
592 $marker -> render($image);
594 Renders the marker on a GD image object. The chromosome object usually calls this function to render the entire chromosome.
596 =cut
598 sub render {
599 my $self = shift;
600 my $image = shift;
602 # calculate y position in pixels
604 my $y = $self->get_chromosome()->get_vertical_offset() + $self->get_chromosome()->mapunits2pixels($self->get_offset());
606 #warn "[Marker.pm] ".$self->get_offset()."cM is $y pixels...\n";
607 # determine the side which this label should be drawn on. If it was not set manually,
608 # retrieve the side from the chromosome as a default.
610 if (!$self->get_label_side()) {
611 $self->set_label_side($self->get_chromosome()->get_label_side());
614 # render marker only if it is visible (markers outside of sections or hidden markers are not visible)
615 if ($self -> is_visible()) {
617 # draw the tick on the chromosome
619 my $color = $image -> colorResolve($self->get_color());
620 my $chromosome_width = $self->get_chromosome()->get_width();
621 my $halfwidth = int($chromosome_width/2);
622 $self->draw_tick($image);
624 # deal with label stuff
626 # the $label object deals with displaying the marker's name
627 # the $offset_label object deals with displaying the marker's offset
628 # on the opposite side
630 my $label = $self->get_label();
631 my $offset_label = $self->get_offset_label();
633 if ($self->get_hilited()) {
634 $label->set_hilited(1);
637 # draw the labels left of the chromosome if label_side eq left
639 if ($self->get_label_side() eq "left") {
641 # define the Label's reference point
643 $label->set_reference_point($self->get_chromosome()->get_horizontal_offset()-$halfwidth,$y);
644 $label->set_horizontal_offset($self->get_chromosome()->get_horizontal_offset()- $label->get_label_spacer());
646 # draw the offset on the right if label_side eq left, if display_marker
647 # offset is true in the chromosome object
649 if ($self->get_chromosome()->{display_marker_offset}) {
651 # define the label's reference point
653 $offset_label->set_reference_point($self->get_chromosome()->get_horizontal_offset()+$halfwidth, $y);
654 $offset_label->set_horizontal_offset($self->get_chromosome()->get_horizontal_offset()+ $label->get_label_spacer()
656 $offset_label->set_vertical_offset($label->get_vertical_offset());
657 $offset_label->set_align_side("left");
659 $offset_label->set_hidden($label->is_hidden());
660 $offset_label->render($image);
664 # draw the labels on the right side if label_side is right
666 elsif ($self->get_label_side() eq "right") {
668 # define the Label's reference point (the point where the label points to)
669 # and the horizontal offset (the actual position of the text label)
671 $label->set_reference_point($self->get_chromosome()->get_horizontal_offset()+$halfwidth,$y);
672 $label->set_horizontal_offset($self->get_chromosome()->get_horizontal_offset()+$label->get_label_spacer());
674 # if show offset is turned on, draw a label on the opposite side of the chromosome
675 # showing the cM position
677 if ($self->get_chromosome()->{display_marker_offset}) {
679 $offset_label->set_reference_point(
680 $self->get_chromosome()->get_horizontal_offset()-$halfwidth, $y
683 $offset_label->set_horizontal_offset($self->get_chromosome()->get_horizontal_offset()-
684 $label->get_label_spacer()
686 $offset_label->set_vertical_offset($label->get_vertical_offset());
687 $offset_label->set_align_side("right");
688 $offset_label->set_hidden($label->is_hidden());
689 $offset_label->render($image);
693 $label->render($image);
695 # draw the offset on the left if label_side eq right, if display_marker
696 # offset is true in the chromosome object
698 $self->draw_mark($image);
703 =head2 function draw_tick
705 Synopsis:
706 Arguments:
707 Returns:
708 Side effects:
709 Description:
711 =cut
713 sub draw_tick {
714 my $self =shift;
715 my $image = shift;
717 my $color = $image -> colorResolve($self->get_color());
718 my $halfwidth = int($self->get_chromosome->get_width/2);
719 my $y = $self->get_chromosome()->get_vertical_offset() + $self->get_chromosome()->mapunits2pixels($self->get_offset());
721 if ($self->get_show_tick()) {
722 $image -> line($self->get_chromosome()->get_horizontal_offset() - $halfwidth +1, $y, $self->get_chromosome()->get_horizontal_offset()+$halfwidth-1, $y, $color);
726 =head2 functions get_label(), set_label()
728 Synopsis: Accessors for the label property, which
729 is a CXGN::Cview::Label object. This attribute
730 is set automatically in the constructor and the
731 label name set to the marker name.
732 Arguments: the setter takes a CXGN::Cview::Label object as a
733 parameter.
734 Returns: the getter returns the marker\'s label object.
735 Side effects: the label object attributes are used for rendering
736 the label.
737 Description:
739 =cut
741 sub get_label {
742 my $self=shift;
743 return $self->{label};
746 sub set_label {
747 my $self=shift;
748 $self->{label}=shift;
751 =head2 function is_visible()
753 returns true if the marker is visible, meaning it is not hidden and it lies not outside the chromosome section, if defined.
755 =cut
757 sub is_visible {
758 my $self = shift;
760 # if it is hidden, we know its not visible...
762 if ($self->{hidden}) { return 0; }
764 # if the chromosome is a section, we return true if the offset is in that inverval, not otherwise
765 if ($self->get_chromosome()->is_section()) {
766 if ($self->get_offset() >= $self->get_chromosome()->get_start_cM() && $self->get_offset() <= $self ->get_chromosome()->{end_cM}) {
767 return 1;
769 else {return 0; }
772 # it's not hidden, and it's not a section, so it has to be visible...
774 return 1;
777 sub get_type{
778 my $self = shift;
779 return $self -> {type};
782 =head2 function draw_mark()
784 Synopsis: draws the mark as specified with the other mark functions.
785 Arguments:
786 Returns:
787 Side effects:
788 Description: the mark is a little circle next to the marker name that
789 can be used to convey additional information about the marker.
790 The color can be set using set_mark_color() and the link can be
791 set using set_mark_url(). The mark should be its own object...
793 =cut
795 sub draw_mark {
796 my $self = shift;
797 my $image = shift;
799 my $halfwidth = $self -> get_chromosome()->get_width() / 2;
800 my $label = $self->get_label();
801 my $x = 0;
802 my $y = $label->get_vertical_offset();
803 my $circle_color = $image -> colorResolve($self->{mark_color}[0], $self->{mark_color}[1], $self->{mark_color}[2]);
805 if ($self->get_show_mark()) {
806 if ($self->get_label_side() eq "left") {
808 # draw the mark for the left labels
810 my $circle_color = $image -> colorResolve($self->get_mark_color());
812 $x = $self->get_chromosome()->get_horizontal_offset()-$label->get_label_spacer()-$label->get_width()-$self->get_mark_size();
814 $self->set_mark_rect($x, $y, $x+$self->get_mark_size(), $y+$self->get_mark_size());
816 elsif ($self->get_label_side() eq "right") {
817 $x = $self->get_chromosome()->get_horizontal_offset()+$label->get_label_spacer()+$self->get_label_width()+$self->get_mark_size();
819 $self->set_mark_rect($x, $y, $x+$self->get_mark_size(), $y+$self->get_mark_size());
821 for (my $i=1; $i<=$self->get_mark_size(); $i++) {
822 $image -> arc($x,$y, $i, $i, 0, 360, $circle_color);
827 =head2 accessors get_offset(), set_offset()
829 Returns the offset of the marker in map units (by default cM).
831 =cut
833 sub get_offset {
834 my $self = shift;
835 return $self->{offset};
838 sub set_offset {
839 my $self = shift;
840 $self->{offset}=shift;
843 =head2 functions get_north_range(), set_north_range
845 Synopsis: $m->set_north_range(5)
846 Args/returns: a range in cM that describes the uncertainty
847 of the marker\'s location
848 Side effects: the label is drawn reflecting the uncertainty.
849 Description:
851 =cut
853 sub get_north_range {
854 my $self=shift;
855 return $self->{north_range};
858 sub set_north_range {
859 my $self=shift;
860 $self->{north_range}=shift;
863 =head2 functions get_south_range(), set_south_range()
865 Synopsis: $m->set_south_range(4)
866 Description: see set_north_range()
868 =cut
870 sub get_south_range {
871 my $self=shift;
872 return $self->{south_range};
875 sub set_south_range {
876 my $self=shift;
877 $self->{south_range}=shift;
881 =head2 set_range_coords
883 Usage: $m->set_range_coords($start, $end)
884 Desc: for markers that require a range, sets
885 the feature start to $start and end to $end,
886 calling set_offset(), set_north_range(), and
887 set_south_range() with the appropriate values.
888 Ret: nothing
889 Args: start [int], end [int]
890 Side Effects:
891 Example:
893 =cut
895 sub set_range_coords {
896 my $self = shift;
897 my $start = shift;
898 my $end = shift;
899 $self->set_offset(($start + $end )/2);
900 $self->set_north_range(($end - $start)/2);
901 $self->set_south_range(($end-$start)/2);
905 =head2 get_start
907 Usage: my $s = $m->get_start();
908 Desc: accessor for the start coord of the marker.
909 no corresponding setter. Use set_range_coords().
910 Ret:
911 Args:
912 Side Effects:
913 Example:
915 =cut
917 sub get_start {
918 my $self = shift;
919 return $self->get_offset()-$self->get_north_range();
922 =head2 get_end
924 Usage: my $e = $m->get_end();
925 Desc: accessor for the end coord of the marker.
926 Ret: no corresponding setter. Use set_range_coords().
927 Args:
928 Side Effects:
929 Example:
931 =cut
933 sub get_end {
934 my $self = shift;
935 return $self->get_offset()+$self->get_south_range();
938 =head2 accessors get_orientation, set_orientation
940 Usage: $m->set_orientation("F");
941 Desc:
942 Property the orientation of the feature, either "F" or "R".
943 Side Effects:
944 Example:
946 =cut
948 sub get_orientation {
949 my $self = shift;
951 # make F the default
953 if (!exists($self->{orientation})) {
954 $self->{orientation} = "F";
956 return $self->{orientation};
959 sub set_orientation {
960 my $self = shift;
961 my $orientation = shift;
962 if ($orientation !~ /F|R/i) {
963 die "Orientation has to be either F or R!";
965 $self->{orientation} = uc($orientation);
969 =head2 functions get_label_side(), set_label_side()
971 Synopsis:
972 Args/Returns: either "right" or "left"
973 Side effects: labels are drawn on the right of the
974 chromosome object if this equals "right", on
975 the left if equal to "left".
976 Description:
978 =cut
980 sub get_label_side {
981 my $self=shift;
982 if (!exists($self->{label_side})) {
983 return $self->get_chromosome()->get_label_side();
985 return $self->{label_side};
988 sub set_label_side {
989 my $self=shift;
990 my $side = shift;
991 $self->{label_side}=$side;
994 =head2 function get_offset_label()
996 Synopsis:
997 Arguments:
998 Returns:
999 Side effects:
1000 Description:
1002 =cut
1004 sub get_offset_label {
1005 my $self=shift;
1006 return $self->{offset_label};
1009 =head2 function set_offset_label()
1011 Synopsis:
1012 Arguments:
1013 Returns:
1014 Side effects:
1015 Description:
1017 =cut
1019 sub set_offset_label {
1020 my $self=shift;
1021 $self->{offset_label}=shift;
1024 =head2 function show_offset_label()
1026 Synopsis:
1027 Arguments:
1028 Returns:
1029 Side effects:
1030 Description:
1032 =cut
1034 sub show_offset_label {
1035 my $self = shift;
1036 my $show = shift;
1037 if ($show != undef) {
1038 my $self->{show_offset_label}=$show;
1040 else {
1041 return $self->{show_offset_label};
1045 =head2 function get_show_tick
1047 Synopsis:
1048 Arguments:
1049 Returns:
1050 Side effects:
1051 Description:
1053 =cut
1055 sub get_show_tick {
1056 my $self=shift;
1057 return $self->{show_tick};
1060 =head2 function set_show_tick
1062 Synopsis:
1063 Arguments:
1064 Returns:
1065 Side effects:
1066 Description:
1068 =cut
1070 sub set_show_tick {
1071 my $self=shift;
1072 $self->{show_tick}=shift;
1075 =head2 functions set_url(), get_url()
1077 sets the url that this marker links to.
1079 =cut
1081 sub set_url {
1082 my $self = shift;
1083 $self->get_label()->set_url(shift);
1086 sub get_url {
1087 my $self = shift;
1088 return $self->get_label()->get_url();
1091 =head2 accessors set_tooltip, get_tooltip
1093 Property:
1094 Setter Args:
1095 Getter Args:
1096 Getter Ret:
1097 Side Effects:
1098 Description:
1100 =cut
1102 sub get_tooltip {
1103 my $self=shift;
1104 return $self->{tooltip};
1107 sub set_tooltip {
1108 my $self=shift;
1109 $self->{tooltip}=shift;
1114 =head2 function hilite()
1116 Hilites the marker in the hilite color (default is yellow).
1118 =cut
1120 sub hilite {
1121 my $self = shift;
1122 $self->get_label()->set_hilited(1);
1125 sub unhilite {
1126 my $self = shift;
1127 $self->get_label()->set_hilited(0);
1130 sub get_hilited {
1131 my $self = shift;
1132 return $self->get_label()->get_hilited();
1137 =head2 functions get_label_height()
1139 Synopsis: gets the height of the label.
1140 note: the height can\'t be set because
1141 it depends on the font size.
1142 Arguments:
1143 Returns:
1144 Side effects:
1145 Description:
1147 =cut
1150 sub get_label_height {
1151 my $self = shift;
1152 return $self ->get_label()->get_font()->height();
1155 =head2 function get_label_width()
1157 Synopsis: gets the width of the label.
1158 note - the width can\'t be set because
1159 it depends on the text in the label
1160 and the current font size.
1161 Arguments:
1162 Returns:
1163 Side effects:
1164 Description:
1166 =cut
1169 sub get_label_width {
1170 my $self = shift;
1171 return $self->get_label()->get_width();
1174 =head2 functions set_label_pos(), get_label_pos()
1176 Synopsis:
1177 Arguments:
1178 Returns:
1179 Side effects:
1180 Description:
1182 =cut
1185 sub set_label_pos {
1187 # sets the position of the label in pixels.
1189 my $self = shift;
1190 my $vertical_position = shift;
1191 # $self -> {label_position} = $vertical_position;
1192 $self->get_label()->set_vertical_offset($vertical_position);
1195 sub get_label_pos {
1196 my $self = shift;
1197 #return $self->{label_position};
1198 return $self->get_label()->get_vertical_offset();
1201 =head2 functions set_label_spacer(), get_label_spacer()
1203 Synopsis: Accessors for the label_spacer property, which
1204 represents the number of pixels from the edge of the
1205 label to the mid-line of the chromosome.
1206 Arguments:
1207 Returns:
1208 Side effects:
1209 Description:
1211 =cut
1214 sub set_label_spacer {
1215 my $self = shift;
1216 my $label_spacer = shift;
1217 $self->get_label()->set_label_spacer($label_spacer);
1220 sub get_label_spacer {
1221 my $self = shift;
1223 return $self->get_label()->get_label_spacer();
1226 =head2 function get_label_line_color()
1228 Synopsis:
1229 Arguments:
1230 Returns:
1231 Side effects:
1232 Description:
1234 =cut
1236 sub get_label_line_color {
1237 my $self=shift;
1238 return $self->get_label()->get_line_color();
1241 =head2 function set_label_line_color()
1243 Synopsis:
1244 Arguments:
1245 Returns:
1246 Side effects:
1247 Description:
1249 =cut
1251 sub set_label_line_color {
1252 my $self=shift;
1253 $self->get_label()->set_line_color(@_);
1256 =head2 function get_hilite_color()
1258 Gets the hilite color. Returns the RGB components of the color
1259 as a list of three elements.
1261 =cut
1263 sub get_hilite_color {
1264 my $self = shift;
1265 # if (!exists($self->{hilite_color})) { @{$self->{hilite_color}}=(); }
1266 # return @{$self->{hilite_color}};
1267 return $self->get_label()->get_hilite_color();
1270 =head2 function set_hilite_color()
1272 Sets the hilite color. Default is yellow. Three numbers between 0 and 255 for red, green and blue channels are required.
1274 =cut
1276 sub set_hilite_color {
1277 my $self = shift;
1278 $self->get_label()->set_hilite_color(@_);
1281 =head2 function get_offset_text_color()
1283 Gets the current offset text color (the color of the line
1284 that connects the marker tick with the marker name).
1286 =cut
1288 sub get_offset_text_color {
1289 my $self = shift;
1290 #if (!exists($self->{offset_text_color})) { @{$self->{offset_text_color}}=(); }
1291 return $self->get_offset_label()->get_text_color();
1292 #return @{$self->{offset_text_color}};
1295 =head2 function set_offset_text_color()
1297 Sets the color of the offset scale text, if enabled.
1299 =cut
1301 sub set_offset_text_color {
1302 my $self = shift;
1303 $self->get_offset_label()->set_text_color(@_);
1306 =head2 function get_text_color()
1308 gets the color of the label text.
1310 =cut
1313 sub get_text_color {
1314 my $self = shift;
1315 return $self->get_label()->get_text_color();
1318 =head2 function set_text_color()
1320 sets the color of the label text.
1322 =cut
1324 sub set_text_color {
1325 my $self = shift;
1326 $self->get_label()->set_text_color(@_);
1330 =head2 accessors get_order_in_loc(), set_order_in_loc()
1332 Synopsis: I think this is deprecated...
1333 Arguments:
1334 Returns:
1335 Side effects:
1336 Description:
1338 =cut
1340 sub get_order_in_loc {
1341 my $self=shift;
1342 return $self->{order_in_loc};
1345 sub set_order_in_loc {
1346 my $self=shift;
1347 $self->{order_in_loc}=shift;
1351 =head2 functions get_location_subscript(), set_location_subscript()
1353 Synopsis: sets the location subscript of this marker position
1354 Arguments: setter: a subscript, usually "a".."c" or similar
1355 Returns: getter: the current subscript
1356 Side effects: the subscript will be rendered on the map,
1357 added to the marker name. The CXGN::Cview::Marker function
1358 get_name() will also include the subscript, whereas
1359 get_marker_name() will not.
1360 Description:
1362 =cut
1364 sub get_location_subscript {
1365 my $self=shift;
1366 return $self->{location_subscript};
1369 sub set_location_subscript {
1370 my $self=shift;
1371 $self->{location_subscript}=shift;
1374 =head2 accessors get_loc_type(), set_loc_type()
1376 Synopsis:
1377 Arguments:
1378 Returns:
1379 Side effects:
1380 Description:
1382 =cut
1384 sub get_loc_type {
1385 my $self=shift;
1386 return $self->{loc_type};
1389 sub set_loc_type {
1390 my $self=shift;
1391 $self->{loc_type}=shift;
1394 =head2 accessors get_loc_order(), set_loc_order()
1396 Synopsis: I think this is deprecated.
1397 Arguments:
1398 Returns:
1399 Side effects:
1400 Description:
1402 =cut
1404 sub get_loc_order {
1405 my $self=shift;
1406 return $self->{loc_order};
1409 sub set_loc_order {
1410 my $self=shift;
1411 $self->{loc_order}=shift;
1414 =head2 has_range
1416 Usage: my $flag = $m->has_range()
1417 Desc: returns true if the marker has a range defined
1418 (usually using set_north_range() and set_south_range())
1419 false otherwise.
1420 Side Effects: none
1421 Example:
1423 =cut
1425 sub has_range {
1426 my $self = shift;
1427 if ( ($self->get_end() - $self->get_start()) > 12) { return 1;}
1428 return 0;