163e77dd2c371e031edc55e8bb4d1c77cade83df
kate
  Tue Nov 1 19:43:18 2011 -0700
Complete features for ChIP-seq
diff --git src/hg/js/encodeProject.js src/hg/js/encodeProject.js
index e7ea264..d03a9e0 100644
--- src/hg/js/encodeProject.js
+++ src/hg/js/encodeProject.js
@@ -1,43 +1,30 @@
 /* encodeProject - javascript utilities for ENCODE-specific things 
  such as controlled vocabulary and experiment table
 
  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?";
 
     var accessionPrefix = 'wgEncodeE?';
 
-    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;
@@ -107,62 +94,62 @@
             });
             $.each(dataGroupHash, function (key, item) {
                 if (key === "Other") {
                     otherGroup = item;
                 } else {
                     dataGroups.push(item);
                 }
             });
             dataGroups.sort(cmpCV);
             dataGroups.push(otherGroup);
             $.each(dataGroups, function (i, group) {
                 if (!dataGroups[i]) {
                     // for some reason there's  __ element here (not my property)
                     return true;
                 }
-                dataGroups[i].dataTypes.sort(cmpNoCase);
+                dataGroups[i].dataTypes.sort(this.cmpNoCase);
             });
             return dataGroups;
         },
 
         getCellTiers: function (cellTypes) {
             // Return sorted array of cellTier objects each having a .term,
             // with tier number, .celltypes, 
             // and an array of cell types, alphasorted
             var cellTiers = [],
                 tier;
             $.each(cellTypes, function (i, cellType) {
                 tier = cellType.tier;
                 // ignore untiered cell types (all human should have a tier)
                 if (!tier) {
                     return true;
                 }
                 if (!cellTiers[tier]) {
                     cellTiers[tier] = {
                         term: tier,
                         cellTypes: []
                     };
                 }
                 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);
+                cellTiers[i].cellTypes.sort(this.cmpNoCase);
             });
             return cellTiers;
         },
 
         isHistone: function (target) {
             // Helper function, returns true if antibody target histone modification
             if (target === undefined) {
                return false;
             }
             return target.match(/^H[234]/);
         },
 
         antibodyFromExp: function (experiment) {
             // Get antibody from expVars field of experiment
             var match = experiment.expVars.match(/antibody=(\S+)/);
@@ -179,67 +166,77 @@
         },
 
         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;
             $.each(antibodies, function (i, antibody) {
                 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);
-                }
+                antibodyGroupHash[group].targets.push(antibody.target);
             });
             $.each(antibodyGroupHash, function (key, item) {
                 antibodyGroups.push(item);
             });
             antibodyGroups.sort(cmpCV);
             $.each(antibodyGroups, function (i, group) {
                 if (!antibodyGroups[i]) {
                     // for some reason there's  __ element here (not my property)
                     return true;
                 }
-                antibodyGroups[i].targets.sort(cmpNoCase);
+                antibodyGroups[i].targets.sort(this.cmpNoCase);
             });
             return antibodyGroups;
         },
 
         getExpIdHash: function (expIds) {
             // Return hash of experiment ID's
             var expIdHash = {};
             $.each(expIds, function (i, expId) {
                 expIdHash[expId.expId] = true;
             });
             return expIdHash;
         },
 
         // UNTESTED
         expIdFromAccession: function(accession) {
             return accession.slice(accessionPrefix.length);
         },
 
+        cmpNoCase: function (a, b) {
+        // Helper function for case-insensitive sort - belongs in
+        // more generic lib
+            var A, B;
+            A = a.toUpperCase();
+            B = b.toUpperCase();
+            if (A < B) {
+                return -1;
+            }
+            if (A > B) {
+                return 1;
+            }
+            return 0;
+        },
+
         serverRequests: {
             // Requests for data from server API
             experiment: "cmd=encodeExperiments",
             expId: "cmd=encodeExpId",
             dataType: "cmd=cv&type=dataType",
             cellType: "cmd=cv&type=cellType",
             antibody: "cmd=cv&type=antibody"
         },
 
         loadAllFromServer: function (requests, handler) {
             // Execute requests to server via ajax
             var serverData = [],
                 count = requests.length;
 
             $.each(requests, function (i, request) {