Skip to content
Permalink
Browse files

Some changes when adding tracks

  • Loading branch information
csw11004 committed Sep 18, 2015
1 parent cbe57b8 commit 874ec6518fec9ea333d970b5b30afe237691a250
Showing with 126 additions and 114 deletions.
  1. +92 −98 VQI_GenomeBrowser.js
  2. +34 −16 dynamic_loading.php
@@ -57,6 +57,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
}
else
{
setPanExtent();
graph(chrom, chrom_start, chrom_end);
}
}
@@ -150,7 +151,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
var navigateBox = "<input type='text' name='navigate' id='navigate' size='30'>";
var navigateButton = "<input type='button' id='navigatebutton' value='Go To'>";
var form = "<form id='navigation_form'>" + navigateBox + navigateButton + "</form>";
$("#" + divId + " #trackNavContainer").append(form);
$("#" + divId).append(form);
$("#" + divId + " #navigatebutton").on("click", navigateToRegion.bind(this));
};
this.makeNavigationForm();
@@ -264,7 +265,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
};
this.makeFormForColocalization();

var removeSelectedTracks = function () {
/*var removeSelectedTracks = function () {
for (var i = trackList.length - 1; i >= 0; i--) {
if (trackList[i].isSelected())
{
@@ -274,7 +275,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
}
reorderTracks();
updateAllTracksSelectBoxes();
}
}*/

var removeTrack = function (track_name) {
for (var i = trackList.length - 1; i >= 0; i--) {
@@ -284,11 +285,13 @@ function VQI_GenomeBrowser(id, serviceURL) {
trackList.splice(i, 1);
}
}
setPanExtent();
graph(chrom_curr, xScale.domain()[0], xScale.domain()[1]);
reorderTracks();
updateAllTracksSelectBoxes();
}

this.getSelectedTrackNames = function(){
/* this.getSelectedTrackNames = function(){
var tracknames = []
for (var i in trackList) {
if (trackList[i].isSelected())
@@ -319,7 +322,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
for (var i in tracknames) {
exportTrack(tracknames[i]);
}
}
}*/

var exportTrack = function (track_name) {

@@ -391,8 +394,8 @@ function VQI_GenomeBrowser(id, serviceURL) {
var mcEntForm = "<form id='mcEntForm'>" + mcScoreButton + "&nbsp&nbsp&nbsp"+entScoreButton +"</form>";
//$("#" + divId +" #exportRemoveContainer").append(removeExportform);
$("#" + divId +" #mcEntContainer").append(mcEntForm);
$("#" + divId + " #removetrackbutton").on("click", removeSelectedTracks.bind(this));
$("#" + divId + " #exporttrackbutton").on("click", exportSelectedTracks.bind(this));
//$("#" + divId + " #removetrackbutton").on("click", removeSelectedTracks.bind(this));
//$("#" + divId + " #exporttrackbutton").on("click", exportSelectedTracks.bind(this));
};
this.makeSelectionForm();

@@ -568,10 +571,8 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

var updateTrack = function(){
if (isready){
for (i in trackList) {
trackList[i].updateTrack();
}
for (i in trackList) {
trackList[i].updateTrack();
}
}
var testRemove = function(){
@@ -646,24 +647,16 @@ function VQI_GenomeBrowser(id, serviceURL) {
zoomed();
}

var setPanExtent = function (min, max) {
var setPanExtent = function () {

var mins = [];
var maxs = [];

if (min != null && max != null)
{
mins.push(Number(min));
maxs.push(Number(max));
}

for (var i in trackList) {
mins.push(d3.min(trackList[i], function (d) {
return Number(d[indexArray.start])
}));
maxs.push(d3.max(trackList[i], function (d) {
return Number(d[indexArray.end])
}));
range = trackList[i].getRange();

mins.push(Number(range[0]));
maxs.push(Number(range[1]));
}

min = d3.min(mins);
@@ -700,22 +693,7 @@ function VQI_GenomeBrowser(id, serviceURL) {

var trackIndex = trackList.length;

//check if min and max of whole graph needs to be readjusted
var min = d3.min(data, function (d) {
return Number(d[indexArray.start])
});
var max = d3.max(data, function (d) {
return Number(d[indexArray.start])
});
if (min < panExtent[0] || max > panExtent[1])
{
setPanExtent(min, max);
graph(chrom_curr);
}

var thisData = data.filter(function (d) {
return (d[indexArray.chr] === chrom_curr);
});
var trackCount = trackIndex + 1;
//name of track
name = name || "track-" + (trackIndex + 1);
@@ -727,6 +705,9 @@ function VQI_GenomeBrowser(id, serviceURL) {
if(type == "fasta")
trackList.push(new FastaTrack(name, graphRegion.append("g"), args));

setPanExtent();
graph(chrom_curr);

clipPath.attr("height", Number(svg.attr("height")));
zoomOnly = true;
zoomed();
@@ -741,68 +722,13 @@ function VQI_GenomeBrowser(id, serviceURL) {
}
}

this.addTrackFromDatabase = function() {
var chrom = "chr1";
var fileHandles = [];
var name = [];
for (i in trackInfo) {
fileHandles.push(trackInfo[i].fileHandle);
name.push(trackInfo[i].name);
}

$.ajax({
url: serviceURL,
type: 'POST',
dataType: "json",
data: {
"getStartEndTrackData": "",
"fileHandles": fileHandles,
"name": name,
"chrom": chrom
}

}).success(function (returnData) {
for (i in trackInfo){
thisObj.addTrack(returnData[i], trackInfo[i].name, trackInfo[i].type);
}

isready = true;
updateTrack();
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
});
}

this.addOneTrackFromDatabase = function(fileHandle,name,type) {
var chrom = "chr1";

$.ajax({
url: serviceURL,
type: 'POST',
dataType: "json",
data: {
"getStartEndTrackData": "",
"fileHandles": [fileHandle],
"name": [name],
"chrom": chrom
}

}).success(function (returnData) {
thisObj.addTrack(returnData[0], name, type, {"fileHandle" : fileHandle});
isready = true;
updateTrack();
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
});
thisObj.addTrack([], name, type, {"fileHandle" : fileHandle});
}

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

if(data[0][0] != "chrom")
{
data.unshift(["chrom", "chrom_start", "chrom_end", "name", "score", "strand"])
}
data = addOneTrack(data, name, type, args);
addOneTrack(data, name, type, args);

reorderTracks();
updateAllTracksSelectBoxes();
@@ -818,7 +744,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
});
}

this.setData = function (data) {
/* this.setData = function (data) {
genomeData = data;
graph(chromosomes[0]);
}
@@ -889,7 +815,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
genomeData = genomeData.concat(shelveData);
thisObj.addTrack(genomeData, "cpg", 'cpg');
});
}
}*/

this.parseTrackFile = function (data, header) {
var delimeter = "\t";
@@ -1118,6 +1044,8 @@ function VQI_GenomeBrowser(id, serviceURL) {
this.updateTrack = function(){};

this.getData = function(){};

this.getRange = function(){};
}

function CpgTrack(name, group, args) {
@@ -1132,6 +1060,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
var data;
var redrawCutoff = 1000; //Scale at which rectangles will be drawn individually


var getScale = function(){
if(zoom.scale() < redrawCutoff)
return fullXScale;
@@ -1339,6 +1268,28 @@ function VQI_GenomeBrowser(id, serviceURL) {
this.getData = function(){
return data;
}

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

return range;
}
}

function BedTrack(name, group, args) {
@@ -1591,6 +1542,28 @@ function VQI_GenomeBrowser(id, serviceURL) {
this.getData = function(){
return data;
}

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

return range;
}
}

function FastaTrack(name, group, args) {
@@ -1716,6 +1689,27 @@ function VQI_GenomeBrowser(id, serviceURL) {
clearTrack();
}
}

this.getRange = function(){
var range;
$.ajax({
url: serviceURL,
type: 'POST',
dataType: "json",
async : false,
data: {
"getFastaRange": "",
"chrom": chrom_curr,
"indexFile": indexFile
}
}).success(function (returnData) {
range = returnData;
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
});

return range;
}
}
}

0 comments on commit 874ec65

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