ccb6455950d7a814502919f00354e6b5855bcd50 kate Thu Oct 13 18:46:41 2011 -0700 Figured out how to get beautifier to accept block comments diff --git src/hg/js/encodeProject.js src/hg/js/encodeProject.js index 25c2113..e61ab10 100644 --- src/hg/js/encodeProject.js +++ src/hg/js/encodeProject.js @@ -1,42 +1,45 @@ -// encodeProject - javascript utilities for ENCODE-specific things -// such as controlled vocabulary and experiment table +/* encodeProject - javascript utilities for ENCODE-specific things + such as controlled vocabulary and experiment table -// Formatted: jsbeautify.py -j -// Syntax checked: jslint --indent=4 --plusplus=true --strict=false --browser=true + Formatted: jsbeautify.py -j -k + Syntax checked: jslint --indent=4 --plusplus=true --strict=false --browser=true +*/ /*global $ */ var encodeProject = (function () { var server = "genome.ucsc.edu", assembly = "hg19", cgi = "/cgi-bin/hgApi?"; function cmpNoCase(a, b) { // Helper function for case-insensitive sort var A, B; A = a.toUpperCase(); B = b.toUpperCase(); if (A < B) { return -1; } if (A > B) { return 1; } return 0; } // TODO: modularize by extending Array.sort ? + + function cmpCV(a, b) { // Helper function for case-insensitive sort of CV objects // Use label if any, otherwise the term A = (a.label !== undefined ? a.label.toUpperCase() : a.term.toUpperCase()); B = (b.label !== undefined ? b.label.toUpperCase() : b.term.toUpperCase()); if (A < B) { return -1; } if (A > B) { return 1; } return 0; } return { @@ -49,32 +52,31 @@ server = settings.assembly; } }, getServer: function () { // Get currently set server return server; }, getDataGroups: function (dataTypes) { // Return sorted array of dataGroup objects each having a .label, // .dataTypes, // and an array of dataTypes, alphasorted, with 'Other' last var dataGroupHash = {}, dataGroups = [], - otherGroup, - group; + otherGroup, group; $.each(dataTypes, function (i, dataType) { group = dataType.dataGroup; if (!group) { return true; } if (!dataGroupHash[group]) { dataGroupHash[group] = { label: group, dataTypes: [] }; } dataGroupHash[group].dataTypes.push(dataType.label); }); $.each(dataGroupHash, function (key, item) { if (key === "Other") { @@ -116,60 +118,57 @@ cellTiers[tier].cellTypes.push(cellType.term); }); cellTiers.sort(cmpCV); $.each(cellTiers, function (i, tier) { if (!cellTiers[i]) { // for some reason there's __ element here (not my property) return true; } cellTiers[i].cellTypes.sort(cmpNoCase); }); return cellTiers; }, isHistone: function (target) { // Helper function, returns true if antibody target histone modification - return target.match(/^H[234]/); }, antibodyFromExp: function (experiment) { // Get antibody from expVars field of experiment var match = experiment.expVars.match(/antibody=(\S+)/); if (match) { return match[1]; } }, targetFromAntibody: function (antibody, antibodyCV) { // Get target for antibody from antibody controlled vocab if (antibodyCV[antibody]) { return antibodyCV[antibody].target; } }, getAntibodyGroups: function (antibodies) { // Return sorted array of antibodyGroup objects each having a .label // with group name (Histone Modification or Transcription Factor), // and an array of antibody targets, alphasorted var antibodyGroups = [], antibodyGroupHash = {}, - group, - target; + group, target; $.each(antibodies, function (i, antibody) { - group = encodeProject.isHistone(antibody.target) ? - "Histone Modification" : "Transcription Factor"; + group = encodeProject.isHistone(antibody.target) ? "Histone Modification" : "Transcription Factor"; if (!antibodyGroupHash[group]) { antibodyGroupHash[group] = { label: group, targets: [], targetHash: {} }; } target = antibody.target; if (antibodyGroupHash[group].targetHash[target] === undefined) { antibodyGroupHash[group].targetHash[target] = target; antibodyGroupHash[group].targets.push(target); } }); $.each(antibodyGroupHash, function (key, item) { antibodyGroups.push(item);