6 CXGN::Cview::Map - an abstract class to deal with maps for the SGN comparative viewer.
10 The SGN mapviewer traditionally used a Perl module called CXGN::Cview::Cview_data_adapter to interface to different data sources. However, this approach was not scalable and was replaced with the CXGN::Cview::Map abstract interface approach.
12 Every Map represented in the SGN comparative viewer version 2.0 needs a corresponding Map object. It needs to inherit from CXGN::Cview::Map, and implement its functions. Each map should be identifyable by an identifier, which is used by CXGN::Cview::MapFactory to create the appropriate map object. If a new map type is added, corresponding code has to be added to the MapFactory to create the map object.
14 The inherited classes should be placed in the CXGN::Cview::Map::<DATABASE>:: namespace, where <DATABASE> signifies the website these interfaces are specific to. For SGN, <DATABASE> equals "SGN".
16 See L<CXGN::Cview::MapFactory> for the current list of supported identifiers and which types of maps they will generate.
20 Lukas A. Mueller <lam87@cornell.edu>
24 part of the compatibility layer of version 2.0 of the SGN mapviewer
28 This class implements the following functions:
34 package CXGN
::Cview
::Map
;
37 use CXGN
::Cview
::Chromosome
;
38 use CXGN
::Cview
::Chromosome
::IL
;
39 use CXGN
::Cview
::Chromosome
::PachyteneIdiogram
;
40 use CXGN
::Cview
::Legend
;
42 use base qw
| CXGN
::DB
::Object
|;
47 Arguments: should take a database handle and a parameter identifying a map.
57 my $self = $class->SUPER::new
($dbh);
61 $self->set_preferred_chromosome_width(20);
62 $self->set_type("generic");
63 $self->set_units("cM");
64 $self->set_short_name("unknown map");
65 $self->set_long_name("");
66 $self->set_chromosome_names("");
67 $self->set_chromosome_lengths(1);
68 $self->set_chromosome_count(1);
69 $self->set_organism("Solanum lycopersicum");
70 $self->set_common_name("Tomato");
71 $self->set_marker_link("/maps/physical/clone_info.pl?id=");
72 $self->set_legend(CXGN
::Cview
::Legend
->new()); # an empty legend.
77 =head2 accessors set_id(), get_id()
79 Property: the primary id of the map object
97 =head2 function get_chromosome()
99 Synopsis: my $chr = $map -> get_chromosome( $chr_nr);
100 Arguments: a legal linkage group name (usually a number, but could also
101 be alphanumeric for certain linkage groups).
102 Returns: a CXGN::Cview::Chromosome object, or a derived class thereof.
103 Side effects: in most implementations, this function will likely access
104 the databases and generate the chromosome object anew for
105 each call, such that there is considerable overhead calling
106 this function on complex chromosomes.
114 # this function should return a CXGN::Cview::Chromosome object
115 # or subclass thereof
116 my $empty_chr = CXGN
::Cview
::Chromosome
->new($chr_nr, 100, 40, 40);
117 #$emtpy_chr -> set_height(1);
118 #$emtpy_chr -> set_length(1);
119 #$emtpy_chr -> set_color(255, 255, 255);
124 =head2 function get_linkage_group()
126 Synopsis: this is a synonym for get_chromosome()
127 Arguments: see get_chromosome()
128 Returns: see get_chromosome()
134 sub get_linkage_group
{
136 return $self->get_chromosome(@_);
140 =head2 function get_chromosome_section()
142 Synopsis: my $chr_section = $map->
143 get_chromosome_section($chr_nr, $start, $end, $comparison);
144 Arguments: the chromosome name, the start offset in map units,
145 and the end offset in map units. The $comparison bit
146 tells the function that there is a comparison present
147 in the viewer, which can be used to subtly change the
148 appearance of the zoomed in section.
149 Returns: a chr_section.
151 Note: the default implementation just calls get_chromosome, ignoring the
152 start and end parameters. This is probably a useful behaviour if the
153 Map does not support sections.
157 sub get_chromosome_section
{
161 return $self->get_chromosome($chr_nr);
165 =head2 function get_chromosomes()
167 Synopsis: my @lg = $map->get_chromosomes()
169 Returns: a list of the linkage groups in the order
170 defined by lg_order (in the case of genetic maps anyway)
171 Side effects: accesses the database, if the map is db-based.
172 Description: calls get_chromosome_names and then get_chromosome on
183 sub get_chromosomes
{
185 my @linkage_groups = ();
186 foreach my $lg ($self->get_chromosome_names()) {
187 push @linkage_groups, $self->get_chromosome($lg);
189 return @linkage_groups;
195 =head2 function get_linkage_groups()
197 Synopsis: a synonym for get_chromosomes()
200 Side effects: calls get_chromosomes()
201 Description: see get_chromosomes().
206 sub get_linkage_groups
{
208 return $self->get_chromosomes(@_);
211 =head2 function get_overview_chromosome()
221 sub get_overview_chromosome
{
224 my $chr = $self->get_chromosome($chr_nr);
228 =head2 function get_chromosome_connections()
230 Synopsis: my @chr_links = $map->get_chromosome_connections($chr_name);
231 Arguments: a chromosome name
232 Returns: a list of hashrefs, containing 4 keys
233 map_version_id, lg_name, marker_count, short_name
234 and the corresponding values
235 Side effects: most implementations will query the database
236 Description: the default implementation does nothing and returns
241 sub get_chromosome_connections
{
243 my @connections = ();
248 =head2 accessors set_chromosome_count(), get_chromosome_count()
250 Synopsis: my $chr_count = $map->get_chromosome_count();
251 Property: the number of chromosomes in the Map (integer).
253 Notes: The constructor should set this property
258 sub get_chromosome_count
{
260 return $self->{chromosome_count
};
264 sub set_chromosome_count
{
266 $self->{chromosome_count
}=shift;
270 =head2 accessors set_chromosome_names(), get_chromosome_names()
272 Property: an ordered list of chromosome names
273 Side Effects: names will be used on the display to identify the
275 Description: This property should be set in the constructor of the
280 sub get_chromosome_names
{
282 return @
{$self->{chromosome_names
}};
285 sub set_chromosome_names
{
287 @
{$self->{chromosome_names
}}= @_;
291 =head2 accessors set_chromosome_lengths(), get_chromosome_lengths()
293 Synopsis: an ordered list of chromosomes lengths in the Map units.
297 Description: Note: the first chromosome is in list element 0.
301 sub get_chromosome_lengths
{
303 return @
{$self->{chromosome_lengths
}};
307 sub set_chromosome_lengths
{
309 @
{$self->{chromosome_lengths
}} = @_;
313 =head2 get_chr_length_by_name
324 sub get_chr_len_by_name
{
326 my $chr_name = shift;
327 my @names = $self->get_chromosome_names();
328 for (my $i=0; $i<@names; $i++) {
329 if ($names[$i] eq $chr_name) {
330 return ($self->get_chromosome_lengths())[$i];
338 =head2 function has_linkage_group()
340 Synopsis: if ($map->has_linkage_group("7F")) { ... }
341 Arguments: a chromosome or linkage group name
342 Returns: returns a true value if a linkage group
343 of that name exists, a false value if it does
344 not exist. This default implementation should
345 work for all subclasses that set the chromosome_names
352 sub has_linkage_group
{
354 my $linkage_group = shift;
355 foreach my $lg ($self->get_chromosome_names()) {
356 if ($lg eq $linkage_group) {
363 =head2 function get_marker_count()
365 Synopsis: $map->get_marker_count($chr_nr)
366 Arguments: a chromosome number
367 Returns: the number of markers on that chr in the map
368 Side effects: depending on implementation, may access db
369 Description: this function needs to be implemented in sub-
370 classes for the map statistics in the SGN
375 sub get_marker_count
{
380 =head2 function get_marker_type_stats()
390 sub get_marker_type_stats
{
395 =head2 accessors set_short_name(), get_short_name()
408 return $self->{short_name
};
413 $self->{short_name
}=shift;
416 =head2 accessors set_long_name(), get_long_name()
429 return $self->{long_name
};
434 $self->{long_name
}=shift;
437 =head2 accessors set_abstract(), get_abstract()
450 return $self->{abstract
};
455 $self->{abstract
}=shift;
459 =head2 accessors set_centromere(), get_centromere()
461 Synopsis: my ($north, $south, $center) = $map->get_centromere($lg_name)
462 Arguments: a valid linkage group name
463 Returns: this function should return a three member list, the first
464 element corresponds to the north boundary of the centromere in cM
465 the second corresponds to the south boundary of
466 the centromere in cM, the third is the arithmetic mean
467 of the two first values.
469 Description: this property should be set in the constructor. The setter takes
470 the north and the south position as parameters.
471 $map->set_centromere($lg_name, $north, $south)
477 my $chr_name = shift;
478 return ($self->{centromere
}->{$chr_name}->{north
}, $self->{centromere
}->{$chr_name}->{south
}, ($self->{centromere
}->{$chr_name}->{north
}+$self->{centromere
}->{$chr_name}->{south
})/2);
483 my $chr_name = shift;
484 ($self->{centromere
}->{$chr_name}->{north
}, $self->{centromere
}->{$chr_name}->{south
}) = @_;
489 =head2 accessors set_deprecated_by(), get_deprecated_by()
491 Property: some maps will support deprecation information,
492 such as the maps in the SGN database. This
493 property returns the id of the map that supercedes
500 sub get_deprecated_by
{
502 return $self->{deprecated_by
};
505 sub set_deprecated_by
{
507 $self->{deprecated_by
}=shift;
512 =head2 accessors set_type(), get_type()
514 Property: the map type, which is defined for
515 the database-based maps. Types include
524 return $self->{type
};
533 =head2 accessors set_units(), get_units()
535 Property: the unit measure of the map, such
544 return $self->{units
};
549 $self->{units
}=shift;
554 =head2 accessors set_preferred_chromosome_width(), get_preferred_chromosome_width()
564 sub set_preferred_chromosome_width
{
566 $self->{preferred_chromosome_width
}= shift;
569 sub get_preferred_chromosome_width
{
571 return $self->{preferred_chromosome_width
};
574 =head2 function can_zoom()
576 Synopsis: if ($map->can_zoom()) { ...
578 Returns: 1 if the map supports zooming in, 0 if it
581 Description: default is zooming not supported.
591 Usage: should return 0 or 1, depending whether the ruler
592 should be shown on a map overview.
593 Desc: default is 1, show ruler.
607 =head2 function show_stats()
609 Synopsis: whether to show the stats on the overview page for
610 this map. Override if default of 1 is not appropriate.
623 =head2 function get_map_stats()
625 Synopsis: my $marker_type_html = $map->get_map_stats()
626 Returns: a HTML snippet with marker type information on this map.
627 Side effects: this will be displayed on the map overview page.
635 =head2 function collapsed_marker_count()
641 Description: the comparative viewer displays the reference chromosome
642 with only a small number of markers shown. This function
643 should give a number for the number of markers shown.
648 sub collapsed_marker_count
{
653 =head2 function initial_zoom_height()
655 Synopsis: the initial zoom level, in map units.
663 sub initial_zoom_height
{
665 if ($self->get_units() eq "MB") {
672 =head2 accessors set_marker_link(), get_marker_link()
674 Synopsis: returns the appropriate link for marker $m
675 Arguments: a marker name
677 Side effects: will be used to link that marker from the map
682 sub get_marker_link
{
686 return $self->{marker_link
}.$id;
691 sub set_marker_link
{
693 $self->{marker_link
}=shift;
696 =head2 function has_IL()
698 Synopsis: if the map has an associated IL map.
709 =head2 function has_physical()
711 Synopsis: if the map has an associated physical map.
715 Description: soon to be deprecated but still used...
722 =head2 accessors set_organism(), get_organism()
724 Property: the organism name
730 to do: this should be expanded the two parents...
736 return $self->{organism
};
741 $self->{organism
}=shift;
744 =head2 accessors set_common_name(), get_common_name()
746 Property: the common name
755 sub get_common_name
{
757 return $self->{common_name
};
760 sub set_common_name
{
762 $self->{common_name
}=shift;
765 =head2 function append_messages()
771 Description: appends a message string that can be displayed by the
772 chromosome viewer to tell the user about unexpected
773 conditions or errors. The messages can be retrieved
774 using get_messages().
778 sub append_messages
{
780 $self->{messages
} .= shift;
784 =head2 function get_messages()
790 Description: gets the message string that has been constructed using
791 the append_messages() function.
797 return $self->{messages
};
800 =head2 map_id2map_version_id
802 Usage: $map_version_id = $map->map_id2map_version_id($map_id)
803 Desc: converts the $map_id to its corresponding $map_version_id
804 if the map supports versioning of maps. The default
805 implementation returns the same id that is fed to it
807 Note: Needs to be over-ridden in a subclass for maps that
808 support versioning. The most recent, current version
815 sub map_id2map_version_id
{
821 =head2 map_version_id2map_id
823 Usage: $map_id = $map->map_version_id2map_id($map_version_id)
824 Desc: converts the $map_version_id to its corresponding $map_id
825 if the map supports versioning of maps. The default
826 implementation returns the same id that is fed to it
828 Note: Needs to be over-ridden in a subclass for maps that
835 sub map_version_id2map_id
{
837 my $map_version_id = shift;
838 return $map_version_id;
841 =head2 accessors get_legend, set_legend
843 Usage: $m->set_legend($legend_object)
844 Desc: the legend object defines the legend that
845 will be displayed in the viewer.
846 Property: a CXGN::Cview::Legend object
854 return $self->{legend
};
859 $self->{legend
} = shift;
862 =head2 accessors get_temp_dir, set_temp_dir
864 Usage: $m->get_temp_dir()
865 Desc: Accessors for the temp dir [string]
867 Side Effects: temporary files generated by this object will
868 be stored in the specified dir
875 return $self->{temp_dir
};
880 $self->{temp_dir
} = shift;