fix parameters for MapFactory object.
[cview.git] / lib / CXGN / Cview / ChromosomeViewer.pm
blob2c238f9941cc227189ff234e7c7eb8e9dc0911cd
1 package CXGN::Cview::ChromosomeViewer;
2 use strict;
3 use warnings;
5 use File::Spec;
7 use CXGN::DB::Connection;
8 use CXGN::Tools::WebImageCache;
9 use CXGN::Cview::Map::Tools;
10 use CXGN::Cview;
11 use CXGN::Cview::Utils qw|set_marker_color get_maps_select get_chromosome_links|;
12 use CXGN::Cview::MapImage;
13 use CXGN::Cview::Chromosome;
14 use CXGN::Cview::Chromosome::Physical;
15 use CXGN::Cview::Chromosome::PachyteneIdiogram;
16 use CXGN::Cview::IL;
17 use CXGN::Cview::ChrLink;
18 use CXGN::Cview::MapFactory;
20 use base qw| CXGN::DB::Object |;
22 =head1 NAME
24 CXGN::Cview::ChromosomeViewer -- a module to display comparative chromosome maps
26 =head1 SYNOPSIS
28 my $viewer = CXGN::Cview::ChromosomeViewer->new;
29 $viewer->set_map_id($map_id);
30 $viewer->set_map_version_id($map_version_id);
31 $viewer->set_ref_chr($chr_nr);
32 $viewer->set_cM($cM);
33 $viewer->set_zoom($zoom);
34 $viewer->set_show_physical($show_physical);
35 $viewer->set_show_ruler($show_ruler);
36 $viewer->set_show_IL($show_IL);
37 $viewer->set_comp_map_id($comp_map_id);
38 $viewer->set_comp_map_version_id($comp_map_version_id);
39 $viewer->set_comp_chr($comp_chr);
40 $viewer->set_color_model($color_model);
41 if ($map_chr_select) {
42 my ($comp_map_id, $comp_chr) = split / /, $map_chr_select;
43 $viewer->set_comp_map_id($comp_map_id);
44 $viewer->set_comp_chr($comp_chr);
46 $viewer->set_cM_start($cM_start);
47 $viewer->set_cM_end($cM_end);
48 $viewer->set_confidence($confidence);
49 $viewer->set_show_zoomed($show_zoomed);
50 $viewer->set_hilite_zoomed($zoomed_hilite_start, $zoomed_hilite_end);
51 $viewer->set_force($force);
53 $viewer->generate_page();
55 =head1 DESCRIPTION
57 =head2 Image Caching
59 ChromosomeViewer caches the images it produces using CXGN::Tools::WebImageCache. The expiration time is set to a day or so.
61 The cache for the image generated by any given URL can be reset by setting the force parameter to 1.
64 =head1 AUTHOR(S)
66 Lukas Mueller (lam87@cornell.edu)
68 =head1 FUNCTIONS
70 The following functions are defined in the class:
72 =cut
74 =head2 function new()
76 Synopsis: generates a new chromosome_viewer object
77 Parameters: $dbh - a database handle
78 Returns: an object handle
79 Side effects: sets some useful default values, creates an SGN page object and
80 establishes a connection to the database through the page object.
81 Status: implemented
82 Example:
84 =cut
86 sub new {
87 my $class = shift;
88 my $dbh = shift;
90 if ( !$dbh ) { die "ChromosomeViewer now takes a dbh parameter."; }
91 my $self = $class->SUPER::new( $dbh, @_ );
93 $self->{unzoomedheight} = 20; # how many cM are seen at zoom level 1
95 # $self -> {raster_size} = 5; # the default raster size for genetic maps
96 # for sequence-based maps this will be changed to 1
97 # later on.
98 $self->set_temp_dir("/tmp")
99 ; # set some default for the temp_dir. However, this
100 # should be visible by apache (which tmp isn't).
101 return $self;
104 =head2 function _adjust_parameters()
106 Synopsis: adjusts parameters; needs to be called before calling generate_image
107 Parameters: none
108 Returns: nothing
109 Side effects: adjusts parameters to make program more robust against out-of-range
110 parameters
111 Status: implemented
112 Example:
113 Notes: this function is only used internally
115 =cut
117 sub _adjust_parameters {
118 my $self = shift;
120 # initialize some variables to prevent undefined blabla errors
121 $self->{fatal_errors} = "";
122 if ( !$self->get_ref_chr() ) { $self->set_ref_chr(1); }
123 if ( !$self->get_hilite() ) { $self->set_hilite(""); }
124 if ( !( $self->get_cM_start() ) ) { $self->set_cM_start(0); }
126 # print STDERR "\n *** Map ID is : ".($self->get_map_id())." ***\n";
128 # It's possible for our objects to have empty strings for map_id attributes.
129 # The following weirdness preserves the interface invariant that get_map_id sets
130 # a desirable default map_id.
132 my $map_id = $self->get_map_id();
134 if ( $self->get_map_version_id() ) {
135 $self->set_map_id(0);
138 if ( $self->get_comp_map_version_id() ) {
139 $self->set_comp_map_id(0);
142 if ( !$self->get_map_version_id() && $map_id eq '' ) {
143 $self->set_map_id(undef);
144 $map_id = $self->get_map_id();
147 # generate the map objects
149 my $map_factory =
150 CXGN::Cview::MapFactory->new( $self->get_dbh(), { cview_db_backend=>$self->get_db_backend() });
152 # print STDERR "Generating MapFactory with id ".$self->get_map_version_id()."\n";
153 # print STDERR "IS A ".ref($map_factory)."\n";
155 $self->set_ref_map(
156 $map_factory->create(
158 map_version_id => $self->get_map_version_id(),
159 map_id => $self->get_map_id()
164 if ( !$self->get_ref_map() ) {
166 # if an illegal map id was supplied, create a default map.
167 $self->set_ref_map(
168 $map_factory->create(
169 { map_id => CXGN::Cview::Map::Tools::current_tomato_map_id() }
172 $self->append_error("Note: Displaying default map, F2-2000.");
175 $self->{ref_map_name} = $self->get_ref_map()->get_short_name();
176 $self->set_map_version_id( $self->get_ref_map()->get_id() );
177 $self->{ref_map_type} = $self->get_ref_map()->get_type();
179 if ( $self->get_comp_map_id() || $self->get_comp_map_version_id() ) {
180 $self->set_comp_map(
181 $map_factory->create(
183 map_version_id => $self->get_comp_map_version_id(),
184 map_id => $self->get_comp_map_id()
189 # { map_id => $self->get_comp_map_id(),
190 # map_version_id => $self->get_comp_map_version_id(),
192 # ));
195 # define the comparison map
197 if ( $self->get_comp_map() ) {
198 $self->{comp_map_name} = $self->get_comp_map()->get_short_name();
199 $self->set_comp_map_version_id( $self->get_comp_map()->get_id() );
200 $self->{comp_map_type} = $self->get_comp_map()->get_type();
202 # @{$self->{comp_chromo_names}} = $self->get_chr_names($self->get_comp_map_id());
203 @{ $self->{comp_chromo_names} } =
204 $self->get_comp_map()->get_chromosome_names();
206 #$self->{comp_max_chr} = $self->get_chr_count($self->get_comp_map_id());
207 $self->{comp_max_chr} = scalar( @{ $self->{comp_chromo_names} } );
210 # test if the supplied chromosome is a legal chromosome on the specific map.
211 # if not, try to find a close match.
213 #if (!$self->is_ok_chr($self->get_map_id(), $self->get_ref_chr())) {
214 if ( !$self->get_ref_map()->has_linkage_group( $self->get_ref_chr() ) ) {
216 # print STDERR "chr ".$self->get_ref_chr()." is not a valid chromosome\n";
217 my $old_chr = $self->get_ref_chr();
218 my $chr = $old_chr;
219 $chr =~ s/.*(\d{1,2}.*)/$1/;
221 #if (!$self->is_ok_chr($self->get_map_id(), $chr)) {
222 if ( !$self->get_ref_map()->has_linkage_group($chr) ) {
223 $chr =~ s/.*(\d).*/$1/;
225 if ( !$self->get_ref_map()->has_linkage_group($chr) ) {
227 #$self->append_errors("The specified chromosome ($old_chr) was not found on map $self->{ref_map_name}!<br /><br />");
228 $self->set_ref_chr(1);
230 else {
231 $self->set_ref_chr($chr);
232 $self->append_error(
233 "The chromosome/linkage group $old_chr does not seem to exist on map "
234 . $self->get_ref_map()->get_short_name()
235 . ". The closest we could find was $chr, displayed below.<br /><br />"
240 # if no map_id was supplied, we show the F2.2000 as default
242 if ( !$self->get_map_id() ) {
243 $self->set_map_id( CXGN::Cview::Map::Tools::current_tomato_map_id() );
246 # @{$self->{chromo_names}} = $self->get_chr_names($self->{map_id});
247 @{ $self->{chromo_names} } = $self->get_ref_map()->get_chromosome_names();
249 #$self->{max_chr} = $self->get_chr_count($self->get_map_id());;
250 # get the number of chromosomes of the map.
252 $self->{max_chr} = scalar( $self->get_ref_map()->get_chromosome_count() );
254 if ( $self->get_ref_chr() < 0 ) {
255 $self->set_ref_chr( abs( $self->get_ref_chr() ) );
258 # set the default zoom size in MB for sequence maps
260 $self->{unzoomedheight} = $self->get_ref_map()->initial_zoom_height();
262 # $self->{unzoomedheight}=4;
266 # adjust cM_start and cM_end if the chromosome was clicked.
268 # if ((($self->get_cM_start()==0) && ($self->get_cM_end()==0)) || ($self->get_cM_end()-$self->get_cM_start()==0)) {
270 $self->set_ref_chr_len(
271 $self->get_ref_map()->get_chr_len_by_name( $self->get_ref_chr() ) );
272 if ( $self->get_cM_start() > $self->get_cM_end() ) {
273 $self->set_cM_start( $self->get_cM_end() );
274 $self->set_cM_end( $self->get_cM_start() +
275 $self->get_ref_map()->initial_zoom_height() );
278 $self->{zoom_length} = $self->get_cM_end() - $self->get_cM_start();
280 if ( $self->{zoom_length} == 0 ) {
281 $self->{zoom_length} = $self->get_ref_map()->initial_zoom_height();
284 if ( $self->get_clicked() ) {
286 #die "Was going to reset cM_start and cM_end (cM defined... ".($self->get_cM()).")\n";
287 my $start = $self->get_cM() - ( $self->{zoom_length} / 2 );
288 my $end = $self->get_cM() + ( $self->{zoom_length} / 2 );
290 if ( $start < 0 ) {
291 $start = 0;
292 $end = $self->{zoom_length};
295 # print STDERR "REF CHR: ".$self->get_ref_chr()."\n";
297 if ( $end > $self->get_ref_chr_len() ) {
298 $end = $self->get_ref_chr_len();
299 $start = $end - $self->{zoom_length};
302 $self->set_cM_start($start);
303 $self->set_cM_end($end);
307 # $self->set_clicked(0);
309 # adjust the cM start value if it is below zero. This could (but shouldn't) happen
310 # during scrolling and zooming operations.
312 if ( $self->get_cM_start() < 0 ) {
313 $self->set_cM_start(0);
314 $self->set_cM_end( $self->{zoom_length} );
315 $self->set_cM( ( $self->get_cM_start() + $self->get_cM_end() ) / 2 );
317 if ( $self->get_cM_end() > $self->get_ref_chr_len() ) {
318 my $end = $self->get_ref_chr_len();
319 $self->set_cM_end($end);
320 $self->set_cM_start( $end - $self->{zoom_length} );
323 if ( !$self->{ref_map_name} ) {
324 $self->{fatal_errors} .=
325 "Fatal error: The map id you entered is invalid.<br />";
328 if ( $self->get_show_physical()
329 && ( !$self->get_ref_map()->has_physical() ) )
331 $self->append_error(
332 "Note: You selected to show physical maps for a map that does not have an associated physical map. The physical map has been turned off.<p /> "
334 $self->set_show_physical(0);
337 my $message = "";
338 if ( $self->get_confidence() == 0 ) {
339 $message = "I(LOD<2) and above [all]";
341 elsif ( $self->get_confidence() == 1 ) { $message = "I(LOD2) and above"; }
342 elsif ( $self->get_confidence() == 2 ) { $message = "CF(LOD3) and above"; }
343 elsif ( $self->get_confidence() == 3 ) { $message = "F(LOD>=3)"; }
344 if ( $self->get_confidence() > -2 ) {
345 $self->append_error("Only showing confidence of $message\n<p />");
348 # note: the force parameter is not part of the state hashref, because it
349 # would change the key and thus the cache file name.
351 my $state_hashref = {
352 chr_nr => $self->get_ref_chr(),
353 map_version_id => $self->get_map_version_id(),
354 cM => $self->{cM},
355 show_ruler => $self->{show_ruler},
356 show_IL => $self->{show_IL},
357 show_offsets => $self->get_show_offsets(),
358 comp_map_version_id => $self->get_comp_map_version_id(),
359 comp_chr => $self->{comp_chr},
360 color_model => $self->{color_model},
361 show_physical => $self->{show_physical},
362 size => $self->{size},
363 show_zoomed => $self->{show_zoomed},
364 confidence => $self->{confidence},
365 hilite => $self->{hilite},
366 marker_type => $self->{display_marker_type},
367 cM_start => $self->get_cM_start(),
368 cM_end => $self->get_cM_end(),
370 #clicked => $self->get_clicked(),
374 # print STDERR "STATE HASHREF CONTENTS: \n";
375 # foreach my $k (%$state_hashref) {
376 ## print STDERR "$k = $$state_hashref{$k}.\n";
378 $self->set_state_hashref($state_hashref);
382 =head2 function generate_page()
384 Synopsis: generates the page to STDOUT in html
385 Parameters: none
386 Returns: nothing
387 Side effects:
388 Status: implemented
389 Example:
391 =cut
393 sub generate_page {
394 my $self = shift;
395 if ( $self->{fatal_errors} ) { return; }
397 $self->_adjust_parameters();
399 $self->get_image();
400 $self->display_toolbar();
404 =head2 function get_image()
406 Synopsis: generates the viewer image as a png file
407 Parameters: none
408 Returns: an array with the image path (semi-absolute) and the image url
409 Side effects: creates the image and stores it into a file
410 Status: implemented
411 Example:
413 =cut
415 sub get_image {
416 my $self = shift;
418 my $cache = CXGN::Tools::WebImageCache->new();
419 my $state_hashref = $self->get_state_hashref();
421 my @sorted_values = map {
422 if ( exists( $state_hashref->{$_} ) && defined( $state_hashref->{$_} ) )
424 $state_hashref->{$_};
426 } sort keys %$state_hashref;
427 my $key = join "-", @sorted_values;
429 # print STDERR "USING KEY: $key\n";
430 $cache->set_key($key);
431 $cache->set_expiration_time(86400);
432 $cache->set_basedir( $self->get_basedir() );
434 $cache->set_temp_dir( $self->get_temp_dir() );
436 $cache->set_map_name("imagemap");
437 $cache->set_force( $self->get_force() );
439 if ( !$cache->is_valid() ) {
440 $self->generate_image();
441 $cache->set_image_data( $self->{map}->render_png_string() );
442 $cache->set_image_map_data( $self->{map}->get_image_map("imagemap") );
444 $self->{image_html} = $cache->get_image_html();
447 sub generate_image {
448 my $self = shift;
450 my $x_distance =
451 120; # the number of pixels the different elements are spaced
452 my $element_count = 0.5; # the number of elements currently placed
454 my $map_width = 500;
456 if ( $self->get_show_zoomed() ) {
457 $map_width += $x_distance;
459 if ( $self->get_show_IL() ) { $map_width += $x_distance; }
461 #print STDERR "Size requested: $self->{size}\n";
462 if ( $self->get_size() =~ /small/i ) {
463 $self->{map_height} = 300;
464 $self->set_chr_height(230);
466 elsif ( $self->get_size() =~ /large/i ) {
467 $self->{map_height} = 800;
468 $self->set_chr_height(650);
470 else {
471 $self->{map_height} = 470;
472 $self->set_chr_height(400);
475 #print STDERR "Chr height: $self->{chr_height}\n";
476 $self->{map} =
477 CXGN::Cview::MapImage->new( "", $map_width, $self->{map_height} );
479 # show IL lines if requested
481 if ( $self->get_show_IL() && $self->get_ref_map()->has_IL() ) {
482 my $map_factory =
483 CXGN::Cview::MapFactory->new( $self->get_dbh(),
484 { cview_db_backend => $self->get_db_backend()} );
486 #print STDERR "Current map_id = ".$self->get_map_id()."\n";
487 my $IL_map = $map_factory->create(
488 { map_version_id => "il6." . ( $self->get_map_id() ) } );
489 $self->{IL} = $IL_map->get_chromosome( $self->get_ref_chr() );
491 $self->{IL}->set_height( $self->get_chr_height() );
492 $self->{IL}->set_horizontal_offset( $x_distance * $element_count, 40 );
493 $self->{IL}->set_vertical_offset(40);
494 $self->{IL}->set_caption("IL");
496 $self->{map}->add_chromosome( $self->{IL} );
497 $element_count = $element_count + 0.95;
500 elsif ( $self->get_show_IL() && !$self->get_ref_map()->has_IL() ) {
501 $self->append_error(
502 "You chose to display the IL information for a map that has no associated IL information.
503 The IL display has been turned off.<P>"
505 $self->set_show_IL(0);
508 # show the physical map if requested
510 if ( $self->get_show_physical() ) {
511 my $map_factory =
512 CXGN::Cview::MapFactory->new( $self->get_dbh(),
513 { cview_db_backend => $self->get_db_backend()} );
515 my $physical_map = $map_factory->create( { map_version_id => "p9" } );
517 # we get the overview chromosome, because it is more compact for the comparison
519 $self->{p} =
520 $physical_map->get_overview_chromosome( $self->get_ref_chr() );
521 $self->{p}->set_horizontal_offset( $x_distance * $element_count );
522 $self->{p}->set_vertical_offset(40);
523 $self->{p}->set_height( $self->get_chr_height() );
525 $self->{map}->add_physical( $self->{p} );
528 # add the chromosome
530 $element_count++;
532 $self->{c1} = $self->get_ref_map()->get_chromosome( $self->get_ref_chr() );
534 #if ($self->get_show_offsets()) { $self->{c1}->set_display_marker_offset(); }
536 # adjust the appearance of the chromosome
538 $self->{c1}->set_height( $self->get_chr_height() );
539 $self->{c1}->set_vertical_offset(40);
540 $self->{c1}->set_horizontal_offset( $x_distance * $element_count );
541 $self->{c1}->set_caption( $self->get_ref_chr() );
542 $self->{c1}->set_labels_left();
544 $self->{c1}->set_units( $self->get_ref_map->get_units() );
545 $self->{c1}
546 ->set_width( $self->get_ref_map()->get_preferred_chromosome_width() );
548 $self->append_error( $self->get_ref_map()->get_messages() );
549 my @m = $self->{c1}->get_markers();
552 # get the markers and determine the highest confidence level
554 my $highest = -1;
555 foreach my $m (@m) {
556 if ( $m->get_confidence() > $highest ) {
557 $highest = $m->get_confidence();
560 my @fm = ();
561 foreach my $m (@m) {
562 if ( $m->get_confidence() == $highest ) { push @fm, $m; }
566 my $interval = 0;
567 if ( $self->get_ref_map()->collapsed_marker_count() ) {
568 $interval = @fm / $self->get_ref_map()->collapsed_marker_count();
571 if ( @m < $self->get_ref_map()->collapsed_marker_count() ) {
572 $interval = 1;
574 my $frame_marker_count = 0;
575 for ( my $i = 0 ; $i < @m ; $i++ ) {
576 $m[$i]->hide_label();
579 # show label if it is hilited...
581 my $marker_name = $m[$i]->get_name();
582 if ( $self->get_hilite() =~ /\b$marker_name\b/i ) {
583 $m[$i]->show_label();
584 $m[$i]->hilite();
588 # otherwise only show one in $interval markers of the
589 # highest confidence
591 if ( $interval > 0 ) {
592 if ( $m[$i]->get_confidence() == $highest ) {
593 if ( $interval > 1 ) {
594 if ( $frame_marker_count % $interval == 0 ) {
595 $m[$i]->show_label();
599 else { $m[$i]->show_label(); }
600 $frame_marker_count++;
604 set_marker_color( $m[$i], $self->get_color_model() );
605 if ( $m[$i]->get_confidence() < $self->get_confidence() ) {
606 $m[$i]->hide_label();
611 # make the chromosome clickable using the rasterize function and
612 # add the url
614 #my $raster_size = int($self->{c1}->get_length() / 20) || 2;
615 if ( $self->get_ref_map()->can_zoom() ) {
616 $self->{c1}->rasterize(1); #$raster_size);
617 $self->{c1}->set_rasterize_link( "view_chromosome.pl?map_version_id="
618 . ( $self->get_map_version_id() )
619 . "&amp;chr_nr="
620 . ( $self->get_ref_chr() )
621 . "&amp;show_physical="
622 . ( $self->get_show_physical() )
623 . "&amp;show_IL="
624 . ( $self->get_show_IL() )
625 . "&amp;show_ruler="
626 . ( $self->get_show_ruler() )
627 . "&amp;show_offsets="
628 . ( $self->get_show_offsets() )
629 . "&amp;color_model="
630 . ( $self->get_color_model() )
631 . "&amp;comp_map_version_id="
632 . ( $self->get_comp_map_version_id() )
633 . "&amp;comp_chr="
634 . ( $self->get_comp_chr() )
635 . "&amp;zoom="
636 . ( $self->get_zoom() )
637 . "&amp;size="
638 . ( $self->get_size() )
639 . "&amp;hilite="
640 . ( $self->get_hilite() )
641 . "&amp;confidence="
642 . ( $self->get_confidence() )
643 . "&amp;show_zoomed=1&amp;marker_type="
644 . ( $self->get_display_marker_type() )
645 . "&amp;cM_start="
646 . ( $self->get_cM_start() )
647 . "&amp;cM_end="
648 . ( $self->get_cM_end() )
649 . "&amp;clicked=1&amp;cM=" );
652 $self->{map}->add_chromosome( $self->{c1} );
655 # show the ruler if requested
657 if ( $self->get_show_ruler() ) {
658 $self->{r} = $self->{c1}->get_ruler();
659 $self->{r}->set_horizontal_offset( $x_distance / 6 );
660 $self->{r}->set_vertical_offset(40);
661 $self->{r}->set_height( $self->get_chr_height() );
662 $self->{r}->set_start_value(0);
663 $self->{r}->set_end_value( $self->{c1}->get_length() );
664 $self->{r}->set_units( $self->get_ref_map()->get_units() );
665 $self->{map}->add_ruler( $self->{r} );
669 # draw the chromosome section if a chromosome section was requested
670 # (that is, if cM is defined)
673 my $x_offset = 200;
674 my @m2; # the markers on c2. Keep for later use.
675 if ( $self->{show_zoomed} && $self->get_ref_map()->can_zoom() ) {
677 $element_count++;
679 #$self->{c2} = CXGN::Cview::Chromosome -> new ($self->get_ref_chr(), $self->get_chr_height(), $x_distance*$element_count, 40);
680 $self->{c2} = $self->get_ref_map()->get_chromosome_section(
681 $self->get_ref_chr(), $self->get_cM_start(),
682 $self->get_cM_end(), $self->get_comp_chr()
684 if ( $self->get_show_offsets() ) {
685 $self->{c2}->set_display_marker_offset();
687 $self->{c2}->set_height( $self->get_chr_height() );
688 $self->{c2}->set_vertical_offset(40);
689 $self->{c2}->set_hilite( $self->get_hilite_zoomed() );
690 $self->{c2}->set_horizontal_offset( $x_distance * $element_count );
691 $self->{c2}->set_units( $self->{c1}->get_units() );
693 # because we have incomplete length information from the query above,
694 # we set the length of the zoomed in chromosome
695 # to be the same as the comparison chromosome (the length is simply
696 # the marker position of the bottom marker)
698 $self->{c2}->set_length( $self->{c1}->get_length() );
701 # correct the cM_start and cM_end if out of range
703 #if ($self->get_cM_start() < 0) { $self->set_cM_start(0); }
704 if ( $self->get_cM_end() > $self->{c2}->get_length() ) {
705 $self->set_cM_end( $self->{c2}->get_length() );
708 # $self->{c2}->set_units( $self->{c1}->get_units() );
709 $self->{c2}->set_color( 255, 220, 220 );
710 @m2 = $self->{c2}->get_markers();
713 # go through the markers and show them according to confidence filter,
714 # add mark for overgo information etc.
716 for ( my $i = 0 ; $i < @m2 ; $i++ ) {
719 # hilite markers to be hilited
721 my $marker_name = $m2[$i]->get_name();
722 if ( $self->get_hilite() =~ /\b$marker_name\b/i ) {
723 $m2[$i]->hilite();
724 $m2[$i]->get_label()->set_hidden(0);
728 # hide markers with confidence below confidence threshold
730 if ( $m2[$i]->get_confidence() < $self->{confidence} ) {
731 $m2[$i]->hide_label();
735 # hide markers that are not of the type that should be displayed
737 my $marker_type = $self->get_display_marker_type();
738 if ( $self->get_display_marker_type()
739 && ( $m2[$i]->get_marker_type() !~ /$marker_type/i ) )
741 $m2[$i]->hide_label();
743 set_marker_color( $m2[$i], $self->get_color_model() );
746 # set the url only if the marker is visible (otherwise imagemap outside the image will be
747 # generated that confuses some browsers (such as Explorer).
749 if ( $m2[$i]->is_visible() ) {
752 else {
754 $m[$i]->hide_mark();
759 # set up the section and connections to the left hand chromosome
761 $self->{c2}->set_section( $self->get_cM_start(), $self->get_cM_end() );
762 $self->{c1}->set_hilite_color( 255, 220, 220 );
763 $self->{c1}->set_hilite( $self->get_cM_start(), $self->get_cM_end() );
764 $self->{link1} = CXGN::Cview::ChrLink->new(
765 $self->{c1}, $self->get_cM_start(),
766 $self->{c2}, $self->get_cM_start()
768 $self->{link1}->set_color( 10, 10, 10 );
769 $self->{link2} = CXGN::Cview::ChrLink->new(
770 $self->{c1}, $self->get_cM_end(),
771 $self->{c2}, $self->get_cM_end()
773 $self->{link2}->set_color( 10, 10, 10 );
774 $self->{map}->add_chr_link( $self->{link1} );
775 $self->{map}->add_chr_link( $self->{link2} );
777 $self->{map}->add_chromosome( $self->{c2} );
781 # draw the map comparison if the map comparison was requested (comp_map comp_chr will be defined).
783 my @m3;
784 if ( $self->get_comp_map() && $self->get_comp_chr() ) {
786 #print STDERR "Generating the comparative map...\n";
788 $element_count++;
790 #$self->{c3} = CXGN::Cview::chromosome -> new ($self->get_comp_chr(), $self->{chr_height}, $x_distance * $element_count, 40);
792 $self->{c3} =
793 $self->get_comp_map()->get_chromosome( $self->get_comp_chr() );
795 $self->{c3}->set_height( $self->get_chr_height() );
796 $self->{c3}->set_horizontal_offset( $x_distance * $element_count );
797 $self->{c3}->set_vertical_offset(40);
798 $self->{c3}->set_units( $self->get_comp_map()->get_units() );
800 #print STDERR "Fetching map $self->{comp_map} chr $self->{comp_chr} from the database...\n";
802 #print STDERR "Adjusting colors etc...\n";
803 $self->{c3}->set_color( 150, 150, 200 );
804 $self->{c3}->set_caption( $self->get_comp_chr() );
806 @m3 = $self->{c3}->get_markers();
808 #print STDERR "$self->{comp_chr} has ".@m3." markers...\n";
809 for ( my $i = 0 ; $i < @m3 ; $i++ ) {
811 #print STDERR "Marker read:". $m3[$i]->get_name()."\n";
812 CXGN::Cview::Utils::set_marker_color( $m3[$i],
813 $self->get_color_model() );
817 #print STDERR "Adding the chromosome to the map...\n";
818 $self->{map}->add_chromosome( $self->{c3} );
821 # determine if the magnified section exists -- then draw the correspondence lines to that chromosome object (c2)
822 # else draw them to the original chromosome object (c1).
824 if ( exists( $self->{c2} ) ) {
825 $self->{c2}->set_labels_left();
827 my $link_list = get_chromosome_links( $self->{c2}, $self->{c3} );
828 foreach my $clink ( $link_list->get_link_list() ) {
829 $self->{map}->add_chr_link($clink);
832 foreach my $m3 (@m3) {
833 $m3->hide_label();
834 if ( $link_list->has_link( $m3->get_marker_name() ) ) {
835 $m3->show_label();
838 if ( $m3->get_confidence < $self->{confidence} ) {
839 $m3->hide_label();
841 my $marker_name = $m3->get_name();
842 if ( $self->get_hilite() =~ /\b$marker_name\b/i ) {
843 $m3->show_label();
844 $m3->hilite();
848 else {
850 #print STDERR "LINKS:::::::::::::::\n";
851 my $link_list = get_chromosome_links( $self->{c1}, $self->{c3} );
852 foreach my $clink ( $link_list->get_link_list() ) {
854 #print STDERR " adding link...\n";
855 $self->{map}->add_chr_link($clink);
857 foreach my $m3 (@m3) {
858 $m3->hide_label();
859 set_marker_color( $m3, $self->get_color_model() );
861 if ( $link_list->has_link( $m3->get_marker_name() ) ) {
862 $m3->show_label();
864 if ( $m3->get_confidence < $self->{confidence} ) {
865 $m3->hide_label();
867 if ( $m3->get_name() eq $self->get_hilite() ) {
868 $m3->show_label();
869 $m3->hilite();
873 $element_count++;
874 if ( $self->get_show_ruler() ) {
875 $self->{r3} = $self->{c3}->get_ruler();
876 $self->{r3}->set_horizontal_offset( $element_count * $x_distance );
877 $self->{r3}->set_vertical_offset(40);
878 $self->{r3}->set_height( $self->get_chr_height() );
879 $self->{r3}->set_start_value(0);
880 $self->{r3}->set_end_value( $self->{c3}->get_length() );
882 $self->{map}->add_ruler( $self->{r3} );
887 =head2 function get_chr_height()
889 Synopsis: Accessor for the chr_height property
890 Arguments: none
891 Returns: the current chr_height
892 Side effects: The chromosomes are being drawn with the chr_height in pixels
893 Description:
895 =cut
897 sub get_chr_height {
898 my $self = shift;
899 return $self->{chr_height};
902 =head2 function set_chr_height()
904 Synopsis:
905 Arguments: the chromosome height in pixels. In small mode, height is 230 pixels, and
906 normal mode the height is 400 pixels.
907 Returns:
908 Side effects:
909 Description:
911 =cut
913 sub set_chr_height {
914 my $self = shift;
915 $self->{chr_height} = shift;
918 =head2 accessors get_ref_map(), set_ref_map()
920 Usage:
921 Desc:
922 Args/Ret: the reference map as a CXGN::Cview::Map object
923 of the appropriate sub-class.
924 Side Effects: this will be the map displayed as the reference
925 map (on the left).
926 Example:
928 =cut
930 sub get_ref_map {
931 my $self = shift;
932 if ( !exists( $self->{ref_map} ) ) { $self->{ref_map} = undef; }
933 return $self->{ref_map};
937 sub set_ref_map {
938 my $self = shift;
939 $self->{ref_map} = shift;
942 =head2 accessors get_comp_map(), set_comp_map()
944 Usage:
945 Property: the comparison map, as a CXGN::Cview::Map object
946 (or subclass thereof)
947 Desc:
948 Side Effects:
949 Example:
951 =cut
953 sub get_comp_map {
954 my $self = shift;
955 if ( !exists( $self->{comp_map} ) || !defined( $self->{comp_map} ) ) {
956 $self->{comp_map} = undef;
958 return $self->{comp_map};
962 sub set_comp_map {
963 my $self = shift;
964 $self->{comp_map} = shift;
967 =head2 accessors set_map_id(), get_map_id()
969 Synopsis: sets the map_id for the reference chromosome
970 Parameters: map_id (integer)
971 Returns:
972 Side effects: the map corresponding to map_id will be drawn as the reference chromosome
973 Status: DEPRECATED. Call $chr_viewer->get_ref_map()->get_id() instead...
974 Example:
976 =cut
978 sub set_map_id {
979 my $self = shift;
980 $self->{map_id} = shift;
983 sub get_map_id {
984 my $self = shift;
986 # if (!exists($self->{map_id})) { $self->{map_id}=0; }
987 if ( !exists( $self->{map_id} ) || !defined( $self->{map_id} ) ) {
988 $self->{map_id} = 0;
990 return $self->{map_id};
993 =head2 accessors get_default_map_id, set_default_map_id
995 Usage:
996 Desc:
997 Property
998 Side Effects:
999 Example:
1001 =cut
1003 sub get_default_map_id {
1004 my $self = shift;
1005 return $self->{default_map_id};
1008 sub set_default_map_id {
1009 my $self = shift;
1010 $self->{default_map_id} = shift;
1014 =head2 accessors get_map_version_id(), set_map_version_id()
1016 Usage:
1017 Desc: the map_version_id of the reference map
1018 Ret:
1019 Args:
1020 Side Effects:
1021 Example:
1023 =cut
1025 sub get_map_version_id {
1026 my $self = shift;
1027 return $self->{map_version_id};
1031 sub set_map_version_id {
1032 my $self = shift;
1033 $self->{map_version_id} = shift;
1036 =head2 accessors get_comp_map_version_id(), set_comp_map_version_id()
1038 Usage:
1039 Desc: the map_version_id of the comparison map
1040 Ret:
1041 Args:
1042 Side Effects:
1043 Example:
1045 =cut
1047 sub get_comp_map_version_id {
1048 my $self = shift;
1049 if ( !exists( $self->{comp_map_version_id} )
1050 || !defined( $self->{comp_map_version_id} ) )
1052 $self->{comp_map_version_id} = '';
1054 return $self->{comp_map_version_id};
1058 sub set_comp_map_version_id {
1059 my $self = shift;
1060 $self->{comp_map_version_id} = shift;
1063 =head2 function set_comp_map_id()
1065 Synopsis: setter function for the map id of the comparison chromosome
1066 Parameters: the map id (integer)
1067 Returns: nothing
1068 Side effects: the specified map will be drawn as the reference chromosome
1069 Status: implemented
1070 Example:
1072 =cut
1074 sub set_comp_map_id {
1075 my $self = shift;
1076 $self->{comp_map_id} = shift;
1079 =head2 function get_comp_map_id()
1081 Synopsis: get the current map id of the comparison chromosome
1082 Parameters:
1083 Returns: map id of the comparison chromosome
1084 Side effects:
1085 Status: implemented
1086 Example:
1088 =cut
1090 sub get_comp_map_id {
1091 my $self = shift;
1092 if ( !exists( $self->{comp_map_id} ) || !defined( $self->{comp_map_id} ) ) {
1093 $self->{comp_map_id} = 0;
1095 return $self->{comp_map_id};
1098 =head2 function set_ref_chr()
1100 Synopsis: setter function for the specifying the reference chromosome
1101 number/linkage group name
1102 Parameters: the desired chromosome number/linkage group name (string)
1103 Returns:
1104 Side effects: the specified chromosome/linkage group will be displayed as
1105 the reference chromosome
1106 Status: implemented
1107 Example:
1109 =cut
1111 sub set_ref_chr {
1112 my $self = shift;
1113 $self->{chr_nr} = shift;
1116 =head2 function get_ref_chr()
1118 Synopsis: accessor function for set_ref_chr
1119 Parameters:
1120 Returns: the chromosome number/linkage group name for the reference
1121 chromosome/linkage group
1122 Side effects:
1123 Status: implemented
1124 Example:
1126 =cut
1128 sub get_ref_chr {
1129 my $self = shift;
1130 if ( !exists( $self->{chr_nr} ) || !defined( $self->{chr_nr} ) ) {
1131 $self->{chr_nr} = 0;
1133 return $self->{chr_nr};
1136 =head2 function set_comp_chr()
1138 Synopsis: setter function for specifying the comparison chromosome/linkage
1139 group
1140 Parameters: chromosome number/linkage group name
1141 Returns: nothing
1142 Side effects: the corrsponding chromosome will be drawn as the comparison chromosome
1143 Status: implemented
1144 Example:
1146 =cut
1148 sub set_comp_chr {
1149 my $self = shift;
1150 $self->{comp_chr} = shift;
1153 =head2 function get_comp_chr()
1155 Synopsis: accessor function for set_comp_chr
1156 Parameters:
1157 Returns:
1158 Side effects:
1159 Status: implemented
1160 Example:
1162 =cut
1164 sub get_comp_chr {
1165 my $self = shift;
1166 if ( !exists( $self->{comp_chr} ) || !defined( $self->{comp_chr} ) ) {
1167 $self->{comp_chr} = 0;
1169 return $self->{comp_chr};
1172 =head2 accessors get_ref_chr_len, set_ref_chr_len
1174 Usage:
1175 Desc:
1176 Property
1177 Side Effects:
1178 Example:
1180 =cut
1182 sub get_ref_chr_len {
1183 my $self = shift;
1184 if ( !exists( $self->{ref_chr_len} ) || !defined( $self->{ref_chr_len} ) ) {
1185 $self->{ref_chr_len} = '';
1187 return $self->{ref_chr_len};
1190 sub set_ref_chr_len {
1191 my $self = shift;
1192 $self->{ref_chr_len} = shift;
1195 =head2 function set_cM_start()
1197 Synopsis: for a chromosome section, sets the starting point in cM
1198 Parameters: cM start position
1199 Returns: nothing
1200 Side effects: cleans the input to be an integer
1201 Status: implemented
1202 Example:
1204 =cut
1206 sub set_cM_start {
1207 my $self = shift;
1208 my $cM_start = shift;
1209 $cM_start =~ s/[^0-9.]//g;
1211 #$cM_start =~ s/.*?(\d+\.?\d*).*/$1/;
1212 $self->{cM_start} = abs($cM_start);
1215 =head2 function get_cM_start()
1217 Synopsis: accessor function for the cM_start property
1218 Parameters:
1219 Returns:
1220 Side effects:
1221 Status: implemented
1222 Example:
1224 =cut
1226 sub get_cM_start {
1227 my $self = shift;
1228 if ( !exists( $self->{cM_start} ) || !defined( $self->{cM_start} ) ) {
1229 $self->{cM_start} = 0;
1232 return sprintf "%.2f", $self->{cM_start};
1235 =head2 function set_cM_end()
1237 Synopsis: sets the end of a chromosome /linkage group section, in cM
1238 Parameters: cM of end of section
1239 Returns: nothing
1240 Side effects: On a chromosome section, this will define the endpoints of the section.
1241 If set_section has not been called, this will define which section is
1242 hilited. The cM and zoom property will be automatically re-calculated.
1243 Status: implemented
1244 Example:
1246 =cut
1248 sub set_cM_end {
1249 my $self = shift;
1250 my $cM_end = shift;
1251 $cM_end =~ s/[^0-9.]//g;
1252 if ( !defined($cM_end) || !$cM_end ) { $cM_end = 0; }
1253 $self->{cM_end} = abs( ($cM_end) );
1256 =head2 function get_cM_end()
1258 Synopsis: accessor function for the cM_end property
1259 Parameters:
1260 Returns:
1261 Side effects:
1262 Status: implemented
1263 Example:
1265 =cut
1267 sub get_cM_end {
1268 my $self = shift;
1269 if ( !exists( $self->{cM_end} ) || !defined( $self->{cM_end} ) ) {
1270 $self->{cM_end} = 0;
1272 return sprintf "%.2f", $self->{cM_end};
1275 =head2 function set_cM()
1277 Synopsis: sets the cM property. This is the approximate location in which
1278 the user has clicked. If set_cM is set, cM_start and cM_end will be
1279 calculated automatically using the current zoom levels.
1280 Parameters: the cM position (integer)
1281 Returns: nothing
1282 Side effects: recalculates cM_start and cM_end.
1283 Status: implemented
1284 Example:
1286 =cut
1288 sub set_cM {
1289 my $self = shift;
1290 $self->{cM} = shift;
1293 =head2 function get_cM()
1295 Synopsis: accessor function for the cM property
1296 Parameters:
1297 Returns:
1298 Side effects:
1299 Status: implemented
1300 Example:
1302 =cut
1304 sub get_cM {
1305 my $self = shift;
1306 if ( !exists( $self->{cM} ) || !defined( $self->{cM} ) ) {
1307 $self->{cM} = 0;
1309 return $self->{cM};
1312 =head2 function set_zoom()
1314 Synopsis: sets the zoom level on the reference chromosome
1315 Parameters: zoom level (1..10). 10 is the highest zoom level (most enlarged section
1316 showing fewer markers). Zoom levels outside the legal range are rounded to
1317 the nearest legal value.
1318 Returns: nothing
1319 Side effects:
1320 Status: Deprecated. Zooming is now implemented by setting cM_start and cM_end
1321 Example:
1323 =cut
1325 sub set_zoom {
1326 my $self = shift;
1327 $self->{zoom} = shift;
1328 if ( !exists( $self->{zoom} )
1329 || !defined( $self->{zoom} )
1330 || $self->{zoom} eq "" )
1332 $self->{zoom} = 0;
1334 if ( $self->{zoom} == 0 ) { $self->{zoom} = 1; }
1335 if ( $self->{zoom} > 10 ) { $self->{zoom} = 10; }
1338 =head2 function get_zoom()
1340 Synopsis: accessor function for the zoom property.
1341 Parameters:
1342 Returns: the current zoom level (1..10)
1343 Side effects:
1344 Status: Deprecated. Zooming is now implented by directly setting cM_start and cM_end.
1345 Example:
1347 =cut
1349 sub get_zoom {
1350 my $self = shift;
1351 if ( !exists( $self->{zoom} ) || !defined( $self->{zoom} ) ) {
1352 $self->{zoom} = 1;
1354 return $self->{zoom};
1357 =head2 accessors get_clicked, set_clicked
1359 Usage: my $flag = $cv -> get_clicked()
1360 Desc: returns true if this page should be regenerated
1361 as a response to a user clicking on the chromosome
1362 (instead of using some of the toolbar buttons),
1363 false otherwise.
1364 Property:
1365 Side Effects:
1366 Example:
1368 =cut
1370 sub get_clicked {
1371 my $self = shift;
1372 if ( !exists( $self->{clicked} ) || !defined( $self->{clicked} ) ) {
1373 $self->{clicked} = 0;
1375 return $self->{clicked};
1378 sub set_clicked {
1379 my $self = shift;
1380 $self->{clicked} = shift;
1383 =head2 function get_show_ruler()
1385 Synopsis: accessor function for the show_ruler property.
1386 Parameters: none
1387 Returns: true if ruler is shown, false otherwise
1388 Side effects:
1389 Status: implemented
1390 Example:
1392 =cut
1394 sub get_show_ruler {
1395 my $self = shift;
1396 if ( !exists( $self->{show_ruler} ) || !defined( $self->{show_ruler} ) ) {
1397 $self->{show_ruler} = 0;
1399 return $self->{show_ruler};
1402 =head2 function set_show_ruler()
1404 Synopsis: setter function for the show_ruler property.
1405 Parameters: true or false (0 or 1)
1406 Returns: nothing
1407 Side effects: true causes the ruler to be displayed for both the reference and comparison map
1408 (if present), false hides the ruler.
1409 Status: implemented
1410 Example:
1412 =cut
1414 sub set_show_ruler {
1415 my $self = shift;
1416 $self->{show_ruler} = shift;
1419 =head2 function set_show_IL()
1421 Synopsis: setter function for the show_IL property
1422 Parameters: true or false
1423 Returns: nothing
1424 Side effects: if the current reference map has associated IL information, true will
1425 cause the IL map to be displayed alongside with the chromosome.
1426 Status: implemented
1427 Example:
1429 =cut
1431 sub set_show_IL {
1432 my $self = shift;
1433 $self->{show_IL} = shift;
1436 =head2 function get_show_IL()
1438 Synopsis: accessor function for the show_IL property
1439 Parameters: none
1440 Returns: true or false
1441 Side effects: none
1442 Status: implemented
1443 Example:
1445 =cut
1447 sub get_show_IL {
1448 my $self = shift;
1449 if ( !exists( $self->{show_IL} ) || !defined( $self->{show_IL} ) ) {
1450 $self->{show_IL} = 0;
1452 return $self->{show_IL};
1455 =head2 function set_show_physical()
1457 Synopsis: true causes the physical map to be displayed if the current reference map
1458 has an associated physical map
1459 Parameters: true/false
1460 Returns: nothing
1461 Side effects:
1462 Status: implemented
1463 Example:
1465 =cut
1467 sub set_show_physical {
1468 my $self = shift;
1469 $self->{show_physical} = shift;
1472 =head2 function get_show_physical()
1474 Synopsis: true causes the physical map to be displayed if the current reference map
1475 has an associated physical map
1476 Parameters: none
1477 Returns: true/false
1478 Side effects:
1479 Status: implemented
1480 Example:
1482 =cut
1484 sub get_show_physical {
1485 my $self = shift;
1486 if ( !exists( $self->{show_physical} )
1487 || !defined( $self->{show_physical} ) )
1489 $self->{show_physical} = 0;
1491 return $self->{show_physical};
1494 =head2 accessors set_show_offsets(), get_show_offsets()
1496 Property: if the offsets should be shown (each marker will display a
1497 label opposite of the marker label, showing the offset in map
1498 units for that marker, for the zoomed-in section
1499 Side Effects:
1500 Description:
1502 =cut
1504 sub get_show_offsets {
1505 my $self = shift;
1506 if ( !exists( $self->{show_offsets} ) || !defined( $self->{show_offsets} ) )
1508 $self->{show_offsets} = 0;
1510 return $self->{show_offsets};
1513 sub set_show_offsets {
1514 my $self = shift;
1515 $self->{show_offsets} = shift;
1518 =head2 function get_size()
1520 Synopsis: accessor function for the size property
1521 Parameters: none
1522 Returns: "small" or "normal" or "large"
1523 Side effects:
1524 Status: implemented
1525 Example:
1527 =cut
1529 sub get_size {
1530 my $self = shift;
1531 if ( !exists( $self->{size} ) or !defined( $self->{size} ) ) {
1532 $self->{size} = 0;
1534 return $self->{size};
1537 =head2 function set_size()
1539 Synopsis: sets the size of the image
1540 Parameters: string ("normal", "small" and "large" are currently supported).
1541 Returns: nothing
1542 Side effects: "smaller" causes the entire map image to be rendered smaller
1543 (ideal for a laptop monitor)
1544 "normal" causes the entire map image to be rendered to fit a desktop monitor
1545 (>=17\")
1546 "larger" for really large monitors (>20\")
1547 Status: implemented
1548 Example:
1550 =cut
1552 sub set_size {
1553 my $self = shift;
1554 $self->{size} = shift;
1557 =head2 function set_hilite()
1559 Synopsis: hilites the specified markers on the reference map (unhides if necessary)
1560 on the zoomed-in map and on the comparison map.
1561 Parameters: a string, containing an enumeration of marker names to be hilited, separated
1562 by spaces (although other delimiters will also work such as comma, semicolons,
1563 etc.)
1564 Returns: nothing
1565 Side effects: the hilited marker name will appear with a yellow background.
1566 Status: implemented
1567 Example:
1569 =cut
1571 sub set_hilite {
1572 my $self = shift;
1573 my $hilite = shift || '';
1574 $hilite =~ tr/\,\.\:\;\// /;
1575 $hilite =~ s/\s+/ /;
1576 $self->{hilite} = $hilite;
1580 =head2 function get_hilite()
1582 Synopsis: accessor function for the hilite property
1583 Parameters: none
1584 Returns: the name of the currently hilited marker
1585 Side effects:
1586 Status: implemented
1587 Example:
1589 =cut
1591 sub get_hilite {
1592 my $self = shift;
1593 if ( !exists( $self->{hilite} ) || !defined( $self->{hilite} ) ) {
1594 $self->{hilite} = "";
1596 return $self->{hilite};
1599 =head2 function set_confidence()
1601 Synopsis: sets the minimal confidence level to be displayed
1602 Parameters: confidence level (-1, 0..3)
1603 -1: uncalculated confidence, 0 - interval marker ... 3 - frame marker
1604 Returns: nothing
1605 Side effects: markers below the specified confidence level will be hidden
1606 Status: implemented
1607 Example:
1609 =cut
1611 sub set_confidence {
1612 my $self = shift;
1613 my $confidence = shift || '';
1614 $confidence =~ s/[A-Za-z]//g;
1615 if ( !defined($confidence) || $confidence eq "" ) { $confidence = -2; }
1616 $confidence = $confidence + 0;
1617 $self->{confidence} = $confidence;
1620 =head2 function get_confidence()
1622 Synopsis: accessor function for the confidence property
1623 Parameters: none
1624 Returns: the current lowest confidence level that is displayed
1625 Normal values for the confidence property are:
1626 -1: not calculated
1627 0 ILOD
1628 1 ILOD2
1629 2 CFLOD
1630 3 LOD3
1631 If the confidence property is not set, it will return -2,
1632 causing all markers to be displayed.
1633 Side effects: markers with a lower confidence value (see list above) won\'t be
1634 displayed.
1635 Status: implemented
1636 Example:
1638 =cut
1640 sub get_confidence {
1641 my $self = shift;
1642 if ( !exists( $self->{confidence} ) || !defined( $self->{confidence} ) ) {
1643 $self->{confidence} = -2;
1645 return $self->{confidence};
1648 =head2 functions set_display_marker_type(), get_display_marker_type()
1650 Synopsis: $self->set_display_marker_type('COS');
1651 Arguments: a marker type. Any of COS, RFLP, ...
1652 Returns: nothing
1653 Side effects: Will also set $self->{error} to indicate to the
1654 user that marker type subsets are shown.
1655 Description: if set_display_marker_type is called with a marker
1656 type argument, only that marker type will be shown
1657 on the viewer. If called with undef, shows all markers.
1659 =cut
1661 sub set_display_marker_type {
1662 my $self = shift;
1663 my $type = shift;
1664 if ( $type && ( "RFLP CAPS COS SSR" =~ /\b$type\b/ ) ) {
1665 $self->{display_marker_type} = $type;
1666 $self->append_error(
1667 "Only markers of the type $self->{display_marker_type} are shown on the zoomed map.<br />"
1672 sub get_display_marker_type {
1673 my $self = shift;
1674 if ( !exists( $self->{display_marker_type} )
1675 || !defined( $self->{display_marker_type} ) )
1677 $self->{display_marker_type} = "";
1679 return $self->{display_marker_type};
1682 =head2 function set_show_zoomed()
1684 Synopsis: setter function for the show_zoomed property
1685 Parameters: show_zoomed property (0 or 1)
1686 Returns: status of the current show_zoomed property (0 or 1)
1687 Side effects: 0 will cause the zoomed in chromosome section not to be drawn
1688 1 will cause a zoomed in chromosome section to be drawn
1689 Status: implemented
1690 Example:
1692 =cut
1694 sub set_show_zoomed {
1695 my $self = shift;
1696 $self->{show_zoomed} = shift;
1699 =head2 function get_show_zoomed()
1701 Synopsis: accessor function for the show_zoomed property
1702 Parameters: none
1703 Returns: status of the current show_zoomed property (0 or 1)
1704 Side effects: none
1705 Status: implemented
1706 Example:
1708 =cut
1710 sub get_show_zoomed {
1711 my $self = shift;
1712 if ( !exists( $self->{show_zoomed} ) || !defined( $self->{show_zoomed} ) ) {
1713 $self->{show_zoomed} = 0;
1715 return $self->{show_zoomed};
1718 =head2 accessors get_hilite_zoomed(), set_hilite_zoomed()
1720 Usage: $chr_viewer->set_hilite_zoomed($cM_start, $cM_end)
1721 Desc: hilites the given region in the zoomed-in section,
1722 using the current hilite color.
1723 Ret: The getter returns the start and end in cM
1724 Args: the start in cM [real], the end in cM [real]
1725 Side Effects: hilites the corresponding region
1726 Notes: the intended use for this is to hilite sections,
1727 such as the boundaries for ILs on the zoomed in
1728 chromosome.
1730 =cut
1732 sub set_hilite_zoomed {
1733 my $self = shift;
1734 $self->{hilite_zoom_start} = shift;
1735 $self->{hilite_zoom_end} = shift;
1739 sub get_hilite_zoomed {
1740 my $self = shift;
1741 if ( !exists( $self->{hilite_zoom_start} )
1742 || !defined( $self->{hilite_zoom_start} ) )
1744 $self->{hilite_zoom_start} = '';
1746 if ( !exists( $self->{hilite_zoom_end} )
1747 || !defined( $self->{hilite_zoom_end} ) )
1749 $self->{hilite_zoom_end} = '';
1751 return ( $self->{hilite_zoom_start}, $self->{hilite_zoom_end} );
1754 =head2 function get_color_model()
1756 Synopsis:
1757 Parameters: name of color model (currently, confidence and marker_type are supported)
1758 Returns: nothing
1759 Side effects: sets the color model property to the specified color model
1760 Status: implemented
1761 Example:
1763 =cut
1765 sub set_color_model {
1766 my $self = shift;
1767 $self->{color_model} = shift;
1770 =head2 function get_color_model()
1772 Synopsis:
1773 Parameters: none
1774 Returns: the name of the current marker color model
1775 Side effects: none
1776 Status: implemented
1777 Example:
1779 =cut
1781 sub get_color_model {
1782 my $self = shift;
1783 if ( !exists( $self->{color_model} ) || !defined( $self->{color_model} ) ) {
1784 $self->{color_model} = "";
1786 return $self->{color_model};
1789 =head2 function get_color_legend()
1791 Synopsis:
1792 Parameters: none
1793 Returns: a string containing html code for the marker color legend
1794 Side effects: none
1795 Status: implemented
1796 Example:
1798 =cut
1800 sub get_color_legend {
1801 my $self = shift;
1802 my $string = "";
1803 my $link =
1804 "view_chromosome.pl?map_version_id="
1805 . $self->get_map_version_id()
1806 . "&amp;chr_nr="
1807 . $self->get_ref_chr()
1808 . "&amp;show_physical="
1809 . $self->get_show_physical
1810 . "&amp;show_IL="
1811 . $self->get_show_IL()
1812 . "&amp;show_offsets="
1813 . $self->get_show_offsets()
1814 . "&amp;show_ruler="
1815 . $self->get_show_ruler()
1816 . "&amp;color_model="
1817 . $self->get_color_model()
1818 . "&amp;comp_map_version_id="
1819 . $self->get_comp_map_version_id()
1820 . "&amp;comp_chr="
1821 . $self->get_comp_chr()
1822 . "&amp;zoom="
1823 . $self->get_zoom()
1824 . "&amp;size="
1825 . $self->get_size()
1826 . "&amp;cM="
1827 . $self->get_cM()
1828 . "&amp;cM_start="
1829 . $self->get_cM_start()
1830 . "&amp;cM_end="
1831 . $self->get_cM_end()
1832 . "&amp;hilite="
1833 . $self->get_hilite()
1834 . "&amp;show_zoomed="
1835 . $self->get_show_zoomed() . "";
1836 if ( $self->{color_model} eq "marker_types" ) {
1838 $string = "<b>Marker color by type:</b>
1839 <a href=\"$link\&marker_type=RFLP\" style=\"color:#FF0000\">RFLP</a> |
1840 <a href=\"$link\&marker_type=SSR\" style=\"color:#00FF00\">SSR</a> |
1841 <a href=\"$link\&marker_type=CAPS\" style=\"color:#0000FF\">CAPS</a> |
1842 <a href=\"$link\&marker_type=COS\" style=\"color:#FF00FF\">COS</a> |
1843 <font color=#000000>other</font>
1844 [<a href=\"$link\&marker_type=\" style=\"color:#111111\">show all</a>]";
1847 else {
1848 $string = "<b>Marker color by LOD score:</b>
1849 <a href=\"$link\&amp;confidence=3\" style=\"color:#FF0000\">F(LOD3)</a> |
1850 <a href=\"$link\&amp;confidence=2\" style=\"color:#00FF00\">CF(LOD>=3</a> |
1851 <a href=\"$link\&amp;confidence=1\" style=\"color:#0000FF\">I(LOD2)</a> |
1852 <a href=\"$link\&amp;confidence=0\" style=\"color:#000000\">I(LOD&lt;2)</a> |
1853 <a href=\"$link\&amp;confidence=-2\" style=\"color:#777777\">uncalculated</a> ";
1855 return $string;
1858 =head2 function get_marker_map_links()
1860 Synopsis:
1861 Parameters: none
1862 Returns: a string with html code for the marker map links pull down menu.
1863 if there is no appropriate map linked to the reference map,
1864 a string is returned that says so.
1865 Side effects: calls the get_chromosome_connections() function of the reference
1866 map object.
1867 Status: implemented
1868 Example:
1869 Notes:
1870 Version:
1872 =cut
1874 sub get_marker_map_links {
1875 my $self = shift;
1877 #print STDERR "get_marker_map_links...\n";
1878 # query the database for maps and chromosome that any of the markers of the current chromosome lie on.
1880 my $chr_nr = $self->get_ref_chr();
1881 my $default_map = CXGN::Cview::Map::SGN::Genetic->new(
1882 $self->get_dbh(),
1883 CXGN::Cview::Map::Tools::find_current_version(
1884 $self->get_dbh(), #CXGN::Cview::Map::Tools::current_tomato_map_id()
1885 $self->get_default_map_id(),
1889 my $default_map_version_id = $default_map->get_id();
1891 my $form =
1892 "<form style=\"margin-bottom:0\" action=\"/cview/view_chromosome.pl\">
1893 <input type=\"hidden\" name=\"chr_nr\" value=\""
1894 . ( $self->get_ref_chr() ) . "\" />
1895 <input type=\"hidden\" name=\"map_version_id\" value=\""
1896 . ( $self->get_map_version_id() ) . "\" />
1897 <input type=\"hidden\" name=\"zoom\" value=\"" . ( $self->get_zoom() ) . "\" />
1898 <input type=\"hidden\" name=\"show_ruler\" value=\""
1899 . ( $self->get_show_ruler() ) . "\" />
1900 <input type=\"hidden\" name=\"show_IL\" value=\""
1901 . ( $self->get_show_IL() ) . "\" />
1902 <input type=\"hidden\" name=\"show_offsets\" value=\""
1903 . ( $self->get_show_offsets() ) . "\" />
1904 <input type=\"hidden\" name=\"cM_start\" value=\""
1905 . ( $self->get_cM_start() ) . "\" />
1906 <input type=\"hidden\" name=\"cM_end\" value=\""
1907 . ( $self->get_cM_end() ) . "\" />
1908 <input type=\"hidden\" name=\"show_physical\" value=\""
1909 . ( $self->get_show_physical() ) . "\" />
1910 <input type=\"hidden\" name=\"color_model\" value=\""
1911 . ( $self->get_color_model() ) . "\" />
1912 <input type=\"hidden\" name=\"size\" value=\""
1913 . ( $self->get_size() ) . "\" />
1914 <input type=\"hidden\" name=\"show_zoomed\" value=\""
1915 . ( $self->get_show_zoomed() ) . "\" />
1916 <input type=\"hidden\" name=\"hilite\" value=\""
1917 . ( $self->get_hilite() ) . "\" />
1918 <input type=\"hidden\" name=\"marker_type\" value=\""
1919 . ( $self->get_display_marker_type() ) . "\" /> ";
1921 my @options =
1922 $self->get_ref_map()->get_chromosome_connections( $self->get_ref_chr() );
1924 if (@options) {
1926 $form .= "<select name=\"map_chr_select\">";
1927 foreach my $o (@options) {
1929 # print STDERR $o->{map_version_id}, $o->{chr_nr}, $o->{short_name}."<br />\n";
1930 my $selected = "";
1932 if ( defined( $self->get_comp_map_version_id() )
1933 && $o->{map_version_id} eq $self->get_comp_map_version_id() )
1935 $selected = "selected=\"selected\"";
1938 $form .=
1939 qq { <option value="$o->{map_version_id} $o->{lg_name}" $selected>Map $o->{short_name} Chromosome $o->{lg_name} ($o->{marker_count} markers)</option> };
1942 $form .= "</select>\n";
1943 $self->{compare_disabled} = "";
1945 else {
1946 $form .= "<select name=\"map_chr_select\" disabled=\"disabled\" >";
1947 $form .=
1948 "<option value=\"\" disabld=\"disabled\" >No maps to compare to</option>";
1949 $form .= "</select>\n";
1950 $self->{compare_disabled} = qq{ disabled="disabled" };
1953 $form .=
1954 "<input type=\"submit\" value=\"Compare\" $self->{compare_disabled} /></form>";
1956 return $form;
1959 sub append_error {
1960 my $self = shift;
1961 my $append = shift || '';
1962 if ( !exists( $self->{errors} ) || !defined( $self->{errors} ) ) {
1963 $self->{errors} = "";
1965 $self->{errors} .= $append;
1968 sub get_errors {
1969 my $self = shift;
1970 return $self->{errors};
1973 =head2 function get_preceding_chromosome()
1975 Synopsis: gives the name of the chromosome or linkage group preceding the
1976 given chromosome
1977 Parameters: chromosome name / linkage group name
1978 Returns: the chromosome number or linkage group name preceding this
1979 chromosome/linkage group
1980 Side effects: none
1981 Status: implemented
1982 Example:
1983 Notes:
1984 Version:
1986 =cut
1988 sub get_preceding_chromosome {
1989 my $self = shift;
1990 my $chr_nr = shift;
1991 my $chr_count = scalar( @{ $self->{chromo_names} } );
1992 my $chr_index = 0;
1993 my $old_chr_index = 0;
1996 # find current chromosome in chromo_names array (a hash would be more elegant...)
1998 for ( my $i = 0 ; $i < ( @{ $self->{chromo_names} } ) ; $i++ ) {
1999 if ( ${ $self->{chromo_names} }[$i] eq $chr_nr ) {
2000 $old_chr_index = $i;
2004 if ( $old_chr_index == 0 ) { $chr_index = $chr_count - 1; }
2005 else { $chr_index = $old_chr_index - 1; }
2006 return ${ $self->{chromo_names} }[$chr_index];
2009 =head2 function get_next_chromosome()
2011 Synopsis: gives the name of the chromosome or linkage group following the given
2012 chromosome
2013 Parameters: chromosome name / linkage group name
2014 Returns: the chromosome number or linkage group name following this
2015 chromosome/linkage group
2016 Side effects: none
2017 Status: implemented
2018 Example:
2019 Notes:
2020 Version:
2022 =cut
2024 sub get_next_chromosome {
2025 my $self = shift;
2026 my $chr_nr = shift;
2027 my $chr_count = scalar( @{ $self->{chromo_names} } );
2028 my $chr_index = 0;
2029 my $old_chr_index = 0;
2030 for ( my $i = 0 ; $i < ( @{ $self->{chromo_names} } ) ; $i++ ) {
2031 if ( ${ $self->{chromo_names} }[$i] eq $chr_nr ) {
2032 $old_chr_index = $i;
2036 if ( $old_chr_index == ( $chr_count - 1 ) ) { $chr_index = 0; }
2037 else { $chr_index = $old_chr_index + 1; }
2038 return ${ $self->{chromo_names} }[$chr_index];
2041 sub get_preceding_comp_chromosome {
2042 my $self = shift;
2043 my $chr_nr = shift;
2044 if ( !( $self->get_comp_map() ) ) {
2045 return "?";
2047 my $chr_count = scalar( @{ $self->{comp_chromo_names} } );
2048 my $chr_index = 0;
2049 my $old_chr_index = 0;
2051 for ( my $i = 0 ; $i < ( @{ $self->{comp_chromo_names} } ) ; $i++ ) {
2052 if ( ${ $self->{comp_chromo_names} }[$i] eq $chr_nr ) {
2053 $old_chr_index = $i;
2057 if ( $old_chr_index == 0 ) { $chr_index = $chr_count - 1; }
2058 else { $chr_index = $old_chr_index - 1; }
2059 return ${ $self->{comp_chromo_names} }[$chr_index];
2062 sub get_next_comp_chromosome {
2063 my $self = shift;
2064 my $chr_nr = shift;
2065 if ( !( $self->get_comp_map() ) ) {
2066 return "?";
2068 else {
2069 my $chr_count = scalar( @{ $self->{comp_chromo_names} } );
2070 my $chr_index = 0;
2071 my $old_chr_index = 0;
2072 for ( my $i = 0 ; $i < ( @{ $self->{comp_chromo_names} } ) ; $i++ ) {
2073 if ( ${ $self->{comp_chromo_names} }[$i] eq $chr_nr ) {
2074 $old_chr_index = $i;
2078 if ( $old_chr_index == ( $chr_count - 1 ) ) { $chr_index = 0; }
2079 else { $chr_index = $old_chr_index + 1; }
2080 return ${ $self->{comp_chromo_names} }[$chr_index];
2085 =head2 function display_toolbar()
2087 Synopsis: displays the toolbar by printing html to STDOUT
2088 Parameters: none
2089 Returns: nothing
2090 Side effects: prints html code to STDOUT
2091 Status: implemented
2092 Example:
2094 =cut
2096 sub display_toolbar {
2097 my $self = shift;
2099 #$self->{scrolldown} = $self->{cM}+2*$self->{unzoomedheight}/$self->{zoom}/3;
2101 $self->{scrolldown_start} =
2102 $self->get_cM_start() + ( $self->{zoom_length} / 2 );
2103 $self->{scrolldown_end} =
2104 $self->get_cM_end() + ( $self->{zoom_length} / 2 );
2105 if ( $self->{scrolldown_end} > $self->get_ref_chr_len() ) {
2107 $self->{scrolldown_end} = $self->get_ref_chr_len();
2108 $self->{scrolldown_start} =
2109 $self->{scrolldown_end} - $self->{zoom_length};
2112 #$self->{scrollup} = $self->{cM}-2*$self->{unzoomedheight}/$self->{zoom}/3;
2113 $self->{scrollup_start} =
2114 $self->get_cM_start() - ( $self->{zoom_length} / 2 );
2115 $self->{scrollup_end} = $self->get_cM_end() - ( $self->{zoom_length} / 2 );
2116 if ( $self->{scrollup_start} < 0 ) {
2117 $self->{scrollup_start} = 0;
2118 $self->{scrollup_end} = $self->{zoom_length};
2121 if ( $self->{zoom_length} == 0 ) { die "ZOOM LENGTH IS 0!\n"; }
2123 #$self->{zoom_in} = $self->{zoom}+1;
2124 $self->{zoom_in_start} =
2125 $self->get_cM_start() + ( $self->{zoom_length} / 4 );
2126 $self->{zoom_in_end} = $self->get_cM_end() - ( $self->{zoom_length} / 4 );
2128 #$self->{zoom_out} = $self->{zoom}-1;
2129 $self->{zoom_out_start} =
2130 $self->get_cM_start() - ( $self->{zoom_length} / 4 );
2131 $self->{zoom_out_end} = $self->get_cM_end + ( $self->{zoom_length} / 4 );
2133 if ( $self->{zoom_out_end} > $self->get_ref_chr_len() ) {
2134 $self->{zoom_out_end} = $self->get_ref_chr_len();
2135 $self->{zoom_out_start} = $self->{zoom_out_end} - $self->{zoom_length};
2138 # set buttons to disabled when no zoomed-in chromosome is displayed.
2139 if ( !$self->{show_zoomed} || !$self->get_ref_map()->can_zoom() ) {
2140 $self->{zoom_in_disabled} = "disabled=\"disabled\"";
2141 $self->{zoom_out_disabled} = "disabled=\"disabled\"";
2142 $self->{scroll_up_disabled} = "disabled=\"disabled\"";
2143 $self->{scroll_down_disabled} = "disabled=\"disabled\"";
2146 # if (!$self->map_has_physical($self->{map_id})) {
2147 if ( !$self->get_ref_map()->has_physical() ) {
2148 $self->{physical_disabled} = "disabled=\"disabled\"";
2151 if ( !$self->get_ref_map()->has_IL() ) {
2152 $self->{IL_disabled} = qq { disabled="disabled" };
2154 else {
2155 $self->{IL_disabled} = "";
2158 if ( $self->{show_zoomed} ) {
2160 #$self->{zoom_in_disabled} = "";
2161 $self->{enable_zoom_text} = "Hide zoomed";
2162 $self->{enable_zoom_value} = 0;
2163 $self->{toggle_zoomed_section} = 0;
2165 else {
2166 $self->{zoom_in_disabled} = " disabled=\"disabled\" ";
2167 $self->{enable_zoom_text} = "Show zoomed";
2168 $self->{enable_zoom_value} = 1;
2169 $self->{toggle_zoomed_section} = 10;
2171 if ( !$self->get_ref_map->can_zoom() ) {
2172 $self->{zoomed_button_enabled} = " disabled=\"disabled\" ";
2175 # $self->{next_chromosome} = $self->{chr_nr} + 1;
2176 # if ($self->{next_chromosome} > $self->{max_chr}) { $self->{next_chromosome} = 1; }
2178 $self->{next_chromosome} =
2179 $self->get_next_chromosome( $self->get_ref_chr() );
2181 # $self->{preceding_chromosome} = $self->{chr_nr}-1;
2182 # if ($self->{preceding_chromosome} == 0) { $self->{preceding_chromosome} = $self->{max_chr}; }
2184 $self->{preceding_chromosome} =
2185 $self->get_preceding_chromosome( $self->get_ref_chr() );
2187 # $self->{next_comp_chr} = $self->{comp_chr} + 1;
2188 # if ($self->{next_comp_chr} > $self->{comp_max_chr}) { $self->{next_comp_chr} = 1; }
2190 $self->{next_comp_chr} =
2191 $self->get_next_comp_chromosome( $self->get_comp_chr() );
2193 # $self->{preceding_comp_chr} = $self -> {comp_chr} -1;
2194 # if ($self->{preceding_comp_chr} ==0 ) { $self->{preceding_comp_chr} = $self->{comp_max_chr}; }
2195 $self->{preceding_comp_chr} =
2196 $self->get_preceding_comp_chromosome( $self->get_comp_chr() );
2198 # $self->{imagemap} = $self->{map}->get_image_map("imagemap");
2200 $self->{marker_map_links} = $self->get_marker_map_links();
2202 my $comp_map_caption = "";
2203 my $chromo_designation = "chr";
2204 if ( $self->get_comp_chr() =~ /[A-Za-z]/ ) {
2205 $chromo_designation = "linkage group";
2207 if ( $self->get_comp_map_version_id() ) {
2208 $comp_map_caption =
2209 "<td>Comparing to $chromo_designation <b>$self->{comp_chr}</b> of map&nbsp;</td><td bgcolor=\"#9999CC\"><a href=\"/cview/map.pl?map_version_id=$self->{comp_map_version_id}\"><b>$self->{comp_map_name}</b></a>&nbsp;</td>";
2212 # some legends need to know the state of the script...
2213 $self->get_ref_map()->get_legend()
2214 ->set_state_hashref( $self->get_state_hashref() );
2215 $self->get_ref_map()->get_legend()->set_mode( $self->get_color_model() );
2216 my $color_legend = $self->get_ref_map()->get_legend()->get_legend_html();
2217 my $toggle_ruler = !( $self->{show_ruler} );
2218 my $toggle_physical = !( $self->{show_physical} );
2219 my $toggle_IL = !( $self->{show_IL} );
2220 my $toggle_offsets = !( $self->get_show_offsets() );
2222 my $toggle_size_select = qq { <select name="size" > };
2224 my @selected = ( '', '', '' );
2225 if ( $self->{size} =~ /small/i ) { $selected[0] = qq { selected="1" }; }
2226 elsif ( $self->{size} =~ /large/i ) { $selected[2] = qq { selected="1" }; }
2227 else { $selected[1] = qq { selected="1" }; }
2228 $toggle_size_select .=
2229 qq { <option value="small" $selected[0] >Small</option> };
2230 $toggle_size_select .=
2231 qq { <option value="normal" $selected[1] >Normal</option> };
2232 $toggle_size_select .=
2233 qq { <option value="large" $selected[2] >Large</option> };
2234 $toggle_size_select .= qq { </select> };
2236 if ( !$self->get_comp_map_version_id() ) {
2237 $self->{hide_comparison} = "disabled=\"disabled\"";
2240 $self->{maps_select} =
2241 CXGN::Cview::Utils::get_maps_select( $self->get_dbh(),
2242 $self->get_ref_map()->get_id(), undef, $self->get_db_backend);
2244 my $view_entire_map_link = "&nbsp;View entire comparative map";
2245 if ( $self->get_comp_map_version_id() ) {
2246 $view_entire_map_link =
2247 "&nbsp;<a href=\"/cview/view_maps.pl?center_map_version_id="
2248 . ( $self->get_ref_map()->get_id() )
2249 . "&amp;right_map_version_id=$self->{comp_map_version_id}\">View entire comparative map</a>";
2252 $self->{url_map_name} = $self->{ref_map_name};
2253 $self->{url_map_name} =~ s/ /\+/g;
2255 my $show_marker_link = "Show markers between 0 and 0 cM";
2256 if ( $self->{show_zoomed} && $self->get_ref_map()->can_zoom() ) {
2257 $show_marker_link = "<a href=\"/search/markers/markersearch.pl?
2258 w822_pos_start="
2259 . $self->get_cM_start()
2260 . "&amp;w822_pos_end="
2261 . $self->get_cM_end()
2262 . "&amp;w822_maps="
2264 CXGN::Cview::Map::Tools::find_map_id_with_version(
2265 $self->get_dbh(), $self->get_ref_map()->get_id()
2268 . "&amp;w822_confs=$self->{confidence}&amp;&amp;w822_submit=Search&amp;w822_chromos="
2269 . $self->get_ref_chr()
2270 . "\"\n>Search markers between "
2271 . ( $self->get_cM_start() ) . " and "
2272 . ( $self->get_cM_end() ) . " "
2273 . $self->get_ref_map()->get_units() . "</a>";
2275 $chromo_designation = "chr";
2276 if ( $self->get_ref_chr() =~ /[A-Za-z]/ ) {
2277 $chromo_designation = "linkage group";
2280 my $state_hashref = $self->get_state_hashref();
2282 my $scroll_up_button =
2283 CXGN::Cview::Chromosome_view::toolbar_button->new( "Scroll up",
2284 $state_hashref );
2285 $scroll_up_button->set_property( "cM_start", $self->{scrollup_start} );
2286 $scroll_up_button->set_property( "cM_end", $self->{scrollup_end} );
2287 $scroll_up_button->set_enabled( $self->{scroll_up_disabled} );
2288 my $scroll_up_html = $scroll_up_button->render_string();
2290 my $scroll_down_button =
2291 CXGN::Cview::Chromosome_view::toolbar_button->new( "Scroll down",
2292 $state_hashref );
2293 $scroll_down_button->set_property( "cM_start", $self->{scrolldown_start} );
2294 $scroll_down_button->set_property( "cM_end", $self->{scrolldown_end} );
2295 $scroll_down_button->set_enabled( $self->{scroll_down_disabled} );
2296 my $scroll_down_html = $scroll_down_button->render_string();
2298 my $zoom_in_button =
2299 CXGN::Cview::Chromosome_view::toolbar_button->new( "Zoom in",
2300 $state_hashref );
2301 $zoom_in_button->set_property( "cM_start", $self->{zoom_in_start} );
2302 $zoom_in_button->set_property( "cM_end", $self->{zoom_in_end} );
2303 $zoom_in_button->set_enabled( $self->{zoom_in_disabled} );
2304 my $zoom_in_html = $zoom_in_button->render_string();
2306 my $zoom_out_button =
2307 CXGN::Cview::Chromosome_view::toolbar_button->new( "Zoom out",
2308 $state_hashref );
2309 $zoom_out_button->set_property( "cM_start", $self->{zoom_out_start} );
2310 $zoom_out_button->set_property( "cM_end", $self->{zoom_out_end} );
2311 $zoom_out_button->set_enabled( $self->{zoom_out_disabled} );
2312 my $zoom_out_html = $zoom_out_button->render_string();
2314 my $show_zoomed_button = CXGN::Cview::Chromosome_view::toolbar_button->new(
2315 $self->{enable_zoom_text},
2316 $state_hashref );
2317 $show_zoomed_button->set_enabled( $self->{zoomed_button_enabled} );
2318 $show_zoomed_button->set_property( "show_zoomed",
2319 $self->{toggle_zoomed_section} );
2321 my $show_zoomed_html = $show_zoomed_button->render_string();
2323 my $hide_comparison_button =
2324 CXGN::Cview::Chromosome_view::toolbar_button->new( "Hide comparison",
2325 $state_hashref );
2326 $hide_comparison_button->set_property( "comp_map_version_id", 0 );
2327 $hide_comparison_button->set_property( "comp_chr", 0 );
2328 $hide_comparison_button->set_enabled( $self->{hide_comparison} );
2329 my $hide_comparison_html = $hide_comparison_button->render_string();
2331 my $switch_chromosomes_button =
2332 CXGN::Cview::Chromosome_view::toolbar_button->new( "Switch chromosomes",
2333 $state_hashref );
2334 $switch_chromosomes_button->set_property( "comp_chr",
2335 $self->get_ref_chr() );
2336 $switch_chromosomes_button->set_property( "chr_nr", $self->get_comp_chr() );
2337 $switch_chromosomes_button->set_property( "map_version_id",
2338 $self->get_comp_map_version_id() );
2339 $switch_chromosomes_button->set_property( "", "" );
2340 $switch_chromosomes_button->set_property( "", "" );
2341 $switch_chromosomes_button->set_property( "comp_map_version_id",
2342 $self->get_map_version_id() );
2343 $switch_chromosomes_button->set_enabled( $self->{hide_comparison} );
2344 my $switch_chromosomes_html = $switch_chromosomes_button->render_string();
2346 my $sync_preceding_chr_button =
2347 CXGN::Cview::Chromosome_view::toolbar_button->new( "&lt;&lt;",
2348 $state_hashref );
2349 $sync_preceding_chr_button->set_property( "chr_nr",
2350 $self->{preceding_chromosome} );
2351 $sync_preceding_chr_button->set_property( "comp_chr",
2352 $self->{preceding_comp_chr} );
2353 $sync_preceding_chr_button->set_enabled( $self->{hide_comparison} );
2354 my $sync_preceding_chr_html = $sync_preceding_chr_button->render_string();
2356 my $sync_next_chr_button =
2357 CXGN::Cview::Chromosome_view::toolbar_button->new( "&gt;&gt;",
2358 $state_hashref );
2359 $sync_next_chr_button->set_property( "chr_nr", $self->{next_chromosome} );
2360 $sync_next_chr_button->set_property( "comp_chr", $self->{next_comp_chr} );
2361 $sync_next_chr_button->set_enabled( $self->{hide_comparison} );
2362 my $sync_next_chr_html = $sync_next_chr_button->render_string();
2364 my $previous_chr_button = CXGN::Cview::Chromosome_view::toolbar_button->new(
2365 $self->{preceding_chromosome} . "&lt;",
2366 $state_hashref );
2367 $previous_chr_button->set_property( "chr_nr",
2368 $self->{preceding_chromosome} );
2369 my $previous_chr_html = $previous_chr_button->render_string();
2371 my $next_chr_button = CXGN::Cview::Chromosome_view::toolbar_button->new(
2372 "&gt;" . $self->{next_chromosome},
2373 $state_hashref );
2374 $next_chr_button->set_property( "chr_nr", $self->{next_chromosome} );
2375 my $next_chr_html = $next_chr_button->render_string();
2377 my $preceding_comp_chr_button =
2378 CXGN::Cview::Chromosome_view::toolbar_button->new(
2379 $self->{preceding_comp_chr} . "&lt;",
2380 $state_hashref );
2381 $preceding_comp_chr_button->set_property( "comp_chr",
2382 $self->{preceding_comp_chr} );
2383 $preceding_comp_chr_button->set_enabled( $self->{hide_comparison} );
2384 my $preceding_comp_chr_html = $preceding_comp_chr_button->render_string();
2386 my $next_comp_chr_button =
2387 CXGN::Cview::Chromosome_view::toolbar_button->new(
2388 "&gt;" . $self->{next_comp_chr},
2389 $state_hashref );
2390 $next_comp_chr_button->set_property( "comp_chr", $self->{next_comp_chr} );
2391 $next_comp_chr_button->set_enabled( $self->{hide_comparison} );
2392 my $next_comp_chr_html = $next_comp_chr_button->render_string();
2394 my $ruler_button =
2395 CXGN::Cview::Chromosome_view::toolbar_button->new( "Ruler",
2396 $state_hashref );
2397 $ruler_button->set_property( "show_ruler", $toggle_ruler );
2398 my $ruler_html = $ruler_button->render_string();
2400 my $physical_map_button =
2401 CXGN::Cview::Chromosome_view::toolbar_button->new( "Physical map",
2402 $state_hashref );
2403 $physical_map_button->set_property( "show_physical", $toggle_physical );
2404 $physical_map_button->set_enabled( $self->{physical_disabled} );
2405 my $physical_map_html = $physical_map_button->render_string();
2407 my $IL_button =
2408 CXGN::Cview::Chromosome_view::toolbar_button->new( "IL", $state_hashref );
2409 $IL_button->set_property( "show_IL", $toggle_IL );
2410 $IL_button->set_enabled( $self->{IL_disabled} );
2411 my $IL_html = $IL_button->render_string();
2413 my $offset_button =
2414 CXGN::Cview::Chromosome_view::toolbar_button->new( "Offsets",
2415 $state_hashref );
2416 $offset_button->set_property( "show_offsets", $toggle_offsets );
2417 $offset_button->set_enabled( $self->{zoom_button_enabled} );
2418 my $offset_html = $offset_button->render_string();
2420 # my $size_button = CXGN::Cview::Chromosome_view::toolbar_button -> new($size_button_text, $state_hashref);
2421 # $size_button -> set_property("size", $toggle_size);
2422 # my $size_html = $size_button -> render_string();
2424 my $errors = $self->get_errors();
2426 my $chr_nr = $self->get_ref_chr();
2427 my $map_version_id = $self->get_map_version_id();
2428 my $map_name = $self->get_ref_map()->get_short_name();
2429 my $zoom = $self->get_zoom();
2430 my $cM = $self->get_cM();
2431 my $show_ruler = $self->get_show_ruler();
2432 my $show_IL = $self->get_show_IL();
2433 my $show_offsets = $self->get_show_offsets();
2434 my $comp_map_version_id = $self->get_comp_map_version_id() || '';
2435 my $comp_chr = $self->get_comp_chr() || '';
2436 my $color_model = $self->get_color_model() || '';
2437 my $show_physical = $self->get_show_physical() || 0;
2438 my $size = $self->get_size() || 0;
2439 my $show_zoomed = $self->get_show_zoomed() || 0;
2440 my $confidence = $self->get_confidence() || -2;
2441 my $hilite = $self->get_hilite() || '';
2442 my $display_marker_type = $self->get_display_marker_type() || '';
2443 my $cM_start = $self->get_cM_start() || '';
2444 my $cM_end = $self->get_cM_end() || '';
2446 my $zoom_range_html = qq {
2447 <form style="margin-bottom:0" >
2448 <input type="hidden" name="map_version_id" value="$map_version_id" />
2449 <input type="hidden" name="chr_nr" value="$chr_nr" size="2" />
2450 <input type="hidden" name="show_ruler" value="$show_ruler" />
2451 <input type="hidden" name="show_IL" value="$show_IL" />
2452 <input type="hidden" name="show_offsets" value="$show_offsets" />
2453 <input type="hidden" name="comp_map_version_id" value="$comp_map_version_id" />
2454 <input type="hidden" name="comp_chr" value="$comp_chr" />
2455 <input type="hidden" name="color_model" value="$color_model" />
2456 <input type="hidden" name="show_physical" value="$show_physical" />
2457 <input type="hidden" name="size" value="$size" />
2458 <input type="hidden" name="show_zoomed" value="1" />
2459 <input type="hidden" name="confidence" value="$confidence" />
2460 <input type="hidden" name="hilite" value="$hilite" />
2461 <input type="hidden" name="marker_type" value="$display_marker_type" />
2463 <b>zoom range:</b> <input name="cM_start" size="3" value="$cM_start" /> to <input name="cM_end" size="3" value="$cM_end" />
2464 <input type="submit" value="show" />
2465 </form>
2468 print <<BUTTONS;
2470 $errors
2473 <table summary="" cellpadding="0" cellspacing="0"><tr><td>Viewing $chromo_designation <b>$chr_nr</b> of map &nbsp;</td><td bgcolor="#CC9999"><a href=\"/cview/map.pl?map_version_id=$map_version_id\"><b>$map_name</b></a></td><td>&nbsp;</td>
2474 $comp_map_caption
2475 <td>&nbsp;&nbsp;[<a href="/help/cview.pl">Help</a>]</td>
2476 </tr></table>
2478 <table summary="" cellpadding="0" cellspacing="0"><tr>
2479 <td>
2481 $self->{image_html}
2483 </td></tr></table>
2485 $color_legend
2488 <table summary="" cellpadding="0" cellspacing="0"><tr><td>
2490 $scroll_up_html
2493 </td><td>
2495 $scroll_down_html
2497 </td><td>
2499 $zoom_in_html
2502 </td><td>
2505 $zoom_out_html
2508 </td>
2510 <td>|</td><td>
2512 $show_zoomed_html
2515 </td>
2517 <td width="10">&nbsp;</td><td>
2519 $zoom_range_html
2520 <!-- $show_marker_link -->
2522 </td>
2524 </tr></table>
2526 <table summary="" cellpadding="0" cellspacing="0" border="0">
2527 <tr><td valign="middle" width="120"><b>Compare map to:</b>&nbsp;</td><td valign="middle">$self->{marker_map_links}</td></tr>
2528 </table>
2530 <table summary="" cellpadding="0" cellspacing="0">
2532 <tr><td width="120">&nbsp;</td><td>
2534 $hide_comparison_html
2537 </td>
2538 <td>
2540 $switch_chromosomes_html
2543 </td>
2547 <td>
2548 $view_entire_map_link
2550 </td>
2552 </tr></table>
2554 <table summary=""><tr><td>
2556 <form style="margin-bottom:0" action="/cview/view_chromosome.pl">
2558 <table summary="" cellpadding="0" border="0" cellspacing="0">
2559 <tr valign="middle"><td valign="middle" width="120">
2560 <b>Jump to map:</b></td><td>$self->{maps_select}</td><td valign="middle">&nbsp;chr&nbsp;</td><td>
2561 <input type="text" name="chr_nr" value="$chr_nr" size="2" />
2562 <input type="hidden" name="zoom" value="$zoom" />
2563 <!-- <input type="hidden" name="cM" value="$cM" /> -->
2564 <input type="hidden" name="cM_start" value="$cM_start" />
2565 <input type="hidden" name="cM_end" value="$cM_end" />
2566 <input type="hidden" name="show_ruler" value="$show_ruler" />
2567 <input type="hidden" name="show_IL" value="$show_IL" />
2568 <input type="hidden" name="show_offsets" value="$show_offsets" />
2569 <input type="hidden" name="comp_map_version_id" value="$comp_map_version_id" />
2570 <input type="hidden" name="comp_chr" value="$comp_chr" />
2571 <input type="hidden" name="color_model" value="$color_model" />
2572 <input type="hidden" name="show_physical" value="$show_physical" />
2573 <input type="hidden" name="size" value="$size" />
2574 <input type="hidden" name="show_zoomed" value="$show_zoomed" />
2575 <input type="hidden" name="confidence" value="$confidence" />
2576 <input type="hidden" name="hilite" value="$hilite" />
2577 <input type="hidden" name="marker_type" value="$display_marker_type" />
2578 <input type="submit" value="Jump" />
2579 </td>
2580 </tr>
2581 </table>
2582 </form>
2583 </td>
2585 <td width="20">&nbsp;</td>
2587 <td>
2588 <form style="margin-bottom:0" action="/cview/view_chromosome.pl">
2589 <b>Highlight marker:</b>
2590 <input type="text" name="hilite" value="$hilite" size="5" />
2591 <input type="submit" value="Highlight" />
2592 <input type="hidden" name="zoom" value="$zoom" />
2593 <!-- <input type="hidden" name="cM" value="$cM" /> -->
2594 <input type="hidden" name="cM_start" value="$cM_start" />
2595 <input type="hidden" name="cM_end" value="$cM_end" />
2596 <input type="hidden" name="chr_nr" value="$chr_nr" />
2597 <input type="hidden" name="map_version_id" value="$map_version_id" />
2598 <input type="hidden" name="show_ruler" value="$show_ruler" />
2599 <input type="hidden" name="show_IL" value="$show_IL" />
2600 <input type="hidden" name="show_offsets" value="$show_offsets" />
2601 <input type="hidden" name="comp_map_version_id" value="$comp_map_version_id" />
2602 <input type="hidden" name="comp_chr" value="$comp_chr" />
2603 <input type="hidden" name="color_model" value="$color_model" />
2604 <input type="hidden" name="show_zoomed" value="$show_zoomed" />
2605 <input type="hidden" name="confidence" value="$confidence" />
2606 <input type="hidden" name="show_physical" value="$show_physical" />
2607 <input type="hidden" name="size" value="$size" />
2608 <input type="hidden" name="marker_type" value="$display_marker_type" />
2609 </form>
2610 </td>
2613 </tr>
2614 </table>
2619 <table summary="" cellpadding="0" cellspacing="0" border="0"><tr>
2620 <td width="120">&nbsp;</td>
2621 <td colspan="3" align="center"><b>Reference chromosome</b></td>
2622 <td width="20">&nbsp;</td>
2623 <td colspan="3" align="center"><b>Comparison chromosome</b></td>
2624 </tr>
2625 <tr>
2626 <td width="120">&nbsp;</td>
2627 <td align="right">
2629 <table summary="" cellpadding="0" cellspacing="0" border="0"><tr><td>
2630 $sync_preceding_chr_html
2631 </td><td>
2632 $previous_chr_html
2633 </td></tr></table>
2635 </td>
2636 <td align="center" valign="middle">
2638 BUTTONS
2640 unless ( $chr_nr ne "" ) { $chr_nr = "&nbsp;"; }
2642 print <<BUTTONS;
2644 &nbsp;<b>$chr_nr</b>&nbsp; </td>
2645 <td>
2647 $next_chr_html
2650 </td>
2651 <td width="20">&nbsp;</td>
2652 <td align="right">
2653 $preceding_comp_chr_html
2656 </td>
2657 <td align="center" valign="middle">
2660 BUTTONS
2662 unless ( $comp_chr ne "" ) { $comp_chr = "&nbsp;"; }
2664 print <<BUTTONS;
2666 &nbsp;<b>$comp_chr</b>&nbsp;</td>
2667 <td>
2669 <table summary="" cellpadding="0" cellspacing="0" border="0"><tr><td>
2670 $next_comp_chr_html
2671 </td><td>
2672 $sync_next_chr_html
2673 </td></tr></table>
2675 </td>
2677 </tr></table>
2679 <table summary="" cellpadding="0" cellspacing="0">
2680 <tr><td valign="middle" width="120">
2681 <b>Show/hide:</b></td>
2682 <td>
2684 $ruler_html
2686 </td>
2687 <td>
2688 $offset_html
2689 </td>
2693 <td>
2695 $physical_map_html
2697 </td>
2699 <td>
2701 $IL_html
2704 </td>
2707 <td width="30">&nbsp;</td>
2708 <td valign="middle">&nbsp;<b>image size: </b> </td><td>
2710 <form style="margin-bottom:0" action="/cview/view_chromosome.pl">
2711 $toggle_size_select
2712 <input type="submit" value="change" />
2713 <input type="hidden" name="zoom" value="$zoom" />
2714 <input type="hidden" name="cM_start" value="$cM_start" />
2715 <input type="hidden" name="cM_end" value="$cM_end" />
2716 <input type="hidden" name="chr_nr" value="$chr_nr" />
2717 <input type="hidden" name="map_version_id" value="$map_version_id" />
2718 <input type="hidden" name="show_ruler" value="$show_ruler" />
2719 <input type="hidden" name="show_IL" value="$show_IL" />
2720 <input type="hidden" name="show_offsets" value="$show_offsets" />
2721 <input type="hidden" name="comp_map_version_id" value="$comp_map_version_id" />
2722 <input type="hidden" name="comp_chr" value="$comp_chr" />
2723 <input type="hidden" name="color_model" value="$color_model" />
2724 <input type="hidden" name="show_zoomed" value="$show_zoomed" />
2725 <input type="hidden" name="confidence" value="$confidence" />
2726 <input type="hidden" name="show_physical" value="$show_physical" />
2727 <input type="hidden" name="marker_type" value="$display_marker_type" />
2728 </form>
2733 </td>
2734 </tr></table>
2736 BUTTONS
2740 sub clean_up {
2741 my $self = shift;
2744 =head2 accessors set_state_hashref(), get_state_hashref()
2746 Property: the state_hashref is a hash describing the current
2747 state of the ChromosomeViewer, essentially collecting
2748 all the processed page arguments.
2749 Args/Ret: a hash reference
2750 Side Effects: the state_hashref determines what the toolbar buttons
2751 and links constructed on the page will contain as
2752 parameters.
2754 =cut
2756 sub get_state_hashref {
2757 my $self = shift;
2758 return $self->{state_hashref};
2761 sub set_state_hashref {
2762 my $self = shift;
2763 $self->{state_hashref} = shift;
2766 =head2 accessors set_force(), get_force()
2768 Property: force - regenerate cached files whatever the
2769 status of the cache
2770 Args/Ret true for re-generation, false for letting cache
2771 decide when to re-generate the images.
2772 Side Effects: true will force regenerate all associated files
2773 Description:
2775 =cut
2777 sub get_force {
2778 my $self = shift;
2779 if ( !exists( $self->{force} ) || !defined( $self->{force} ) ) {
2780 $self->{force} = "";
2782 return $self->{force};
2785 sub set_force {
2786 my $self = shift;
2787 $self->{force} = shift;
2790 =head2 get_temp_dir
2792 Usage:
2793 Desc:
2794 Ret:
2795 Args:
2796 Side Effects:
2797 Example:
2799 =cut
2801 sub get_temp_dir {
2802 my $self = shift;
2803 if ( !exists( $self->{temp_dir} ) ) {
2804 die "ChromosomeViewer: need a temp_dir for storing images... STOP!\n";
2807 return $self->{temp_dir};
2811 =head2 set_temp_dir
2813 Usage:
2814 Desc:
2815 Ret:
2816 Args:
2817 Side Effects:
2818 Example:
2820 =cut
2822 sub set_temp_dir {
2823 my $self = shift;
2824 $self->{temp_dir} = shift;
2827 =head2 get_basedir
2829 Usage:
2830 Desc:
2831 Ret:
2832 Args:
2833 Side Effects:
2834 Example:
2836 =cut
2838 sub get_basedir {
2839 my $self = shift;
2840 if ( !exists( $self->{basedir} ) ) {
2841 die "ChromosomeViewer: need a basedir for storing images... STOP!\n";
2843 return $self->{basedir};
2847 =head2 set_basedir
2849 Usage:
2850 Desc:
2851 Ret:
2852 Args:
2853 Side Effects:
2854 Example:
2856 =cut
2858 sub set_basedir {
2859 my $self = shift;
2860 $self->{basedir} = shift;
2863 =head2 accessors get_db_backend, set_db_backend
2865 Usage: $v ->set_db_backend("cxgn");
2866 Desc: sets the db backend of the comparative viewer.
2867 following values are allowed:
2868 o cxgn - the cxgn database
2869 o cmap - the cmap database
2870 o cxgn_and_cmap - both databases are queried for maps.
2871 Property a string describing the database backend to be used.
2872 Side Effects: the specified backend will be used
2874 =cut
2876 sub get_db_backend {
2877 my $self = shift;
2878 return $self->{db_backend} || 'cxgn';
2881 sub set_db_backend {
2882 my $self = shift;
2883 $self->{db_backend} = shift;
2886 =head2 accessors get_context, set_context
2888 Usage: $cv -> set_context( CXGN::Context->new() );
2889 Property: A context object
2890 Side Effects: The context object provides things like temp
2891 file locations, etc.
2892 Example:
2894 =cut
2896 sub get_context {
2897 my $self = shift;
2898 return $self->{context};
2901 sub set_context {
2902 my $self = shift;
2903 $self->{context} = shift;
2906 package CXGN::Cview::Chromosome_view::toolbar_button;
2908 sub new {
2909 my $class = shift;
2910 my $args = {};
2911 my $self = bless $args, $class;
2913 my $name = shift;
2915 my $properties_hashref = shift;
2917 $self->set_name($name);
2919 %{ $self->{properties} } = (
2920 'chr_nr' => "",
2921 'map_version_id' => "",
2922 'zoom' => "",
2923 'show_ruler' => "",
2924 'show_IL' => "",
2925 'show_offsets' => "",
2926 'comp_map_version_id' => "",
2927 'comp_chr' => "",
2928 'color_model' => "",
2929 'show_zoomed' => "",
2930 'show_physical' => "",
2931 'confidence' => "",
2932 'size' => "",
2933 'hilite' => "",
2934 'marker_type' => "",
2935 'cM_start' => "",
2936 'cM_end' => "",
2937 'cM' => "",
2938 'clicked' => "",
2941 foreach my $k ( keys(%$properties_hashref) ) {
2942 if ( exists( ${ $self->{properties} }{$k} ) ) {
2943 ${ $self->{properties} }{$k} = $$properties_hashref{$k};
2945 else {
2946 print STDERR
2947 "property $k is not supported in toolbar_button package.\n";
2950 return $self;
2953 sub set_name {
2954 my $self = shift;
2955 $self->{name} = shift;
2958 sub get_name {
2959 my $self = shift;
2960 return $self->{name};
2963 sub set_action {
2964 my $self = shift;
2965 $self->{action} = shift;
2968 sub get_action {
2969 my $self = shift;
2970 if ( !exists( $self->{action} ) ) { $self->{action} = ""; }
2971 return $self->{action};
2974 sub set_enabled {
2976 # parameter: true or false setting to enabled or disabled
2978 my $self = shift;
2979 $self->{enabled} = shift;
2982 sub is_enabled {
2983 my $self = shift;
2984 return $self->{enabled};
2987 sub set_property {
2988 my $self = shift;
2989 my $property = shift;
2990 my $value = shift;
2991 if ( !$value ) { $value = ""; }
2992 if ( !exists( ${ $self->{properties} }{$property} ) ) {
2993 print STDERR
2994 "Warning: toolbar_button: property $property does not exist!\n";
2995 return 0;
2997 else {
2998 ${ $self->{properties} }{$property} = $value;
2999 return 1;
3003 sub render_string {
3004 my $self = shift;
3006 my $action = $self->get_action();
3008 if ( $action eq "" ) {
3009 $action = "#";
3011 my $s = "<form style=\"margin-bottom:0\" action=\"$action\">\n";
3013 foreach my $p ( keys %{ $self->{properties} } ) {
3015 #print STDERR "Printing toolbar button: hidden field: $p, $self->{properties}{$p}\n";
3016 if ( exists( $self->{properties}{$p} ) && $self->{properties}{$p} ) {
3017 $s .=
3018 "<input type=\"hidden\" name=\"$p\" value=\"$self->{properties}{$p}\" />\n";
3023 my $disabled;
3024 if ( $self->is_enabled() ) {
3025 $disabled = "disabled=\"disabled\"";
3027 else {
3028 $disabled = "";
3030 $s .=
3031 "<input type=\"submit\" value=\""
3032 . $self->get_name()
3033 . "\" $disabled />\n";
3034 $s .= "</form>\n";
3035 return $s;
3038 sub render {
3039 my $self = shift;
3040 print $self->render_string();