Skip to content
Permalink
Browse files

Check table exists method added

  • Loading branch information
csw11004 committed Oct 9, 2015
1 parent fc7e395 commit 9d92804cea55c9ea75f2c72c778c2c007a3a2bb4
Showing with 100 additions and 43 deletions.
  1. +46 −4 VQI_GenomeBrowser.js
  2. +1 −1 VQI_GenomeBrowserDemo.html
  3. +53 −38 dynamic_loading.php
@@ -711,9 +711,25 @@ function VQI_GenomeBrowser(id, serviceURL) {
selectBox.options.length = 0;
var optionIndex = 0;
for (var key in genomes) {
console.log(key)
var text = key;
var value = key;
selectBox.options[optionIndex++] = new Option(text, value);
for(var key2 in genomes[key])
{
if(key2 === 'custom' || key2 ==='genes')
{
checkTableUpload(genomes[key][key2].table_name)
}
if(key2 === 'cpg')
{
var tempHandles = genomes[key][key2].table_name.split(",");
for(var i in tempHandles)
{
checkTableUpload(tempHandles[i].trim())
}
}
}
}
}

@@ -729,6 +745,25 @@ function VQI_GenomeBrowser(id, serviceURL) {
}
}

var checkTableUpload = function(tableName) {

$.ajax({
url: serviceURL,
type: 'POST',
dataType: "json",
data: {
"checkTable": "",
"tableName": tableName
}

}).success(function (returnData) {
console.log(returnData);
}
).error(function (req, status, error) {
$("body").append(status + ": " + error);
});
}

