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
{
159 return $self->get_chromosome();
163 =head2 function get_chromosomes()
165 Synopsis: my @lg = $map->get_chromosomes()
167 Returns: a list of the linkage groups in the order
168 defined by lg_order (in the case of genetic maps anyway)
169 Side effects: accesses the database, if the map is db-based.
170 Description: calls get_chromosome_names and then get_chromosome on
181 sub get_chromosomes
{
183 my @linkage_groups = ();
184 foreach my $lg ($self->get_chromosome_names()) {
185 push @linkage_groups, $self->get_chromosome($lg);
187 return @linkage_groups;
193 =head2 function get_linkage_groups()
195 Synopsis: a synonym for get_chromosomes()
198 Side effects: calls get_chromosomes()
199 Description: see get_chromosomes().
204 sub get_linkage_groups
{
206 return $self->get_chromosomes(@_);
209 =head2 function get_overview_chromosome()
219 sub get_overview_chromosome
{
222 my $chr = $self->get_chromosome($chr_nr);
226 =head2 function get_chromosome_connections()
228 Synopsis: my @chr_links = $map->get_chromosome_connections($chr_name);
229 Arguments: a chromosome name
230 Returns: a list of hashrefs, containing 4 keys
231 map_version_id, lg_name, marker_count, short_name
232 and the corresponding values
233 Side effects: most implementations will query the database
234 Description: the default implementation does nothing and returns
239 sub get_chromosome_connections
{
241 my @connections = ();
246 =head2 accessors set_chromosome_count(), get_chromosome_count()
248 Synopsis: my $chr_count = $map->get_chromosome_count();
249 Property: the number of chromosomes in the Map (integer).
251 Notes: The constructor should set this property
256 sub get_chromosome_count
{
258 return $self->{chromosome_count
};
262 sub set_chromosome_count
{
264 $self->{chromosome_count
}=shift;
268 =head2 accessors set_chromosome_names(), get_chromosome_names()
270 Property: an ordered list of chromosome names
271 Side Effects: names will be used on the display to identify the
273 Description: This property should be set in the constructor of the
278 sub get_chromosome_names
{
280 return @
{$self->{chromosome_names
}};
283 sub set_chromosome_names
{
285 @
{$self->{chromosome_names
}}= @_;
289 =head2 accessors set_chromosome_lengths(), get_chromosome_lengths()
291 Synopsis: an ordered list of chromosomes lengths in the Map units.
299 sub get_chromosome_lengths
{
301 return @
{$self->{chromosome_lengths
}};
305 sub set_chromosome_lengths
{
307 @
{$self->{chromosome_lengths
}} = @_;
311 =head2 get_chr_length_by_name
322 sub get_chr_len_by_name
{
324 my $chr_name = shift;
325 my @names = $self->get_chromosome_names();
326 for (my $i=0; $i<@names; $i++) {
327 if ($names[$i] eq $chr_name) {
328 return ($self->get_chromosome_lengths())[$i];
336 =head2 function has_linkage_group()
338 Synopsis: if ($map->has_linkage_group("7F")) { ... }
339 Arguments: a chromosome or linkage group name
340 Returns: returns a true value if a linkage group
341 of that name exists, a false value if it does
342 not exist. This default implementation should
343 work for all subclasses that set the chromosome_names
350 sub has_linkage_group
{
352 my $linkage_group = shift;
353 foreach my $lg ($self->get_chromosome_names()) {
354 if ($lg eq $linkage_group) {
361 =head2 function get_marker_count()
363 Synopsis: $map->get_marker_count($chr_nr)
364 Arguments: a chromosome number
365 Returns: the number of markers on that chr in the map
366 Side effects: depending on implementation, may access db
367 Description: this function needs to be implemented in sub-
368 classes for the map statistics in the SGN
373 sub get_marker_count
{
378 =head2 function get_marker_type_stats()
388 sub get_marker_type_stats
{
393 =head2 accessors set_short_name(), get_short_name()
406 return $self->{short_name
};
411 $self->{short_name
}=shift;
414 =head2 accessors set_long_name(), get_long_name()
427 return $self->{long_name
};
432 $self->{long_name
}=shift;
435 =head2 accessors set_abstract(), get_abstract()
448 return $self->{abstract
};
453 $self->{abstract
}=shift;
457 =head2 accessors set_centromere(), get_centromere()
459 Synopsis: my ($north, $south, $center) = $map->get_centromere($lg_name)
460 Arguments: a valid linkage group name
461 Returns: this function should return a three member list, the first
462 element corresponds to the north boundary of the centromere in cM
463 the second corresponds to the south boundary of
464 the centromere in cM, the third is the arithmetic mean
465 of the two first values.
467 Description: this property should be set in the constructor. The setter takes
468 the north and the south position as parameters.
469 $map->set_centromere($lg_name, $north, $south)
475 my $chr_name = shift;
476 return ($self->{centromere
}->{$chr_name}->{north
}, $self->{centromere
}->{$chr_name}->{south
}, ($self->{centromere
}->{$chr_name}->{north
}+$self->{centromere
}->{$chr_name}->{south
})/2);
481 my $chr_name = shift;
482 ($self->{centromere
}->{$chr_name}->{north
}, $self->{centromere
}->{$chr_name}->{south
}) = @_;
487 =head2 accessors set_deprecated_by(), get_deprecated_by()
489 Property: some maps will support deprecation information,
490 such as the maps in the SGN database. This
491 property returns the id of the map that supercedes
498 sub get_deprecated_by
{
500 return $self->{deprecated_by
};
503 sub set_deprecated_by
{
505 $self->{deprecated_by
}=shift;
510 =head2 accessors set_type(), get_type()
512 Property: the map type, which is defined for
513 the database-based maps. Types include
522 return $self->{type
};
531 =head2 accessors set_units(), get_units()
533 Property: the unit measure of the map, such
542 return $self->{units
};
547 $self->{units
}=shift;
552 =head2 accessors set_preferred_chromosome_width(), get_preferred_chromosome_width()
562 sub set_preferred_chromosome_width
{
564 $self->{preferred_chromosome_width
}= shift;
567 sub get_preferred_chromosome_width
{
569 return $self->{preferred_chromosome_width
};
572 =head2 function can_zoom()
574 Synopsis: if ($map->can_zoom()) { ...
576 Returns: 1 if the map supports zooming in, 0 if it
579 Description: default is zooming not supported.
587 =head2 function show_stats()
589 Synopsis: whether to show the stats on the overview page for
590 this map. Override if default of 1 is not appropriate.
603 =head2 function get_map_stats()
605 Synopsis: my $marker_type_html = $map->get_map_stats()
606 Returns: a HTML snippet with marker type information on this map.
607 Side effects: this will be displayed on the map overview page.
615 =head2 function collapsed_marker_count()
621 Description: the comparative viewer displays the reference chromosome
622 with only a small number of markers shown. This function
623 should give a number for the number of markers shown.
628 sub collapsed_marker_count
{
633 =head2 function initial_zoom_height()
635 Synopsis: the initial zoom level, in map units.
643 sub initial_zoom_height
{
645 if ($self->get_units() eq "MB") {
652 =head2 accessors set_marker_link(), get_marker_link()
654 Synopsis: returns the appropriate link for marker $m
655 Arguments: a marker name
657 Side effects: will be used to link that marker from the map
662 sub get_marker_link
{
666 return $self->{marker_link
}.$id;
671 sub set_marker_link
{
673 $self->{marker_link
}=shift;
676 =head2 function has_IL()
678 Synopsis: if the map has an associated IL map.
689 =head2 function has_physical()
691 Synopsis: if the map has an associated physical map.
695 Description: soon to be deprecated but still used...
702 =head2 accessors set_organism(), get_organism()
704 Property: the organism name
710 to do: this should be expanded the two parents...
716 return $self->{organism
};
721 $self->{organism
}=shift;
724 =head2 accessors set_common_name(), get_common_name()
726 Property: the common name
735 sub get_common_name
{
737 return $self->{common_name
};
740 sub set_common_name
{
742 $self->{common_name
}=shift;
745 =head2 function append_messages()
751 Description: appends a message string that can be displayed by the
752 chromosome viewer to tell the user about unexpected
753 conditions or errors. The messages can be retrieved
754 using get_messages().
758 sub append_messages
{
760 $self->{messages
} .= shift;
764 =head2 function get_messages()
770 Description: gets the message string that has been constructed using
771 the append_messages() function.
777 return $self->{messages
};
780 =head2 map_id2map_version_id
782 Usage: $map_version_id = $map->map_id2map_version_id($map_id)
783 Desc: converts the $map_id to its corresponding $map_version_id
784 if the map supports versioning of maps. The default
785 implementation returns the same id that is fed to it
787 Note: Needs to be over-ridden in a subclass for maps that
788 support versioning. The most recent, current version
795 sub map_id2map_version_id
{
801 =head2 map_version_id2map_id
803 Usage: $map_id = $map->map_version_id2map_id($map_version_id)
804 Desc: converts the $map_version_id to its corresponding $map_id
805 if the map supports versioning of maps. The default
806 implementation returns the same id that is fed to it
808 Note: Needs to be over-ridden in a subclass for maps that
815 sub map_version_id2map_id
{
817 my $map_version_id = shift;
818 return $map_version_id;
821 =head2 accessors get_legend, set_legend
823 Usage: $m->set_legend($legend_object)
824 Desc: the legend object defines the legend that
825 will be displayed in the viewer.
826 Property: a CXGN::Cview::Legend object
834 return $self->{legend
};
839 $self->{legend
} = shift;
842 =head2 accessors get_temp_dir, set_temp_dir
844 Usage: $m->get_temp_dir()
845 Desc: Accessors for the temp dir [string]
847 Side Effects: temporary files generated by this object will
848 be stored in the specified dir
855 return $self->{temp_dir
};
860 $self->{temp_dir
} = shift;