
The purpose of this code is to create a mash up of GBrowse data and Google Maps that displays diversity data of a feature in the locations that they were sampled.

This code was started as a modification of the gbrowse_details script.
Template Toolkit is used to generate the html for the page. The template is encased after the __DATA__ token.

PhyloGeoViz is a Google Maps/Population data mashup. It does the heavy lifting of displaying the diversity data on Google Maps. This means that PhyloGeoViz (or something functionally equivalent) is required for the gbrowse_gmap script to work.
Fortunately, PhyloGeoViz is freely available and easy to install.
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/ .
PhyloGeoViz is a PHP application. Make sure PHP is installed and working on your server.
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
Examples:
mkdir /var/www/html/phylogeoviz
or
mkdir /usr/local/apache2/htdocs/phylogeoviz
Copy the contents of the phylogeoviz-read-only directory into the newly created directory:
cp phylogeoviz-read-only/* /var/www/html/phylogeoviz/
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
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.
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.
To check that the installation worked, go to your web site:
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.
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.
A track is identified as being a population if it has latitude and longitude values assigned in the configuration file.
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.
Only features that have the same start and end as the chosen feature will be displayed. If a feature has a different start or end, it will be excluded.
I'm pretty sure that this won't work for anything other than SeqFeature::Store. I haven't tested that assumption though. There should be a way to generalize this. The feature searching is where I'm conserned about it.
contig1 Contig scaffold 1 793 . . . Name=contig1 contig1 POPA SNP 50 50 8 . . ID=snp.POPA.contig1.50.AA;Name=AA contig1 POPA SNP 50 50 4 . . ID=snp.POPA.contig1.50.AG;Name=AG contig1 POPB SNP 50 50 1 . . ID=snp.POPB.contig1.50.AA;Name=AA contig1 POPB SNP 50 50 4 . . ID=snp.POPB.contig1.50.AG;Name=AG contig1 POPB SNP 50 50 5 . . ID=snp.POPB.contig1.50.NN;Name=NN contig1 POPC SNP 50 50 3 . . ID=snp.POPC.contig1.50.AA;Name=AA contig1 POPC SNP 50 50 2 . . ID=snp.POPC.contig1.50.AG;Name=AG
Since this script is now using PhyloGeoViz for the GMap interactions, we no longer need the api key. I'm keeping this section of comments in case we ever need it again.

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.