this.addTrack = function (name, type, args) {

var trackIndex = trackList.length;
@@ -738,12 +773,19 @@ function VQI_GenomeBrowser(id, serviceURL) {
name = name || "track-" + (trackIndex + 1);

if(type == "cpg")
{
trackList.push(new CpgTrack(name, graphRegion.append("g"), args));
}
else if(type == "genes")
{
trackList.push(new BedTrack(name, graphRegion.append("g"), args));
}
else if(type == "fasta")
{
trackList.push(new FastaTrack(name, graphRegion.append("g"), args));
else{
}
else
{
args.exportable = true;
trackList.push(new CustomTrack(name, graphRegion.append("g"), args));
}
@@ -1236,7 +1278,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
data: {
"getRange": "",
"fileHandles": [fileHandle],
"name": [name],
"type": "cpg",
"chrom": chrom_curr
}
}).success(function (returnData) {
@@ -1526,7 +1568,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
data: {
"getRange": "",
"fileHandles": [fileHandle],
"name": [name],
"type": "gene",
"chrom": chrom_curr
}
}).success(function (returnData) {
@@ -1778,7 +1820,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
data: {
"getRange": "",
"fileHandles": [fileHandle],
"name": [name],
"type": "custom",
"chrom": chrom_curr
}
}).success(function (returnData) {
@@ -47,7 +47,7 @@
cpg: {file: "../../genome/hg19_genes.txt", table_name:'hg19_cpg'},*/
fasta: {fasta: "/Users/corywang/Downloads/hg19.fa.txt", index : "/Users/corywang/Downloads/hg19.fa.fai.txt"},
genes: {file: "", table_name: "upload1436481988"},
cpg: {files: "", table_name: "upload1437097194,upload1437098473,upload1437098556"},
cpg: {file: "", table_name: "upload1437097194,upload1437098473,upload1437098556"},
custom: {file: "", table_name:'upload1436411775'}
},
"MM9":{
@@ -54,7 +54,7 @@
ajaxReturn($result);
}
else if (isset($_POST["getRange"])){
$result = getRange($_POST["fileHandles"], $_POST["name"], $_POST["chrom"]);
$result = getRange($_POST["fileHandles"], $_POST["type"], $_POST["chrom"]);
ajaxReturn($result);
}
else if (isset($_POST["loadTooltip"])){
@@ -73,10 +73,30 @@
$result = getFullTrackData($_POST["fileHandle"]);
ajaxReturn($result);
}
else if (isset($_POST["checkTable"])){
$result = checkTable($_POST["tableName"]);
ajaxReturn($result);
}
else {
loadTable();
}
function checkTable($tableName){
$db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink'];
$sql = "SELECT * FROM {$db_name}.{$tableName} LIMIT 1";
$res = mysqli_query ($link,$sql);
$firstRow = mysqli_fetch_row($res);
if($firstRow)
return "true";
else
return "false";
}
function loadFastaData($chrom, $start, $length, $file, $indexFile){
$indexFile = fopen($indexFile, "r");
@@ -299,7 +319,7 @@ function mergeExons($geneStart, $geneEnd, $Exstart, $Exend, $start,$end, $scale)
}
}
function getHG19TrackData($fileHandle,$chrom,$start,$end){
function getGeneTrackData($fileHandle,$chrom,$start,$end){
$db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink'];
@@ -541,7 +561,7 @@ function getFullTrackData($fileHandles){
return $returnArray;
}
function getRange($fileHandles,$name,$chrom){
function getRange($fileHandles,$type,$chrom){
$db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink'];
@@ -551,47 +571,42 @@ function getRange($fileHandles,$name,$chrom){
$sql .= " WHERE `CHROM` = '".$chrom."'";
$sql .= " ORDER BY `CHROM_START` * 1 ASC";
foreach ($fileHandles as $key => $value) {
# code...
$fileHandle = $value;
$fileHandle = $value;
$minsql = "SELECT `CHROM`, `CHROM_START`, `CHROM_END`, `GENESYMBOL`, `SCORE` FROM {$db_name}.{$fileHandle} ORDER BY `CHROM_START` * 1 ASC LIMIT 1";
if ($name[$key] == "HG19"){
$minsql = "SELECT `chrom`, `txStart`, `txEnd`, `name2`, `score` FROM {$db_name}.{$fileHandle} ORDER BY `txStart` * 1 ASC LIMIT 1";
}
if ($name[$key] == "cpg"){
$temp = explode(",", $fileHandle);
$shelveFile = $temp[1];
$minsql = "SELECT `CHROM`, `START`, `END` FROM {$db_name}.{$shelveFile} ORDER BY `START` * 1 ASC LIMIT 1";
}
$minres = mysqli_query ($link,$minsql);
$minsql = "SELECT `CHROM`, `CHROM_START`, `CHROM_END`, `GENESYMBOL`, `SCORE` FROM {$db_name}.{$fileHandle} ORDER BY `CHROM_START` * 1 ASC LIMIT 1";
if ($type == "gene"){
$minsql = "SELECT `chrom`, `txStart`, `txEnd`, `name2`, `score` FROM {$db_name}.{$fileHandle} ORDER BY `txStart` * 1 ASC LIMIT 1";
}
if ($type == "cpg"){
$temp = explode(",", $fileHandle);
$shelveFile = $temp[1];
$minsql = "SELECT `CHROM`, `START`, `END` FROM {$db_name}.{$shelveFile} ORDER BY `START` * 1 ASC LIMIT 1";
}
$minres = mysqli_query ($link,$minsql);
while($row = mysqli_fetch_row($minres))
{
$min = $row[1];
array_push($returnArray, $min);
}
$row = mysqli_fetch_row($minres);
$min = $row[1];
array_push($returnArray, $min);
$maxsql = "SELECT `CHROM`, `CHROM_START`, `CHROM_END`, `GENESYMBOL`, `SCORE` FROM {$db_name}.{$fileHandle} ORDER BY `CHROM_END` * 1 DESC LIMIT 1";
if ($name[$key] == "HG19"){
$maxsql = "SELECT `chrom`, `txStart`, `txEnd`, `name2`, `score` FROM {$db_name}.{$fileHandle} ORDER BY `txEnd` * 1 DESC LIMIT 1";
}
if ($name[$key] == "cpg"){
$temp = explode(",", $fileHandle);
$shelveFile = $temp[1];
$maxsql = "SELECT `CHROM`, `START`, `END` FROM {$db_name}.{$shelveFile} ORDER BY `END` * 1 DESC LIMIT 1";
}
$maxres = mysqli_query ($link,$maxsql);
$maxsql = "SELECT `CHROM`, `CHROM_START`, `CHROM_END`, `GENESYMBOL`, `SCORE` FROM {$db_name}.{$fileHandle} ORDER BY `CHROM_END` * 1 DESC LIMIT 1";
if ($type == "gene"){
$maxsql = "SELECT `chrom`, `txStart`, `txEnd`, `name2`, `score` FROM {$db_name}.{$fileHandle} ORDER BY `txEnd` * 1 DESC LIMIT 1";
}
if ($type == "cpg"){
$temp = explode(",", $fileHandle);
$shelveFile = $temp[1];
$maxsql = "SELECT `CHROM`, `START`, `END` FROM {$db_name}.{$shelveFile} ORDER BY `END` * 1 DESC LIMIT 1";
}
$maxres = mysqli_query ($link,$maxsql);
while($row = mysqli_fetch_row($maxres))
{
$max = $row[2];
array_push($returnArray, $max);
}
$row = mysqli_fetch_row($maxres);
$max = $row[2];
array_push($returnArray, $max);
}
return $returnArray;
}
}
function loadTooltip($chrom, $type, $min, $max, $fileHandle){
//return $chrom.$trackName.$type.$xCoordinate.$scale.$fileHandle;
@@ -642,7 +657,7 @@ function loadCPGTooltip($chrom,$type, $min,$max,$fileHandle){
}
function loadHG19Tooltip($chrom,$type, $min,$max,$fileHandle){
function loadGeneTooltip($chrom,$type, $min,$max,$fileHandle){
$db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink'];

0 comments on commit 9d92804

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