Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
csw11004 committed Oct 11, 2015
1 parent c57eb45 commit e60598c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 57 deletions.
24 changes: 5 additions & 19 deletions VQI_GenomeBrowser.js
Expand Up @@ -73,7 +73,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
for (i in trackInfo){ for (i in trackInfo){


if (trackInfo[i].name == track){ if (trackInfo[i].name == track){
self.addTrack([] , track , trackInfo[i].type , trackInfo[i].args); self.addTrack(track[i].name , trackInfo[i].type , trackInfo[i].args);
break; break;
} }
} }
Expand Down Expand Up @@ -227,7 +227,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
}, },
async: true async: true
}).success(function (data) { }).success(function (data) {
console.log(data);
$("#pvalue_div").empty().append("p-value = " + data); $("#pvalue_div").empty().append("p-value = " + data);
}).error(function (req, status, error) { }).error(function (req, status, error) {
$("body").append(status + ": " + error); $("body").append(status + ": " + error);
Expand Down Expand Up @@ -711,7 +710,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
selectBox.options.length = 0; selectBox.options.length = 0;
var optionIndex = 0; var optionIndex = 0;
for (var key in genomes) { for (var key in genomes) {
console.log(key)
var text = key; var text = key;
var value = key; var value = key;
selectBox.options[optionIndex++] = new Option(text, value); selectBox.options[optionIndex++] = new Option(text, value);
Expand Down Expand Up @@ -751,7 +749,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
for(var key in genomes[genome]) for(var key in genomes[genome])
{ {
this.addTrack(genome+"_"+key, key, genomes[genome][key]) this.addTrack(genome+"_"+key, key, genomes[genome][key])
// console.log(genomes[genome][key]);
} }
} }
} }
Expand All @@ -769,7 +766,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
} }


}).success(function (returnData) { }).success(function (returnData) {
console.log(returnData);
} }
).error(function (req, status, error) { ).error(function (req, status, error) {
$("body").append(status + ": " + error); $("body").append(status + ": " + error);
Expand Down Expand Up @@ -1237,7 +1233,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
} }


}).success(function (returnData) { }).success(function (returnData) {
// console.log(returnData);
drawTrack(returnData); drawTrack(returnData);
LoadingText.remove(); LoadingText.remove();
} }
Expand Down Expand Up @@ -1290,7 +1285,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
async : false, async : false,
data: { data: {
"getRange": "", "getRange": "",
"fileHandles": [fileHandle], "fileHandle": fileHandle,
"type": "cpg", "type": "cpg",
"chrom": chrom_curr "chrom": chrom_curr
} }
Expand Down Expand Up @@ -1372,19 +1367,13 @@ function VQI_GenomeBrowser(id, serviceURL) {


if (exons) if (exons)
{ {
trackGroup.selectAll("rect")
.data(data, function (d) {
return d;
})
.exit()
.remove();

trackGroup.selectAll("rect") trackGroup.selectAll("rect")
.data(exons, function (d) { .data(exons, function (d) {
return d; return d;
}) })
.enter() .enter()
.append("rect"); .append("rect");

trackGroup.selectAll("rect") trackGroup.selectAll("rect")
.data(exons, function (d) { .data(exons, function (d) {
return d; return d;
Expand Down Expand Up @@ -1503,7 +1492,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
} }


}).success(function (returnData) { }).success(function (returnData) {
// console.log(returnData);
if(returnData.length == 2) {//exons exist if(returnData.length == 2) {//exons exist


drawTrack(returnData[0], returnData[1]); drawTrack(returnData[0], returnData[1]);
Expand Down Expand Up @@ -1563,7 +1551,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
} }
}).success(function (returnData) { }).success(function (returnData) {
data = returnData; data = returnData;
console.log(returnData);
data.unshift(["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"]); data.unshift(["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"]);
}).error(function (req, status, error) { }).error(function (req, status, error) {
$("body").append(status + ": " + error); $("body").append(status + ": " + error);
Expand All @@ -1581,7 +1568,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
async : false, async : false,
data: { data: {
"getRange": "", "getRange": "",
"fileHandles": [fileHandle], "fileHandle": fileHandle,
"type": "gene", "type": "gene",
"chrom": chrom_curr "chrom": chrom_curr
} }
Expand Down Expand Up @@ -1815,7 +1802,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
} }
}).success(function (returnData) { }).success(function (returnData) {
data = returnData; data = returnData;
console.log(returnData);
data.unshift(["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"]); data.unshift(["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"]);
}).error(function (req, status, error) { }).error(function (req, status, error) {
$("body").append(status + ": " + error); $("body").append(status + ": " + error);
Expand All @@ -1833,7 +1819,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
async : false, async : false,
data: { data: {
"getRange": "", "getRange": "",
"fileHandles": [fileHandle], "fileHandle": fileHandle,
"type": "custom", "type": "custom",
"chrom": chrom_curr "chrom": chrom_curr
} }
Expand Down
2 changes: 1 addition & 1 deletion VQI_GenomeBrowserDemo.html
Expand Up @@ -49,7 +49,7 @@
genes: {file: "hg19_refgene.txt", table_name: "hg19_refgene"}, genes: {file: "hg19_refgene.txt", table_name: "hg19_refgene"},
cpg: {file: "cpg_site_hg19.txt,shelve_hg19.txt,shoer_hg19.txt", table_name: "cpg_site_hg19,shelve_hg19,shoer_hg19"}, cpg: {file: "cpg_site_hg19.txt,shelve_hg19.txt,shoer_hg19.txt", table_name: "cpg_site_hg19,shelve_hg19,shoer_hg19"},
//custom: {file: "", table_name:'upload1436411775'} //custom: {file: "", table_name:'upload1436411775'}
}, }
// "MM9":{ // "MM9":{
// fasta: {fasta: "/Users/corywang/Downloads/mm9.fa.txt", index: "/Users/corywang/Downloads/mm9.fa.fai.txt"}, // fasta: {fasta: "/Users/corywang/Downloads/mm9.fa.txt", index: "/Users/corywang/Downloads/mm9.fa.fai.txt"},
// //genes: {file: "../../genome/mm9/mm9_genes.txt", table_name:'mm9_gene_annotation'}, // //genes: {file: "../../genome/mm9/mm9_genes.txt", table_name:'mm9_gene_annotation'},
Expand Down
72 changes: 35 additions & 37 deletions dynamic_loading.php
@@ -1,22 +1,22 @@
<?php <?php
//set content type and xml tag //set content type and xml tag
header("Content-type: text/xml"); header("Content-type: text/xml");
/**************************/ /**************************/
// replace these information if needed // replace these information if needed
$db_name = "test"; $db_name = "test";
$table_name = ""; $table_name = "";
$host_name = "localhost"; $host_name = "localhost";
$user_name = "root"; $user_name = "root";
$password = ""; $password = "";
$DBlink = mysqli_connect($host_name, $user_name, $password); $DBlink = mysqli_connect($host_name, $user_name, $password);
$currentRow = 0; $currentRow = 0;


