8398cecd1f2503d61a02f863c500d289b1bbdf52 kate Fri Mar 16 18:29:02 2012 -0700 1. Cleanup repetitive code 2. Exclude bogus Reference Genome experiments (currently 5C) that are actually supplemental files. #5149-18. diff --git src/hg/js/encodeDataSummary.js src/hg/js/encodeDataSummary.js index 9cb787b..f590356 100644 --- src/hg/js/encodeDataSummary.js +++ src/hg/js/encodeDataSummary.js @@ -5,91 +5,106 @@ Syntax checked: jslint indent:4, plusplus: true, continue: true, unparam: true, sloppy: true, browser: true */ /*global $, encodeProject */ $(function () { var requests = [ // requests to server API encodeProject.serverRequests.experiment, encodeProject.serverRequests.dataType, encodeProject.serverRequests.antibody, encodeProject.serverRequests.expId ]; var $summaryTables = $('.summaryTable'); + function addDataType(dataTypeName, expList, isChip) { + // Helper function to fill datatype lists that are used to make tables + + var dataType, dataTypeLabel; + + if (!isChip) { + // get data type label + dataType = encodeProject.getDataType(dataTypeName); + if (dataType !== undefined) { + dataTypeLabel = dataType.label; + } + } + if (dataTypeLabel === undefined) { + // if there is a mismatch between experiment table and CV we might not + // find dataType for the experiment + dataTypeLabel = dataTypeName; + } + if (!expList[dataTypeLabel]) { + expList[dataTypeLabel] = 0; + } + expList[dataTypeLabel]++; + } + function handleServerData(responses) { // Main actions, called when loading data from server is complete var experiments = responses[0], dataTypes = responses[1], antibodies = responses[2], expIds = responses[3]; var cellAssayExps = {}, tfbsExps = {}, refGenomeExps = {}; var refGenomeTypes = [], elementTypes = [], tfbsTypes = []; - var dataType, antibody, target; + var antibody, dataType; encodeMatrix.show($summaryTables); antibodyGroups = encodeProject.getAntibodyGroups(antibodies); encodeProject.getDataGroups(dataTypes); // use to filter out experiments not in this assembly expIdHash = encodeProject.getExpIdHash(expIds); $.each(experiments, function (i, exp) { - // experiment not in this assembly + // exlude experiment not in this assembly if (expIdHash[exp.ix] === undefined) { return true; } - antibody = encodeProject.antibodyFromExp(exp); - if (antibody) { - target = encodeProject.targetFromAntibody(antibody); + if (exp.dataType === undefined) { + return true; } - // add experiments into the appropriate table object + // add experiment into the appropriate list if (exp.cellType === 'None') { - dataType = encodeProject.getDataType(exp.dataType); - if (dataType !== undefined) { - dataType = dataType.label; - } else { - dataType = exp.dataType; - } - if (!refGenomeExps[dataType]) { - refGenomeExps[dataType] = 0; - } - refGenomeExps[dataType]++; + addDataType(exp.dataType, refGenomeExps, false); } else if (exp.dataType === 'ChipSeq') { - if (!target) { + antibody = encodeProject.antibodyFromExp(exp); + if (!antibody) { return true; } - if (!tfbsExps[target]) { - tfbsExps[target] = 0; + dataType = encodeProject.targetFromAntibody(antibody); + if (!dataType) { + // this excludes controls + return true; } - tfbsExps[target]++; - } else { - dataType = encodeProject.getDataType(exp.dataType); - if (dataType !== undefined) { - dataType = dataType.label; + addDataType(dataType, tfbsExps, true); } else { - dataType = exp.dataType; + addDataType(exp.dataType, cellAssayExps, false); } - if (!cellAssayExps[dataType]) { - cellAssayExps[dataType] = 0; + }); + // work-around for some supplementary files being accessioned as experiments (5C) + // they show up in both reference genome and cell assay lists incorrectly + // remove them from refGenome list of they are in cellAssayExps + for (dataType in refGenomeExps) { + if (cellAssayExps[dataType] !== undefined) { + delete refGenomeExps[dataType]; } - cellAssayExps[dataType]++; } - }); // fill in tables and activate buttons tableOut('#refGenomeTable', refGenomeTypes, refGenomeExps, false); tableOut('#elementTable', elementTypes, cellAssayExps, false); $('#buttonDataMatrix').click(function () { window.location = 'encodeDataMatrixHuman.html'; }); // TODO: enable selectable items in antibody table tableOut('#tfbsTable', tfbsTypes, tfbsExps, true); $('#buttonChipMatrix').click(function () { window.location = 'encodeChipMatrixHuman.html'; }); // add row highlight $('.summaryTable').delegate('.even, .odd', 'mouseover mouseleave', function (ev) { if (ev.type == 'mouseover') {