From a7c854743951fc6da24d2e4d35e3f525db970ffc Mon Sep 17 00:00:00 2001 From: Yuchen Jiang Date: Sun, 11 Oct 2015 16:02:17 -0400 Subject: [PATCH] fixed add recent track --- VQI_GenomeBrowser.js | 81 ++++++++++++++++++++++---------------- VQI_GenomeBrowserDemo.html | 5 ++- dynamic_loading.php | 1 + 3 files changed, 51 insertions(+), 36 deletions(-) diff --git a/VQI_GenomeBrowser.js b/VQI_GenomeBrowser.js index cd3ddca..557ded5 100755 --- a/VQI_GenomeBrowser.js +++ b/VQI_GenomeBrowser.js @@ -73,7 +73,8 @@ function VQI_GenomeBrowser(id, serviceURL) { for (i in trackInfo){ if (trackInfo[i].name == track){ - self.addTrack(track[i].name , trackInfo[i].type , trackInfo[i].args); + console.log([trackInfo[i].name,trackInfo[i].type , trackInfo[i].args]); + self.addTrack(trackInfo[i].name , trackInfo[i].type , trackInfo[i].args); break; } } @@ -539,6 +540,7 @@ function VQI_GenomeBrowser(id, serviceURL) { }; var uploadFile = function(data,name,genome){ + //console.log(data); headerArray = ["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"]; for (i in headerArray) { @@ -559,9 +561,9 @@ function VQI_GenomeBrowser(id, serviceURL) { var CurrentFileHandle = data; var trackName = CurrentFileHandle; if(name !== undefined){ - var trackName = name+" "+genome; + var trackName = name; } - trackInfo.push({name: trackName, type: "custom", args: {fileHandle: CurrentFileHandle, exportable: true}}); + trackInfo.push({name: trackName, type: "custom", args: {table_name: CurrentFileHandle, exportable: true}}); updateRecentTrackDropDown(); self.addTrack(trackName , "custom" , {table_name: CurrentFileHandle}); }).error(function (req, status, error) { @@ -772,42 +774,51 @@ function VQI_GenomeBrowser(id, serviceURL) { }); } - this.addTrack = function (name, type, args) { - - var trackIndex = trackList.length; + this.addTrack = function (name, type, args, fromServer) { + if(fromServer){ + var temp = []; + for (i in args) { + temp.push(args[i].join('\t')); + } + trackData = temp.join('\n'); + uploadFile(trackData,name); + } + else{ + var trackIndex = trackList.length; - var trackCount = trackIndex + 1; - //name of track - name = name || "track-" + (trackIndex + 1); + var trackCount = trackIndex + 1; + //name of track + name = name || "track-" + (trackIndex + 1); - if(type == "cpg") - { - trackList.push(new CpgTrack(name, graphRegion.append("g"), args)); - } - else if(type == "genes") - { - trackList.push(new BedTrack(name, graphRegion.append("g"), args)); - } - else if(type == "fasta") - { - trackList.push(new FastaTrack(name, graphRegion.append("g"), args)); - } - else - { - args.exportable = true; - trackList.push(new CustomTrack(name, graphRegion.append("g"), args)); - } + if(type == "cpg") + { + trackList.push(new CpgTrack(name, graphRegion.append("g"), args)); + } + else if(type == "genes") + { + trackList.push(new BedTrack(name, graphRegion.append("g"), args)); + } + else if(type == "fasta") + { + trackList.push(new FastaTrack(name, graphRegion.append("g"), args)); + } + else + { + args.exportable = true; + trackList.push(new CustomTrack(name, graphRegion.append("g"), args)); + } - setPanExtent(); - graph(chrom_curr); + setPanExtent(); + graph(chrom_curr); - clipPath.attr("height", Number(svg.attr("height"))); - zoomOnly = true; - zoomed(); - zoomOnly = false; - - reorderTracks(); - updateAllTracksSelectBoxes(); + clipPath.attr("height", Number(svg.attr("height"))); + zoomOnly = true; + zoomed(); + zoomOnly = false; + + reorderTracks(); + updateAllTracksSelectBoxes(); + } } diff --git a/VQI_GenomeBrowserDemo.html b/VQI_GenomeBrowserDemo.html index 718d021..beac1d1 100644 --- a/VQI_GenomeBrowserDemo.html +++ b/VQI_GenomeBrowserDemo.html @@ -46,6 +46,7 @@ genes: {file: "../../genome/hg19_genes.txt", table_name:'hg19_gene_annotation'}, cpg: {file: "../../genome/hg19_genes.txt", table_name:'hg19_cpg'},*/ //fasta: {fasta: "/Users/corywang/Downloads/hg19.fa.txt", index : "/Users/corywang/Downloads/hg19.fa.fai.txt"}, + 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'} @@ -59,10 +60,12 @@ }; obj.loadGenomes(genomes); //loads the genomes based on the datastructure described above - setTimeout(function(){ hs()}, 3000); + setTimeout(function(){ hs()}, 1000); function hs (){ obj.setGenome("HG19"); } + // obj.addTrack("HG19_Custom","Custom",[["CHROM", "CHROM_START" ,"CHROM_END" , "GENESYMBOL", "SCORE", "STRAND"],["chr1" , "896004" , "896005" , "." , "0" , "+"]],true); + //obj.setGenome("HG19"); // obj.setGenome("MM9"); //should set hg19 genome in dropdown and display fasta, cpg and genes tracks. diff --git a/dynamic_loading.php b/dynamic_loading.php index de38178..178ef60 100644 --- a/dynamic_loading.php +++ b/dynamic_loading.php @@ -18,6 +18,7 @@ if (isset($_POST["upload"])){ $timestamp = (new DateTime())->getTimestamp(); + $timestamp = "upload".$timestamp; $data = parseData($_POST["upload"]); if(isset($_POST["tableName"])){ $result = insertToDb($_POST["tableName"], $_POST["header"],$data);