/***************************/ /***************************/






if (isset($_POST["upload"])){ if (isset($_POST["upload"])){
$timestamp = (new DateTime())->getTimestamp(); $timestamp = (new DateTime())->getTimestamp();
$data = parseData($_POST["upload"]); $data = parseData($_POST["upload"]);
if(isset($_POST["tableName"])){ if(isset($_POST["tableName"])){
Expand Down Expand Up @@ -54,7 +54,7 @@
ajaxReturn($result); ajaxReturn($result);
} }
else if (isset($_POST["getRange"])){ else if (isset($_POST["getRange"])){
$result = getRange($_POST["fileHandles"], $_POST["type"], $_POST["chrom"]); $result = getRange($_POST["fileHandle"], $_POST["type"], $_POST["chrom"]);
ajaxReturn($result); ajaxReturn($result);
} }
else if (isset($_POST["loadTooltip"])){ else if (isset($_POST["loadTooltip"])){
Expand Down Expand Up @@ -305,8 +305,8 @@
} }


function mergeExons($geneStart, $geneEnd, $Exstart, $Exend, $start,$end, $scale){ function mergeExons($geneStart, $geneEnd, $Exstart, $Exend, $start,$end, $scale){
$ExStartArray = explode(",",substr($Exstart,0,-1)); $ExStartArray = explode(",",trim($Exstart, '"'));
$ExEndArray = explode(",",substr($Exend,0,-1)); $ExEndArray = explode(",",trim($Exend, '"'));


if ($geneEnd-$geneStart < 1/$scale){ if ($geneEnd-$geneStart < 1/$scale){


Expand Down Expand Up @@ -587,7 +587,7 @@
return $returnArray; return $returnArray;
} }


function getRange($fileHandles,$type,$chrom){ function getRange($fileHandle,$type,$chrom){
$db_name = $GLOBALS['db_name']; $db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink']; $link = $GLOBALS['DBlink'];


Expand All @@ -598,8 +598,6 @@
$sql .= " ORDER BY `CHROM_START` * 1 ASC"; $sql .= " ORDER BY `CHROM_START` * 1 ASC";


# code... # code...
$fileHandle = $value;

$minsql = "SELECT `CHROM`, `CHROM_START`, `CHROM_END`, `GENESYMBOL`, `SCORE` FROM {$db_name}.{$fileHandle} ORDER BY `CHROM_START` * 1 ASC LIMIT 1"; $minsql = "SELECT `CHROM`, `CHROM_START`, `CHROM_END`, `GENESYMBOL`, `SCORE` FROM {$db_name}.{$fileHandle} ORDER BY `CHROM_START` * 1 ASC LIMIT 1";
if ($type == "gene"){ if ($type == "gene"){
$minsql = "SELECT `chrom`, `txStart`, `txEnd`, `name2`, `score` FROM {$db_name}.{$fileHandle} ORDER BY `txStart` * 1 ASC LIMIT 1"; $minsql = "SELECT `chrom`, `txStart`, `txEnd`, `name2`, `score` FROM {$db_name}.{$fileHandle} ORDER BY `txStart` * 1 ASC LIMIT 1";
Expand Down Expand Up @@ -923,7 +921,7 @@
$table_name = $_GET["tableRef"]; $table_name = $_GET["tableRef"];
} }
} }
if(isset($_GET["posStart"])) if(isset($_GET["posStart"]))
$posStart = $_GET['posStart']; $posStart = $_GET['posStart'];
else else
$posStart = 0; $posStart = 0;
Expand All @@ -932,35 +930,35 @@
else else
$count = 100; $count = 100;


$currentRow = $posStart; $currentRow = $posStart;
$totalCount = 0; $totalCount = 0;
//connect to database //connect to database
$link = mysqli_connect($host_name, $user_name, $password); $link = mysqli_connect($host_name, $user_name, $password);
//$db = mysqli_select_db ("test"); //$db = mysqli_select_db ("test");


//create query to products table //create query to products table
$sql = "SELECT * FROM {$db_name}.{$table_name}"; $sql = "SELECT * FROM {$db_name}.{$table_name}";
//if this is the first query - get total number of records in the query result //if this is the first query - get total number of records in the query result
if($posStart==0){ if($posStart==0){
$sqlCount = "Select count(*) as cnt from ($sql) as tbl"; $sqlCount = "Select count(*) as cnt from ($sql) as tbl";
$resCount = mysqli_query ($link,$sqlCount); $resCount = mysqli_query ($link,$sqlCount);
$rowCount=mysqli_fetch_assoc($resCount); $rowCount=mysqli_fetch_assoc($resCount);
$totalCount = $rowCount["cnt"]; $totalCount = $rowCount["cnt"];
} }
if(isset($_GET["name_mask"]) && isset($_GET["filter_attribute"])){ if(isset($_GET["name_mask"]) && isset($_GET["filter_attribute"])){
$p = $_GET['filter_attribute']; $p = $_GET['filter_attribute'];
$sql.=" Where {$p} = '".$_GET["name_mask"]."'"; $sql.=" Where {$p} = '".$_GET["name_mask"]."'";


$sqlCount = "Select count(*) as cnt from ($sql) as tbl"; $sqlCount = "Select count(*) as cnt from ($sql) as tbl";
$resCount = mysqli_query ($link,$sqlCount); $resCount = mysqli_query ($link,$sqlCount);
$rowCount=mysqli_fetch_assoc($resCount); $rowCount=mysqli_fetch_assoc($resCount);
$totalCount = $rowCount["cnt"]; $totalCount = $rowCount["cnt"];
} }
if (isset($_GET["order"]) && isset($_GET["sort_attribute"])){ if (isset($_GET["order"]) && isset($_GET["sort_attribute"])){
$order = $_GET['order']; $order = $_GET['order'];
$sort_attribute = $_GET['sort_attribute']; $sort_attribute = $_GET['sort_attribute'];
$ifNumeric = "SELECT `".$sort_attribute."` FROM {$db_name}.{$table_name} LIMIT 1"; $ifNumeric = "SELECT `".$sort_attribute."` FROM {$db_name}.{$table_name} LIMIT 1";
$res = mysqli_query ($link, $ifNumeric); $res = mysqli_query ($link, $ifNumeric);
$resArray = mysqli_fetch_row($res); $resArray = mysqli_fetch_row($res);
Expand All @@ -970,8 +968,8 @@
else { else {
$sql.=" ORDER BY $sort_attribute $order"; $sql.=" ORDER BY $sort_attribute $order";
} }
} }


//add limits to query to get only rows necessary for the output //add limits to query to get only rows necessary for the output
$sql.= " LIMIT ".$posStart.",".$count; $sql.= " LIMIT ".$posStart.",".$count;
Expand All @@ -995,13 +993,13 @@
// print("<cell>"); // print("<cell>");
// print($row[3]); // print($row[3]);
// print("</cell>"); // print("</cell>");
// print("<cell>"); // print("<cell>");
// print($row[4]); // print($row[4]);
// print("</cell>"); // print("</cell>");
// print("<cell>"); // print("<cell>");
// print($row[5]); // print($row[5]);
// print("</cell>"); // print("</cell>");
// print("<cell>"); // print("<cell>");
// print($row[6]); // print($row[6]);
// print("</cell>"); // print("</cell>");
foreach ($row as $key=>$title){ foreach ($row as $key=>$title){
Expand All @@ -1013,5 +1011,5 @@
} }
print("</rows>"); print("</rows>");
} }
?> ?>

0 comments on commit e60598c

Please sign in to comment.