Skip to content
Permalink
Browse files

load track from server fixed

  • Loading branch information
yuj12001 committed Aug 6, 2015
1 parent e5c22a0 commit 6fa59af1da419ea9ae1cefa9a305f977b32b1fff
Showing with 52 additions and 24 deletions.
  1. +42 −24 VQI_GenomeBrowser.js
  2. +10 −0 VQI_GenomeBrowserDemo.html
@@ -26,6 +26,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
var isready = false;
var zoomOnly = false;
var waitTime;
var loadCount = 0;


var trackInfo = [];
@@ -59,7 +60,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
}
};
var addRecentTrack = function(){
console.log(trackInfo);
var track = $("#" + divId + " #RecentTracks").val();
for (i in trackList){
if (trackList[i]['name'] == track){
@@ -421,17 +421,19 @@ function VQI_GenomeBrowser(id, serviceURL) {
"font-size": "11px"});

if (! zoomOnly){
//updateTrack();
if (waitTime != undefined)
{
clearTimeout(waitTime);
}
waitTime = setTimeout(updateTrack, 100); }
waitTime = setTimeout(updateTrack, 100);
}
$("#" + divId + " #navigate").val(chrom_curr + ":" + Math.round(xScale.domain()[0]) + "-" + Math.round(xScale.domain()[1]));
};

var uploadFile = function(data){
var rows = data.split("\n");
headerArray = rows[0].split("\t");
var uploadFile = function(data,name,genome){
//var rows = data.split("\n");
headerArray = ["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"];

for (i in headerArray) {
indexArray[headerArray[i]] = i;
@@ -449,17 +451,28 @@ function VQI_GenomeBrowser(id, serviceURL) {

}).success(function (data) {
var CurrentFileHandle = data;
console.log(CurrentFileHandle);
trackInfo.push({name: CurrentFileHandle, type: "bed", fileHandle: CurrentFileHandle});
var trackName = CurrentFileHandle;
if(name !== undefined){
var trackName = name+" "+genome;
}
trackInfo.push({name: trackName, type: "bed", fileHandle: CurrentFileHandle});
updateRecentTrackDropDown();
self.addOneTrackFromDatabase(CurrentFileHandle,CurrentFileHandle,"bed");
self.addOneTrackFromDatabase(CurrentFileHandle,trackName,"bed");
}).error(function (req, status, error) {
$("body").append(status + ": " + error);
});
}

var updateTrack = function(){
this.uploadFileFromServer = function(data,name,genome){
var temp = [];
for (i in data) {
temp.push(data[i].join('\t'));
}
trackData = temp.join('\n');
uploadFile(trackData,name,genome);
}

var updateTrack = function(){
if (isready){
var start = (Math.round(xScale.domain()[0])).toString();
var end = (Math.round(xScale.domain()[1])).toString();
@@ -491,21 +504,22 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

}).success(function (returnData) {

for (i in trackList){
var name = trackList[i]['name'];
var type = trackList[i]['type'];
trackList[i] = returnData[name];
trackList[i]['name'] = name;
trackList[i]['type'] = type;
if (name == "HG19"){
addBEDTrack(returnData[name][0], name, returnData[name][1]);
}
else if (name == "cpg"){
addCpgTrack(returnData[name], name);
}
else{
addBEDTrack(returnData[name], name);
if(returnData[name] != undefined){
trackList[i] = returnData[name];
trackList[i]['name'] = name;
trackList[i]['type'] = type;
if (name == "HG19"){
addBEDTrack(returnData[name][0], name, returnData[name][1]);
}
else if (name == "cpg"){
addCpgTrack(returnData[name], name);
}
else{
addBEDTrack(returnData[name], name);
}
}
}

@@ -577,7 +591,9 @@ function VQI_GenomeBrowser(id, serviceURL) {
zoom.translate([zoomWidth, 0])
.scale(scale);

zoomOnly = true;
zoomed();
zoomOnly = false;
}

var setPanExtent = function (min, max) {
@@ -631,6 +647,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

var addOneTrack = function (data, name, type, i) {
//console.log("addonetrack");
i = Number(i);
var trackIndex;
if (!isNaN(i)) {
@@ -670,6 +687,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

data['name'] = name;
//console.log(data);
clipPath.attr("height", Number(svg.attr("height")));
zoomOnly = true;
zoomed();
@@ -975,7 +993,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

this.addTrackFromDatabase = function(){

var chrom = "chr1";
var fileHandles = [];
var name = [];
@@ -1010,7 +1027,6 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

this.addOneTrackFromDatabase = function(fileHandle,name,type){

var chrom = "chr1";

$.ajax({
@@ -1034,13 +1050,15 @@ function VQI_GenomeBrowser(id, serviceURL) {
}

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

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

//console.log("addtrack");
trackList.push(data);


reorderTracks();
updateAllTracksSelectBoxes();
@@ -32,6 +32,16 @@
//obj.addTrackFile(genomeFile, "base", 'bed');
obj.addTrackFromDatabase();
var data = [["chr1", "896004", "896005", ".", "0", "+"],
["chr1", "976170", "976171", ".", "-.4", "+"],
["chr1", "1198674", "1198675", ".", "0", "+"],
["chr1", "1250433", "1250434", ".", "1", "+"],
["chr1", "1597292", "1597293", "rs79791328", "0", "+"],
["chr1", "1597292", "1597293", "rs79791328", "0", "+"]];
obj.uploadFileFromServer(data,"test","testgenome");
obj.uploadFileFromServer(data,"tests","testgenomes");
//setTimeout(function(){ obj.uploadFileFromServer(data,"test","testgenome"); }, 3000);
// var snpFile = file_dir + "./Tile2contentsnpplotter.txt";
//obj.addTrackFile(snpFile, "Tile2 Content Snp", 'bed');

0 comments on commit 6fa59af

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