6 use CXGN
::DB
::Connection
;
8 my $page = CXGN
::Page
->new();
9 my ($map_id, $map_version_id, $size, $hilite, $physical, $force) = $page->get_encoded_arguments("map_id", "map_version_id", "size", "hilite", "physical", "force");
11 my $dbh = CXGN
::DB
::Connection
->new();
14 my $referer = ($page->get_request()->uri()) ."?". ($page->get_request->args());
17 my $tempdir = $c->path_to($c->tempfiles_subdir('cview'));
20 $c->forward_to_mason_view('/cview/map/index.mas', dbh
=>$dbh, map_version_id
=>$map_version_id, map_id
=>$map_id, hilite
=>$hilite, physical
=>$physical, size
=>$size, referer
=>$referer, force
=>$force, tempdir
=>$tempdir);
24 map.pl - display top level map web page
28 A script that displays a web page with an overview graph of a map, an abstract and some statistics about the map, using map_id or map_version_id as a parameter.
30 Older versions of this script accepted other parameters, such as the mysterious legacy_id or the more cumbersome map short name. Support for these has been scrapped. Sorry!
32 As well, older versions supported a parameter called "physical", which then, through some inextricable hack displayed a physical map. This parameter has been deprecated but is still supported.
34 On the other hand, a new parameter was added, called "force", which, if set to true, will force the cached images and stats to be re-calculated. Normally, the map overview image and associated image map and the map statistics are cached.
42 The map_id of the map to display.
46 the map_version_id of the map to display. Note that map_id and map_version_id are mutually exclusive.
50 a space separated, url-encoded string that gives the markers to be highlighted.
54 the size of the map to display. 0 denotes the standard size (smallest), 10 denotes the largest size.
58 if set to true, force the image and map stats caches to be re-calculated.
64 Early versions were written by Robert Ahrens, with later additions by Lukas Mueller and John Binns <zombieite@gmail.com>.
66 Currently maintained by Lukas Mueller <lam87@cornell.edu>.
76 # use CXGN::DB::Connection;
78 # use CXGN::Page::FormattingHelpers qw(page_title_html blue_section_html tooltipped_text);
79 # use CXGN::Cview::Map_overviews::Generic;
80 # use CXGN::People::PageComment;
82 # use CXGN::Map::Tools;
83 # use CXGN::Cview::MapFactory;
84 # use CXGN::Cview::Map::Tools;
88 # my $vh = CXGN::VHost->new();
90 # # set up a cache for the map statistics, using Cache::File
92 # my $cache_file_dir = File::Spec->catfile($vh->get_conf("basepath"), $vh->get_conf("tempfiles_subdir"), "cview", "cache_file");
94 # tie %marker_info, 'Cache::File', { cache_root => $cache_file_dir };
96 # # report some unusual conditions to the user.
100 # our $page = CXGN::Page -> new( "SGN map", "Lukas");
102 # $page->jsan_use('MochiKit.Base', 'MochiKit.Async');
104 # my ($map_id, $map_version_id, $size, $hilite, $physical, $force) = $page->get_encoded_arguments("map_id", "map_version_id", "size", "hilite", "physical", "force");
106 # my $dbh = CXGN::DB::Connection->new();
109 # # maintain some backwards compatibility. The physical parameter is deprecated, but
110 # # we still support it...
112 # if ($physical==1) { $map_id= "p".$map_id; }
114 # # if the map_id was supplied, convert immediately to map_version_id
116 # if ($map_id && !$map_version_id) {
117 # $map_version_id = CXGN::Cview::Map::Tools::find_current_version($dbh, $map_id);
121 # # get the map data using the CXGN::Map API.
123 # my $map_factory = CXGN::Cview::MapFactory->new($dbh);
124 # my $map = $map_factory ->create({ map_version_id => $map_version_id });
126 # if (!$map) { missing_map_page(); }
128 # # adjust the size parameter, which scales the size of the map overview image.
130 # my $enlarge_button_disabled = "";
131 # my $shrink_button_disabled = "";
132 # my $smaller_size = 0;
133 # my $larger_size = 0;
139 # $shrink_button_disabled = qq { disabled="1" };
140 # $smaller_size = $size;
143 # $smaller_size = $size - 1;
148 # $enlarge_button_disabled = qq { disabled="1" };
149 # $larger_size = $size;
152 # $larger_size = $size+ 1;
154 # $larger_size = 10 if $larger_size > 10;
156 # my $image_height = 160;
157 # my $image_width = 820;
159 # $image_height = $image_height + $image_height * $size /2;
161 # my $map_fullname = $map->get_long_name();
162 # my $abstract = $map->get_abstract();
163 # my $short_name = $map->get_short_name();
165 # my @chr_names = $map->get_chromosome_names();
167 # my $abstract = $map->get_abstract();
169 # my $map_image_file="";
170 # my $image_map = "";
175 # # create an appropriate overview diagram - physical or generic
176 # # (the generic will also provide an appropriate overview for the fish map).
178 # $map_overview = CXGN::Cview::Map_overviews::Generic -> new($map, $force);
180 # $map_overview->set_image_height($image_height);
181 # $map_overview->set_image_width($image_width);
183 # # deal with marker names to be highlighted on the overview diagram
184 # # (the ones to be requested to be hilited using the hilite feature)
186 # my @hilite_markers = split /\s+|\,\s*|\;s*/, $hilite;
188 # foreach my $hm (@hilite_markers) {
189 # #print STDERR "Hilite marker $hm...\n";
190 # $map_overview -> hilite_marker($hm);
193 # # generate the marker list for use in the URL links
195 # my $hilite_encoded = URI::Escape::uri_escape(join (" ", @hilite_markers));
197 # # render the map and get the imagemap
199 # $map_overview -> render_map();
201 # my $map_overview_html = $map_overview->get_image_html();
203 # # get the markers that could not be hilited
205 # my @markers_not_found = $map_overview -> get_markers_not_found();
206 # if (@markers_not_found) {
207 # $message .= "The following markers requested for hiliting were not found on this map (click to search on other maps):<br />";
208 # foreach my $m (@markers_not_found) {
209 # $message .= " <a href=\"/search/markers/markersearch.pl?searchtype=exactly&name=$m\">$m</a>";
211 # $message .= "<br />\n";
214 # # start displaying the page
218 # print page_title_html($short_name);
219 # print "<div id=\"pagetitle2\"><center><h3>$map_fullname</h3></center></div>";
222 # print "<div class=\"boxbgcolor5\"><b>NOTE:</b><br />$message</div>\n";
227 # <table summary="outer table" width="100%" border="0"><tr>
228 # <td width="10%"><br /></td>
239 # # add the input box and form for the hilite marker feature
241 # my $hilite_tooltip = tooltipped_text("Highlight marker(s)", "You can highlight markers on the overview graphic by entering them here, separated by spaces");
242 # my $size_tooltip = tooltipped_text("Image size", "You can increase the size of the overview graph by clicking on the (+) button and decrease it by clicking on (-).");
246 # <table><tr><td align="left">
247 # <div class="indentedcontent">
249 # <form action="/cview/map.pl?map_version_id=$map_version_id&physical=$physical">
251 # $hilite_tooltip: <input type="text" name="hilite" value="$hilite" size="10" />
252 # <input type="hidden" name="physical" value="$physical" />
253 # <input type="hidden" name="map_version_id" value="$map_version_id" />
254 # <input type="hidden" name="size" value="$size" />
255 # <input type="submit" value="Highlight" />
258 # </td><td width=400 align="right">$size_tooltip:
259 # </td><td align="right">
261 # <input type="hidden" name="physical" value="$physical" />
262 # <input type="hidden" name="map_version_id" value="$map_version_id" />
263 # <input type="hidden" name="size" value="$smaller_size" />
264 # <input type="hidden" name="hilite" value="$hilite" />
265 # <input type="submit" value="-" $shrink_button_disabled />
269 # <input type="hidden" name="physical" value="$physical" />
270 # <input type="hidden" name="map_version_id" value="$map_version_id" />
271 # <input type="hidden" name="hilite" value="$hilite" />
272 # <input type="hidden" name="size" value="$larger_size" />
273 # <input type="submit" value="+" $enlarge_button_disabled />
282 # # print the abstract
284 # print blue_section_html("Abstract", "<div class=\"indentedcontent\">$abstract</div><br />") if ($abstract);
286 # # print a list of links, one per chromosome, and some marker stats
290 # my $map_stats = qq |
292 # <table summary="map stats" align="center" border="0">
294 # <td valign="middle"><b>Click to view a given chromosome<br /><br /></b></td>
295 # <td width="70"> </td>
296 # <td><b>Marker collections:</b><br /><br /></td>
302 # <table summary="marker stats table" >
303 # <tr><td> </td><td>\# markers</td></tr>
308 # $map_id = CXGN::Cview::Map::Tools::find_map_id_with_version($dbh, $map_version_id);
311 # my $total_markers=0;
312 # for (my $i=0; $i<@chr_names; $i++) {
313 # my $hash_key = $map_version_id."-".$i;
314 # if (!exists($marker_info{$hash_key}) || $force) {
315 # $marker_info{$hash_key} = $map->get_marker_count($chr_names[$i]);
317 # $map_stats .= "<tr><td><a href=\"/cview/view_chromosome.pl?map_version_id=$map_version_id&chr_nr=$chr_names[$i]&hilite=$hilite_encoded\"><b>Chromosome $chr_names[$i]</b></a></td><td align=\"right\"><a href=\"/search/markers/markersearch.pl?w822_nametype=starts+with&w822_marker_name=&w822_mapped=on&w822_species=Any&w822_protos=Any&w822_colls=Any&w822_pos_start=&w822_pos_end=&w822_confs=Any&w822_submit=Search&w822_chromos=$chr_names[$i]&w822_maps=$map_id\">$marker_info{$hash_key}</a></td></tr>\n";
318 # $total_markers += $marker_info{$hash_key};
320 # $map_stats .= qq { <tr><td colspan="2"> </td></tr><tr><td><b>Total mapped:</b></td><td align=\"right\"><b>$total_markers</b></td></tr>\n };
321 # $map_stats .= "</table>\n";
322 # my $marker_type_table = "";
323 # if (!exists($marker_info{$map_version_id}) || $force) {
324 # $marker_info{$map_version_id} = $map->get_map_stats();
329 # </td><td> </td><td valign="middle">$marker_info{$map_version_id}</td></tr>
337 # print blue_section_html("Map statistics", $map_stats);
339 # # add the page comment feature. Only show for maps that have completely
340 # # numeric identifiers.
342 # if ($map_overview->get_map()->get_id=~/^\d+$/) {
344 # my $referer = $page->{request}->uri()."?".$page->{request}->args();
345 # my $comment_map_id=0;
346 # if ($map_id=~/(\d+)/) {
347 # $comment_map_id=$1;
350 # print $page->comments_html('map', $comment_map_id, $referer);
354 # #print "</td></tr>\n";
363 # sub missing_map_page {
366 # my $title = page_title_html("The requested map could not be found.");
373 # All available maps on SGN are listed on the <a href="/cview/">map index page</a>.
376 # Please contact <a href="mailto:sgn-feedback\@sgn.cornell.edu">SGN</a> if you think there is a problem.
387 # # sub hack_abstract ($$$) {
388 # # # Look. This is a total hack and that's that. Let's make no
389 # # # bones about it. There is doubtlessly a good way to handle this,
390 # # # but in the meantime this sub will allow us to swap in a decent
391 # # # abstract for the physical mapping project w/o having to redesign
393 # # my ($abstract, $map, $physical) = @_;
394 # # my $vhost_conf=CXGN::VHost->new();
395 # # my $physabstractfile = $vhost_conf->get_conf('basepath').$vhost_conf->get_conf('support_data_subdir')."/mapviewer/physicalabstract";
396 # # my $overgo_stats_page = '/maps/physical/overgo_stats.pl';
397 # # my $overgo_plate_browser = '/maps/physical/list_bacs_by_plate.pl';
398 # # my $overgo_explanation = '/maps/physical/overgo_process_explained.pl';
400 # # my $map_id = $map->map_id();
401 # # my $map_fullname = $map->long_name();
402 # # if (! $physical) { $physical = 0; }
404 # # if (($map_id==9) && ($physical==1)) {
405 # # open PHYSABSTRACT, "<$physabstractfile"
406 # # or die( "<i>ERROR: Unable to read from $physabstractfile</i>.\n" );
407 # # my @phys_abst = <PHYSABSTRACT>;
408 # # close PHYSABSTRACT;
409 # # $abstract = join("", @phys_abst);
410 # # $abstract =~ s/MAPID/$map_id/;
413 # # if ( $map->has_physical() ) {
417 # # $abstract .= <<PHYSICAL;
420 # # <b>Genetic Map:</b> This map is extracted from the
421 # # <a href="/cview/map.pl?map_id=$map_id&physical=0">$map_fullname</a>.
425 # # <b>Overgo Data</b>
427 # # <li>Statistics on the <a href="$overgo_stats_page">Overgo Plating Process</a></li>
428 # # <li><a href="$overgo_explanation">Explanation of the Overgo Plating process</a></li>
435 # # $abstract .= <<PHYSICAL;
438 # # <b><a href="/cview/map.pl?map_id=$map_id&physical=1">The physical Map</a></b> -- a combined genetic and physical map, showing the association of BACs and BAC contigs to this genetic map
447 # # return $abstract;