Skip to content
Permalink
Browse files

Export track for all chromosomes and delete confirmation

  • Loading branch information
csw11004 committed Sep 19, 2015
1 parent 3b56814 commit 2bf102cc7a877871052b747db87909a6b99418b2
Showing with 124 additions and 29 deletions.
  1. +91 −23 VQI_GenomeBrowser.js
  2. +9 −6 VQI_GenomeBrowserDemo.html
  3. +24 −0 dynamic_loading.php
@@ -31,9 +31,9 @@ function VQI_GenomeBrowser(id, serviceURL) {


var trackInfo = [];
trackInfo[0] = {name: "HG19", type: "bed", fileHandle: "upload1436481988"};
trackInfo[1] = {name: "Tile2 Content Snp", type: "bed", fileHandle: "upload1436411775"};
trackInfo[2] = {name: "cpg", type: "cpg", fileHandle: "upload1437097194,upload1437098473,upload1437098556"};
trackInfo[0] = {name: "HG19", type: "bed", args: {fileHandle: "upload1436481988"}};
trackInfo[1] = {name: "Tile2 Content Snp", type: "bed", args: {fileHandle: "upload1436411775", exportable: true}};
trackInfo[2] = {name: "cpg", type: "cpg", args: {fileHandle: "upload1437097194,upload1437098473,upload1437098556"}};

var serviceURL = serviceURL;

@@ -76,7 +76,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
for (i in trackInfo){

if (trackInfo[i].name == track){
self.addOneTrackFromDatabase(trackInfo[i].fileHandle,track,trackInfo[i].type);
self.addTrack([] , track , trackInfo[i].type , trackInfo[i].args);
break;
}
}
@@ -285,8 +285,8 @@ function VQI_GenomeBrowser(id, serviceURL) {
trackList.splice(i, 1);
}
}
setPanExtent();
graph(chrom_curr, xScale.domain()[0], xScale.domain()[1]);
//setPanExtent();
//graph(chrom_curr, xScale.domain()[0], xScale.domain()[1]);
reorderTracks();
updateAllTracksSelectBoxes();
}
@@ -555,7 +555,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
}
trackInfo.push({name: trackName, type: "bed", fileHandle: CurrentFileHandle});
updateRecentTrackDropDown();
self.addOneTrackFromDatabase(CurrentFileHandle,trackName,"bed");
self.addTrack([] , trackName , "bed" , trackInfo[i].args);
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
});
@@ -722,10 +722,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
}
}

this.addOneTrackFromDatabase = function(fileHandle,name,type) {
thisObj.addTrack([], name, type, {"fileHandle" : fileHandle});
}

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

addOneTrack(data, name, type, args);
@@ -951,7 +947,13 @@ function VQI_GenomeBrowser(id, serviceURL) {
});
}

