Skip to content
Permalink
Browse files

tool-tip server side support

  • Loading branch information
yuj12001 committed Aug 12, 2015
1 parent dc3f36b commit 6da2578c4c3801d5794d2dc56f32962dec136b80
Showing with 142 additions and 7 deletions.
  1. +30 −2 VQI_GenomeBrowser.js
  2. +2 −2 VQI_GenomeBrowserDemo.html
  3. +110 −3 dynamic_loading.php
@@ -476,7 +476,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
if (isready){
var start = (Math.round(xScale.domain()[0])).toString();
var end = (Math.round(xScale.domain()[1])).toString();
var chrom = "chr1";
var chrom = chrom_curr;
var fileHandles = [];
var name = [];

@@ -967,6 +967,31 @@ function VQI_GenomeBrowser(id, serviceURL) {

var addTooltip = function(selection, name, type)
{
var start = (Math.round(xScale.domain()[0])).toString();
var end = (Math.round(xScale.domain()[1])).toString();
var scale = (end - start)/1000;

var fileHandle = '';
if(type == "cpg"){
fileHandle = 'upload1437097194';
}
else if(type == "shelve"){
fileHandle = 'upload1437098473';
}
else if (type == "shore"){
fileHandle = 'upload1437098556';
}
else if (name == "HG19"){
fileHandle = 'upload1436481988';
}
else {
for(i in trackInfo){
if(name == trackInfo[i].name){
fileHandle = trackInfo[i].fileHandle;
break;
}
}
}
selection.qtip({
content: {
text: function(event, api) {
@@ -976,9 +1001,12 @@ function VQI_GenomeBrowser(id, serviceURL) {
dataType: "json",
data: {
"loadTooltip": "",
"chrom": chrom_curr,
"trackName" : name,
"type" : type,
"xCoordinate" : event.pageX
"xCoordinate" : event.pageX - 60,
"scale": scale,
'fileHandle': fileHandle
}
})
.then(function(content) {
@@ -39,8 +39,8 @@
["chr1", "1597292", "1597293", "rs79791328", "0", "+"],
["chr1", "1597292", "1597293", "rs79791328", "0", "+"]];
obj.uploadFileFromServer(data,"test","testgenome");
obj.uploadFileFromServer(data,"tests","testgenomes");
// obj.uploadFileFromServer(data,"test","testgenome");
// obj.uploadFileFromServer(data,"tests","testgenomes");
//setTimeout(function(){ obj.uploadFileFromServer(data,"test","testgenome"); }, 3000);
// var snpFile = file_dir + "./Tile2contentsnpplotter.txt";
@@ -11,6 +11,7 @@
$password = "";
$DBlink = mysqli_connect($host_name, $user_name, $password);
$currentRow = 0;
/***************************/
@@ -50,7 +51,7 @@
ajaxReturn($result);
}
else if (isset($_POST["loadTooltip"])){
$result = loadTooltip($_POST["trackName"], $_POST["type"], $_POST["xCoordinate"]);
$result = loadTooltip($_POST["chrom"],$_POST["trackName"], $_POST["type"], $_POST["xCoordinate"],$_POST["scale"],$_POST["fileHandle"]);
ajaxReturn($result);
}
else {
@@ -498,10 +499,116 @@ function getStartEndTrackData($fileHandles,$name,$chrom){
return $returnArray;
}
function loadTooltip($trackName, $type, $xCoordinate){
return $trackName.$type.$xCoordinate;
function loadTooltip($chrom,$trackName, $type, $xCoordinate, $scale, $fileHandle){
//return $chrom.$trackName.$type.$xCoordinate.$scale.$fileHandle;
if($trackName == "cpg"){
return loadCPGTooltip($chrom,$type, $xCoordinate,$scale,$fileHandle);
}
else if($trackName == 'HG19'){
return loadHG19Tooltip($chrom,$type, $xCoordinate,$scale,$fileHandle);
}
else{
return loadBEDTooltip($chrom,$type, $xCoordinate,$scale,$fileHandle);
}
}
function loadCPGTooltip($chrom,$type, $xCoordinate,$scale,$fileHandle){
$db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink'];
$min = $xCoordinate*$scale - $scale/2;
$max = $xCoordinate*$scale + $scale/2;
$sql = "SELECT `START`, `END` FROM {$db_name}.{$fileHandle}";
$sql .= " WHERE `CHROM` = '".$chrom."'";
$sql .= " AND (((`START` BETWEEN $min AND $max) OR (`END` BETWEEN $min AND $max))";
$sql .= " OR (`START` <= $min AND `END` >= $max))";
$sql .= " ORDER BY `START` * 1 ASC";
$res = mysqli_query ($link,$sql);
$returnArray = [];
$compString = "";
while($row = mysqli_fetch_row($res)){
$start = (string)$row[0];
$end = (string)$row[1];
//$compString.(string)$row[0]."-".(string)$row[1].", ";
$compString .= $start."-".$end.", ";
}
$compString = substr($compString,0,-2);
return $type.": ".$compString;
}
function loadHG19Tooltip($chrom,$type, $xCoordinate,$scale,$fileHandle){
$db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink'];
$min = $xCoordinate*$scale - $scale/2;
$max = $xCoordinate*$scale + $scale/2;
$sql = "SELECT `txStart`, `txEnd`, `name2`, `exonStarts`, `exonEnds` FROM {$db_name}.{$fileHandle}";
$sql .= " WHERE `chrom` = '".$chrom."'";
$sql .= " AND (((`txStart` BETWEEN $min AND $max) OR (`txEnd` BETWEEN $min AND $max))";
$sql .= " OR (`txStart` <= $min AND `txEnd` >= $max))";
$sql .= " ORDER BY `txStart` * 1 ASC";
$res = mysqli_query ($link,$sql);
$returnArray = [];
$compString = "";
while($row = mysqli_fetch_row($res)){
if($type == "gene"){
$start = (string)$row[0];
$end = (string)$row[1];
$name = (string)$row[2];
//$compString.(string)$row[0]."-".(string)$row[1].", ";
$compString .= $name." (".$start."-".$end."), ";
}
else{
$name = (string)$row[2];
$start = substr((string)$row[3],0,-1);
$end = substr((string)$row[4],0,-1);
$compString .= $name."(".$start."-".$end."), ";
}
}
$compString = substr($compString,0,-2);
return $type.": ".$compString;
}
function loadBEDTooltip($chrom,$type, $xCoordinate,$scale,$fileHandle){
$db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink'];
$min = $xCoordinate*$scale - $scale/2;
$max = $xCoordinate*$scale + $scale/2;
$sql = "SELECT `CHROM_START`, `CHROM_END`, `GENESYMBOL` FROM {$db_name}.{$fileHandle}";
$sql .= " WHERE `CHROM` = '".$chrom."'";
$sql .= " AND (((`CHROM_START` BETWEEN $min AND $max) OR (`CHROM_END` BETWEEN $min AND $max))";
$sql .= " OR (`CHROM_START` <= $min AND `CHROM_END` >= $max))";
$sql .= " ORDER BY `CHROM_START` * 1 ASC";
$res = mysqli_query ($link,$sql);
$returnArray = [];
$compString = "";
while($row = mysqli_fetch_row($res)){
$start = (string)$row[0];
$end = (string)$row[1];
$name = (string)$row[2];
//$compString.(string)$row[0]."-".(string)$row[1].", ";
$compString .= $name. " (".$start."-".$end."), ";
}
$compString = substr($compString,0,-2);
return $type.": ".$compString;
}
function ajaxReturn($result){
echo json_encode($result);
}

0 comments on commit 6da2578

Please sign in to comment.
You can’t perform that action at this time.