9a49290fedc8b4f9c7a631dedcfe8ac3aa2b4cee chinhli Thu Oct 20 14:10:43 2011 -0700 merge conflict resolved diff --git src/hg/js/encodeChipMatrix.js src/hg/js/encodeChipMatrix.js index 2afc3f0..479caec 100644 --- src/hg/js/encodeChipMatrix.js +++ src/hg/js/encodeChipMatrix.js @@ -1,27 +1,27 @@ // encodeChipMatrix.js - pull experiment table and metadata from server // and display ChIP antibodies vs. cell types in a matrix - // Formatted: jsbeautify.py -j // Syntax checked: jslint indent:4, plusplus: true, continue: true, unparam: true, sloppy: true, browser: true */ /*global $, encodeProject */ $(function () { - var requests = [ + var dataType, server, requests = [ // Requests to server API - encodeProject.serverRequests.experiment, encodeProject.serverRequests.cellType, encodeProject.serverRequests.antibody], - dataType; + encodeProject.serverRequests.experiment, + encodeProject.serverRequests.cellType, + encodeProject.serverRequests.antibody]; function tableOut(matrix, cellTiers, cellTypeHash, antibodyGroups, antibodyHash, targetHash) { // Create table where rows = cell types and columns are datatypes // create table and first row 2 rows (column title and column headers) var table, tableHeader, row, td; table = $('<table>' + '<tr><td><td class="axisType" colspan=6>Antibody Targets</td></tr>' + '<tr id="columnHeaders"><td class="axisType">Cell Types</td></tr>'); tableHeader = $('#columnHeaders', table); $.each(antibodyGroups, function (i, group) { tableHeader.append('<th class="groupType"><div class="verticalText">' + group.label + '</div></th>'); $.each(group.targets, function (i, target) { if (targetHash[target] === undefined) { return true; } // prune out targets with no experiments @@ -56,31 +56,31 @@ //$(".cellType").click(matrixClickHandler); //"searchWindow"); // prune out targets with no experiments if (targetHash[target] === undefined) { return true; } if (targetHash[target].count === undefined) { return true; } td = '<td class="cellType'; if (matrix[cellType][target]) { td += ' experiment'; } td += '">'; if (matrix[cellType][target]) { - td += '<a target=_blank href="http://genome-preview.ucsc.edu/cgi-bin/hgTracks?db=hg19&tsCurTab=advancedTab&hgt_tsPage=&hgt_tSearch=search&hgt_mdbVar1=cell&hgt_mdbVar2=target&hgt_mdbVal1='; + td += '<a target="searchWindow" href="http://genome-preview.ucsc.edu/cgi-bin/hgTracks?db=hg19&tsCurTab=advancedTab&hgt_tsPage=&hgt_tSearch=search&hgt_mdbVar1=cell&hgt_mdbVar2=target&hgt_mdbVar3=view&hgt_mdbVal2=Any&hgt_mdbVal1='; td += cellType; td += '&hgt_mdbVal2='; // TODO: needs to be join of all antibodies for this target td += target; //td += '"><font color=#00994D>'; td += '"><font>'; td += matrix[cellType][target]; //td += "....."; td += '</font></a>'; td += '</td>'; } row.append(td); }); table.append(row); }); @@ -90,33 +90,33 @@ $("body").append(table); } function handleServerData(responses) { // Main actions, called when loading data from server is complete var experiments = responses[0], cellTypes = responses[1], antibodies = responses[2], antibodyGroups, antibodyHash = {}, targetHash = {}, cellTypeHash = {}, antibody, target, cellTiers, cellType, matrix = {}, organism, assembly, header; // variables passed in hidden fields - organism = $("#var_organism").val(); - assembly = $("#var_assembly").val(); - header = $("#var_pageHeader").val(); + organism = encodeChipMatrix_organism; + assembly = encodeChipMatrix_assembly; + header = encodeChipMatrix_pageHeader; $("#pageHeader").text(header); $("title").text('ENCODE ' + header); // set up structures for antibodies and their groups $.each(antibodies, function (i, item) { antibodyHash[item.term] = item; }); antibodyGroups = encodeProject.getAntibodyGroups(antibodies); // set up structures for cell types and their tiers $.each(cellTypes, function (i, item) { cellTypeHash[item.term] = item; }); cellTiers = encodeProject.getCellTiers(cellTypes); @@ -153,23 +153,28 @@ cellType = exp.cellType; if (!matrix[cellType]) { matrix[cellType] = {}; } if (!matrix[cellType][target]) { matrix[cellType][target] = 0; } matrix[cellType][target]++; }); // fill in table tableOut(matrix, cellTiers, cellTypeHash, antibodyGroups, antibodyHash, targetHash); } + // get server from calling web page (intended for genome-preview) + if ('encodeDataMatrix_server' in window) { + server = encodeDataMatrix_server; + } else { + server = document.location.hostname; + } + // initialize encodeProject.setup({ - // todo: add hidden page variable for server - server: "hgwdev.cse.ucsc.edu" - //server: "genome-preview.ucsc.edu" + server: server }); encodeProject.loadAllFromServer(requests, handleServerData); });