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){

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;
}
}
Expand Down Expand Up @@ -227,7 +227,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
},
async: true
}).success(function (data) {
console.log(data);
$("#pvalue_div").empty().append("p-value = " + data);
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
Expand Down Expand Up @@ -711,7 +710,6 @@ 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);
Expand Down Expand Up @@ -751,7 +749,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
for(var key in genomes[genome])
{
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) {
console.log(returnData);
}
).error(function (req, status, error) {
$("body").append(status + ": " + error);
Expand Down Expand Up @@ -1237,7 +1233,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

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

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

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

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

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

drawTrack(returnData[0], returnData[1]);
Expand Down Expand Up @@ -1563,7 +1551,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
}
}).success(function (returnData) {
data = returnData;
console.log(returnData);
data.unshift(["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"]);
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
Expand All @@ -1581,7 +1568,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
async : false,
data: {
"getRange": "",
"fileHandles": [fileHandle],
"fileHandle": fileHandle,
"type": "gene",
"chrom": chrom_curr
}
Expand Down Expand Up @@ -1815,7 +1802,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
}
}).success(function (returnData) {
data = returnData;
console.log(returnData);
data.unshift(["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"]);
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
Expand All @@ -1833,7 +1819,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
async : false,
data: {
"getRange": "",
"fileHandles": [fileHandle],
"fileHandle": fileHandle,
"type": "custom",
"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"},
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'}
},
}
// "MM9":{
// 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'},
Expand Down
72 changes: 35 additions & 37 deletions dynamic_loading.php
@@ -1,22 +1,22 @@
<?php
//set content type and xml tag
header("Content-type: text/xml");
/**************************/
// replace these information if needed
$db_name = "test";
$table_name = "";
$host_name = "localhost";
$user_name = "root";
$password = "";
header("Content-type: text/xml");
/**************************/
// replace these information if needed
$db_name = "test";
$table_name = "";
$host_name = "localhost";
$user_name = "root";
$password = "";
$DBlink = mysqli_connect($host_name, $user_name, $password);
$currentRow = 0;

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



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

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

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

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

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

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

# code...
$fileHandle = $value;

$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";
Expand Down Expand Up @@ -923,7 +921,7 @@
$table_name = $_GET["tableRef"];
}
}
if(isset($_GET["posStart"]))
if(isset($_GET["posStart"]))
$posStart = $_GET['posStart'];
else
$posStart = 0;
Expand All @@ -932,35 +930,35 @@
else
$count = 100;

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

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

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

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

0 comments on commit e60598c

Please sign in to comment.