Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed add recent track
  • Loading branch information
yuj12001 committed Oct 11, 2015
1 parent e60598c commit a7c8547
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 36 deletions.
81 changes: 46 additions & 35 deletions VQI_GenomeBrowser.js
Expand Up @@ -73,7 +73,8 @@ function VQI_GenomeBrowser(id, serviceURL) {
for (i in trackInfo){ for (i in trackInfo){


if (trackInfo[i].name == track){ 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; break;
} }
} }
Expand Down Expand Up @@ -539,6 +540,7 @@ function VQI_GenomeBrowser(id, serviceURL) {
}; };


var uploadFile = function(data,name,genome){ var uploadFile = function(data,name,genome){
//console.log(data);
headerArray = ["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"]; headerArray = ["CHROM","CHROM_START","CHROM_END","GENESYMBOL","SCORE","STRAND"];


for (i in headerArray) { for (i in headerArray) {
Expand All @@ -559,9 +561,9 @@ function VQI_GenomeBrowser(id, serviceURL) {
var CurrentFileHandle = data; var CurrentFileHandle = data;
var trackName = CurrentFileHandle; var trackName = CurrentFileHandle;
if(name !== undefined){ 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(); updateRecentTrackDropDown();
self.addTrack(trackName , "custom" , {table_name: CurrentFileHandle}); self.addTrack(trackName , "custom" , {table_name: CurrentFileHandle});
}).error(function (req, status, error) { }).error(function (req, status, error) {
Expand Down Expand Up @@ -772,42 +774,51 @@ function VQI_GenomeBrowser(id, serviceURL) {
}); });
} }


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

if(fromServer){
var trackIndex = trackList.length; 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; var trackCount = trackIndex + 1;
//name of track //name of track
name = name || "track-" + (trackIndex + 1); name = name || "track-" + (trackIndex + 1);


if(type == "cpg") if(type == "cpg")
{ {
trackList.push(new CpgTrack(name, graphRegion.append("g"), args)); trackList.push(new CpgTrack(name, graphRegion.append("g"), args));
} }
else if(type == "genes") else if(type == "genes")
{ {
trackList.push(new BedTrack(name, graphRegion.append("g"), args)); trackList.push(new BedTrack(name, graphRegion.append("g"), args));
} }
else if(type == "fasta") else if(type == "fasta")
{ {
trackList.push(new FastaTrack(name, graphRegion.append("g"), args)); trackList.push(new FastaTrack(name, graphRegion.append("g"), args));
} }
else else
{ {
args.exportable = true; args.exportable = true;
trackList.push(new CustomTrack(name, graphRegion.append("g"), args)); trackList.push(new CustomTrack(name, graphRegion.append("g"), args));
} }


setPanExtent(); setPanExtent();
graph(chrom_curr); graph(chrom_curr);


clipPath.attr("height", Number(svg.attr("height"))); clipPath.attr("height", Number(svg.attr("height")));
zoomOnly = true; zoomOnly = true;
zoomed(); zoomed();
zoomOnly = false; zoomOnly = false;


reorderTracks(); reorderTracks();
updateAllTracksSelectBoxes(); updateAllTracksSelectBoxes();
}


} }


Expand Down
5 changes: 4 additions & 1 deletion VQI_GenomeBrowserDemo.html
Expand Up @@ -46,6 +46,7 @@
genes: {file: "../../genome/hg19_genes.txt", table_name:'hg19_gene_annotation'}, genes: {file: "../../genome/hg19_genes.txt", table_name:'hg19_gene_annotation'},
cpg: {file: "../../genome/hg19_genes.txt", table_name:'hg19_cpg'},*/ 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"}, //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"}, 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"}, 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'} //custom: {file: "", table_name:'upload1436411775'}
Expand All @@ -59,10 +60,12 @@
}; };


obj.loadGenomes(genomes); //loads the genomes based on the datastructure described above obj.loadGenomes(genomes); //loads the genomes based on the datastructure described above
setTimeout(function(){ hs()}, 3000); setTimeout(function(){ hs()}, 1000);
function hs (){ function hs (){
obj.setGenome("HG19"); 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("HG19");
// obj.setGenome("MM9"); //should set hg19 genome in dropdown and display fasta, cpg and genes tracks. // obj.setGenome("MM9"); //should set hg19 genome in dropdown and display fasta, cpg and genes tracks.


Expand Down
1 change: 1 addition & 0 deletions dynamic_loading.php
Expand Up @@ -18,6 +18,7 @@


if (isset($_POST["upload"])){ if (isset($_POST["upload"])){
$timestamp = (new DateTime())->getTimestamp(); $timestamp = (new DateTime())->getTimestamp();
$timestamp = "upload".$timestamp;
$data = parseData($_POST["upload"]); $data = parseData($_POST["upload"]);
if(isset($_POST["tableName"])){ if(isset($_POST["tableName"])){
$result = insertToDb($_POST["tableName"], $_POST["header"],$data); $result = insertToDb($_POST["tableName"], $_POST["header"],$data);
Expand Down

0 comments on commit a7c8547

Please sign in to comment.