function Track(name, group) {
function Track(name, group, args) {
//Perhaps I need a better structure if I'm just going to pass custom arguments through args as a json object
//Possible value pairs:
//filehandle : string
//exportable : boolean
//file : string
//indexFile : string
this.group = group;
this.name = name;

@@ -973,27 +975,77 @@ function VQI_GenomeBrowser(id, serviceURL) {


group.append("foreignObject")
.attr("width", 50)
.attr("width", 20)
.attr("height", 20)
.attr("x", width+5)
.attr("y", -7.5)
.attr("y", -15)
.append("xhtml:div")
.html("<form><input type=image src=DeleteTrack.png width=15 height=15 onclick='return false;'></form>")
.on("click", function () {
removeTrack(name);
deleteConfirm.style("visibility", "visible");
});

if(args.exportable)
{
group.append("foreignObject")
.attr("width", 20)
.attr("height", 20)
.attr("x", width+5)
.attr("y", 0)
.append("xhtml:div")
.html("<form><input type=image src=ExportTrack.png width=15 height=15 onclick='return false;'></form>")
.on("click", function () {
exportTrack(name);
});
}

group.append("foreignObject")
.attr("width", 50)
.attr("width", 20)
.attr("height", 20)
.attr("x", width+25)
.attr("y", -7.5)
.attr("y", -10)
.attr("class", "checkbox")
.append("xhtml:div")
.html("<form><input type=checkbox id='check'/></form>")
.on("click", function () {
xAxisSelection.call(xAxis)});//I have no idea why it won't redraw the checkbox unless I call this

var deleteConfirm = group.append("g")
.style("visibility", "hidden");

deleteConfirm.append("rect")
.attr("width", 40)
.attr("height", 50)
.attr("x", width+5)
.attr("y", -25)
.style("fill", "white")

deleteConfirm.append("text")
.attr("x", width+5)
.attr("y", -25)
.text("Delete?")

deleteConfirm.append("foreignObject")
.attr("width", 40)
.attr("height", 20)
.attr("x", width+5)
.attr("y", -20)
.append("xhtml:div")
.html("<form><input type=button value='Yes' onclick='return false;'></form>")
.on("click", function () {
removeTrack(name);
});

deleteConfirm.append("foreignObject")
.attr("width", 40)
.attr("height", 20)
.attr("x", width+5)
.attr("y", 0)
.append("xhtml:div")
.html("<form><input type=image src=ExportTrack.png width=15 height=15 onclick='return false;'></form>")
.html("<form><input type=button value='No' onclick='return false;'></form>")
.on("click", function () {
exportTrack(name);
deleteConfirm.style("visibility", "hidden");
});


group.append("path")
.attr("transform", function (d) {
@@ -1049,7 +1101,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

function CpgTrack(name, group, args) {
Track.call(this, name, group);
Track.call(this, name, group, args);
var trackGroup = this.trackGroup;

var fileHandle = args.fileHandle;
@@ -1293,7 +1345,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

function BedTrack(name, group, args) {
Track.call(this, name, group)
Track.call(this, name, group, args)
var trackGroup = this.trackGroup;

var fileHandle = args.fileHandle;
@@ -1540,6 +1592,22 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

this.getData = function(){
var data;
$.ajax({
url: serviceURL,
type: 'POST',
dataType: "json",
async : false,
data: {
"getFullTrackData": "",
"fileHandles": [fileHandle]
}
}).success(function (returnData) {
data = returnData;
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
});

return data;
}

@@ -1567,7 +1635,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

function FastaTrack(name, group, args) {
Track.call(this, name, group);
Track.call(this, name, group, args);
var trackGroup = this.trackGroup;

var file = args.file;
@@ -29,13 +29,16 @@
var obj = new VQI_GenomeBrowser("test",'dynamic_loading.php');
//insert path to file and indexfile
obj.addTrack([[""],[""]], "fasta", "fasta",
{ "file" : "",
"indexFile" : ""});
obj.addTrack([], "fasta", "fasta",
{ file : "",
indexFile : ""});
obj.addOneTrackFromDatabase("upload1437097194,upload1437098473,upload1437098556", "cpg", "cpg");
obj.addOneTrackFromDatabase("upload1436481988", "HG19", "bed");
obj.addOneTrackFromDatabase("upload1436411775", "Tile2 Content Snp", "bed");
obj.addTrack([], "cpg", "cpg",
{fileHandle : "upload1437097194,upload1437098473,upload1437098556"});
obj.addTrack([], "HG19", "bed", {fileHandle : "upload1436481988"});
obj.addTrack([], "Tile2 Content Snp", "bed",
{ fileHandle : "upload1436411775",
exportable : true});
/*var data = [["chr1", "896004", "896005", ".", "0", "+"],
["chr1", "976170", "976171", ".", "-.4", "+"],
["chr1", "1198674", "1198675", ".", "0", "+"],
@@ -62,6 +62,10 @@
$result = getFastaRange($_POST["chrom"],$_POST["indexFile"]);
ajaxReturn($result);
}
else if (isset($_POST["getFullTrackData"])){
$result = getFullTrackData($_POST["fileHandles"]);
ajaxReturn($result);
}
else {
loadTable();
}
@@ -512,6 +516,26 @@ function getTrackData($fileHandles,$name,$chrom,$start,$end){
return $returnArray;
}
function getFullTrackData($fileHandles){
$returnArray = [];
foreach ($fileHandles as $key => $value) {
$fileHandle = $value;
$db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink'];
$sql = "SELECT `CHROM`, `CHROM_START`, `CHROM_END`, `GENESYMBOL`, `SCORE` FROM {$db_name}.{$fileHandle}";
$sql .= " ORDER BY LENGTH(`CHROM`), `CHROM`, `CHROM_START` * 1 ASC";
$res = mysqli_query ($link,$sql);
while($row = mysqli_fetch_row($res)){
array_push($returnArray, [$row[0],$row[1],$row[2],$row[3],$row[4]]);
}
}
return $returnArray;
}
function getRange($fileHandles,$name,$chrom){
$db_name = $GLOBALS['db_name'];
$link = $GLOBALS['DBlink'];

0 comments on commit 2bf102c

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