GBrowse
view release on metacpan or search on metacpan
cgi-bin/gbrowse_gmap view on Meta::CPAN
More detailed and up to date information on PhyloGeoViz is available at its web
site, http://phylogeoviz.org/. The code is available at
http://code.google.com/p/phylogeoviz/ .
=head3 PhyloGeoViz Installation
=over 4
=item * PHP
PhyloGeoViz is a PHP application. Make sure PHP is installed and working on your server.
=item * Get PhyloGeoViz Code
PhyloGeoViz is available through Google. Simply download using Subversion
(svn). From the Linux command line it looks like this:
svn checkout http://phylogeoviz.googlecode.com/svn/trunk/ phylogeoviz-read-only
=item * Make a directory in your web server's document tree
Examples:
mkdir /var/www/html/phylogeoviz
or
mkdir /usr/local/apache2/htdocs/phylogeoviz
=item * Copy PhyloGeoViz
Copy the contents of the phylogeoviz-read-only directory into the newly created directory:
cp phylogeoviz-read-only/* /var/www/html/phylogeoviz/
=back
=head3 PhyloGeoViz Configuration
In the top directory of your new PhyloGeoViz installation is a file called
config.php. This is a php file where information is set to customize
PhyloGeoViz.
Open it with your favorite editor.
Example:
vim /var/www/html/phylogeoviz/config.php
=over 4
=item * $gmap_api_key
To use Google Maps, a GMap API key must be supplied. As of writing, keys are
freely available from Google at http://code.google.com/apis/maps/.
Set the $gmap_api_key to your new api key. As follows:
gmap_api_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Note: You must keep the quotes and the semicolon intact for it to work.
=item * $popup_url
Each PhyloGeoViz pie has a marker in the middle. Clicking on that pops up a
window with information. If set $popup_url will be used as a base url to get
html to fill the pop-up window. We want that to point to this (the
gbrowse_gmap) script.
$popup_url = "/cgi-bin/gb2/gbrowse_gmap/pop_demo?pop_name=";
Note: You still must keep the quotes and the semicolon intact for it to work.
=back
=head3 Test PhyloGeoViz
To check that the installation worked, go to your web site:
http://localhost/phylo/
This will give you a page that says "Input Your Data".
Click the "Autofill some example data" link to get some example data and click
"Draw Map!".
If a Google Map appears with several pie charts, then you have successfully
installed Phylogeoviz.
=head2 Configuration
To place the mashup in a balloon, simply add a modified version of the
following to the track configuration.
balloon click = http://localhost/cgi-bin/gbrowse_gmap/yeast_chr1?ref=$ref;start=$start;end=$end;name=$name;class=$class;balloon=1
Similarly, to set the mashup as a feature link add a modified version of the
following to the track configuration.
link = http://localhost/cgi-bin/gbrowse_gmap/yeast_chr1?ref=$ref;start=$start;end=$end;name=$name;class=$class;
Note that the only difference between the two URLs was the balloon option. The
balloon option needs to be set to 1 if it will be popped up in a balloon.
The "yeast_chr1" portion should be replaced with the coorect data source.
Also, "localhost" should be changed to your url. A relative url may not work
because Google ties the api key to a URL.
=head2 Current Data Requirements
=over 4
=item * Different Populations will have different track types.
=item * Latitude and Longitude
A track is identified as being a population if it has latitude and longitude
values assigned in the configuration file.
=item * Haplotypes
Each haplotype of a population is stored as a feature with the "score" value
deterimining its weight. The feature "name" is the haplotype name. For
features to be considered as part of the same population group, they must all
share the same start and end.
=item * Start and end of all used features the same.
Only features that have the same start and end as the chosen feature will be
cgi-bin/gbrowse_gmap view on Meta::CPAN
my @phylo_link_params = (
[ 'numpops', $numpops ],
[ 'numhaps', $numhaps ],
[ 'anchor_pies', 1 ],
[ 'pop_names', JSON::to_json( \@sorted_pop_names ) ],
[ 'hap_names', JSON::to_json( \@sorted_hap_names ) ],
[ 'pop_lat', JSON::to_json( \@pop_lat ) ],
[ 'pop_lng', JSON::to_json( \@pop_lng ) ],
[ 'pop_haps', JSON::to_json( \@pop_haps ) ],
[ 'hapgroups', JSON::to_json( \@hapgroups ) ],
[ 'set_hap_colors', JSON::to_json( \@set_hap_colors ) ],
[ 'pop_include', JSON::to_json( \@pop_include ) ],
[ 'hap_include', JSON::to_json( \@hap_include ) ],
[ 'radii_in_km', JSON::to_json( \@pie_sizes ) ],
[ 'link_options', JSON::to_json( \%link_options ) ],
);
if ($balloon) {
$iframe_height = '400';
$iframe_width = '400';
my $map_padding = 40;
push @phylo_link_params,
(
[ 'map_width', $iframe_width - $map_padding ],
[ 'map_height', $iframe_height - $map_padding ],
[ 'map_only', 1 ],
);
}
# must escape the JSON objects
my $request_str = join( '&',
map { $_->[0] . "=" . CGI::escape( $_->[1] ) } @phylo_link_params );
# For some reason, the balloon interprets the escaping.
# So we must escape again if it is a balloon.
if ($balloon) {
$request_str = CGI::escape($request_str);
}
my %options = (
style_sheet => $style_sheet,
numpops => $numpops,
numhaps => $numhaps,
request_str => $request_str,
phylo_url => $phylo_url,
iframe_width => $iframe_width,
iframe_height => $iframe_height,
balloon => $balloon,
);
$template->process( \*DATA, \%options, \$html )
or die $template->error();
print $html;
return;
}
=pod
=head2 print_pop_details
This method prints out the population details for the given feature. This is
to be presented in a smallish popup balloon. It presents population
information and creates links to GBrowse.
The reason that this is not it's own script is that it is just a small portion
of the gbrowse_gmap project. I'm trying to minimize the file footprint of this
project.
=cut
sub print_pop_details {
my $self = shift;
my %args = @_;
my $pop_name = $args{pop_name} or return 0;
my $type_geolocation = $args{type_geolocation} or return 0;
my $population_data = $args{population_data} or return 0;
my $pop_key = undef;
foreach my $local_pop_key ( keys %$type_geolocation ) {
print STDERR "POP_KEY $local_pop_key\n";
if ( $type_geolocation->{$local_pop_key}{'key'} eq $pop_name ) {
print STDERR "FOUND\n";
$pop_key = $local_pop_key;
last;
}
}
return 0 unless ( defined $pop_key );
my $longitude = $type_geolocation->{$pop_key}{'longitude'};
my $latitude = $type_geolocation->{$pop_key}{'latitude'};
my $category = $type_geolocation->{$pop_key}{'category'};
print header, start_html;
print qq[
<div id="phylo_popup_div" >
$pop_name <br>
Location: $latitude, $longitude <br>
<table>
];
for my $hap_name ( sort keys %{ $population_data->{$pop_key} } ) {
print "<tr> <td>$hap_name:</td> <td>"
. $population_data->{$pop_key}{$hap_name}
. "</td></tr>\n";
}
print "</table>";
print "</div>";
print end_html;
return 1;
}
__DATA__
[% IF not balloon %]
<body onLoad="window.location='[% phylo_url %]?[% request_str %]';">
</body>
[% ELSE %]
<iframe frameborder=1 scrolling=auto height=[% iframe_height %] width=[% iframe_width %] src="[% phylo_url %]?[% request_str %]">ALT</iframe>
<BR>
<a href="[% phylo_url %]?[% request_str %]">Local PhyloGeoViz</a>
<BR>
<a href="http://phylogeoviz.org/latest/newviewer.php?[% request_str %]">Official PhyloGeoViz</a>
[% END %]
<a href="http://phylogeoviz.org/latest/newviewer.php?[% request_str %]">Official PhyloGeoViz</a>
( run in 0.811 second using v1.01-cache-2.11-cpan-364913b4093 )