2028f58f234220d59b228639ff4e4ead0d83d2c0
aamp
  Tue May 17 15:03:28 2011 -0700
Stuff to do with microarray subsetting.  It might need a little smoothing over
diff --git src/hg/hgTracks/expRatioTracks.c src/hg/hgTracks/expRatioTracks.c
index e179cda..798420a 100644
--- src/hg/hgTracks/expRatioTracks.c
+++ src/hg/hgTracks/expRatioTracks.c
@@ -506,43 +506,44 @@
     {
     tg->items = msBedGroupByIndex(bedList, "hgFixed", tg->expTable, affyId, NULL, -1);
     }
 else if(affyType == affyChipType)
     {
     tg->items = msBedGroupByIndex(bedList, "hgFixed", tg->expTable, affyChipType, NULL, -1);
     }
 else
     {
     tg->items = msBedGroupByIndex(bedList, "hgFixed", tg->expTable, affyAllData, affyMap, 1);
     slSort(&tg->items,lfsSortByName);
     }
 bedFreeList(&bedList);
 }
 
-static void lfsFromBedAndGrouping(struct track *tg, struct maGrouping *combineGroup)
+static void lfsFromBedAndGrouping(struct track *tg, struct maGrouping *combineGroup, struct maGrouping *subset, int subsetOffset)
 /* This is sort of a replacement of msBedGroupByIndex. */
 /* It's meant to be the default microarray track filter */
 /* for tracks using the new microarrayGroups.ra scheme. */
 {
 struct linkedFeaturesSeries *lfsList = NULL;
 struct bed *bedList = tg->items;
 int i;
-int numRows = combineGroup->numGroups;
+int numRows;
 char newLongLabel[512];
 if (bedList && (bedList->expCount != combineGroup->size))
     errAbort("Error: %s grouping has bad size (%d).  Expected %d", combineGroup->name, combineGroup->size, bedList->expCount);
-maBedClumpGivenGrouping(bedList, combineGroup);
+maBedClumpGivenGrouping(bedList, combineGroup, subset, subsetOffset);
+numRows = combineGroup->numGroups;
 /* Initialize the lfs array first. */
 for (i = 0; i < numRows; i++)
     {
     struct linkedFeaturesSeries *lfs;
     struct bed *bed;
     char customName[16];
     safef(customName, sizeof(customName), "Array %d", i+1);
     AllocVar(lfs);
     if (combineGroup == NULL)
 	lfs->name = cloneString(customName);
     else
 	lfs->name = cloneString(combineGroup->names[i]);
     for (bed = bedList; bed != NULL; bed = bed->next)
 	{
 	struct linkedFeatures *lf = lfFromBed(bed);
@@ -555,38 +556,42 @@
 slReverse(&lfsList);
 tg->items = lfsList;
 /* Change the longLabel */
 if (!sameString(combineGroup->description, "Custom Track"))
     {
     safef(newLongLabel, sizeof(newLongLabel), "%s - %s", tg->longLabel, combineGroup->description);
     tg->longLabel = cloneString(newLongLabel);
     }
 }
 
 void lfsFromExpRatio(struct track *tg)
 /* Make the lfs out of the track by calling lfsFromBedAndGrouping */
 {
 struct customTrack *ct = tg->customPt;
 struct maGrouping *grouping = NULL;
+struct maGrouping *subset = NULL;
+int subsetOffset = -1;
 if (ct != NULL)
     grouping = maGetGroupingFromCt(ct);
 else
     {
     struct microarrayGroups *groups = maGetTrackGroupings(database, tg->tdb);
     grouping = maCombineGroupingFromCart(groups, cart, tg->track);
+    subset = maSubsetGroupingFromCart(groups, cart, tg->track);
+    subsetOffset = maSubsetOffsetFromCart(subset, cart, tg->track);
     }
-lfsFromBedAndGrouping(tg, grouping);
+lfsFromBedAndGrouping(tg, grouping, subset, subsetOffset);
 }
 
 void lfsFromAffyUclaNormBed(struct track *tg)
 /* filters the bedList stored at tg->items
 into a linkedFeaturesSeries as determined by
 filter type */
 {
 struct linkedFeaturesSeries *lfsList = NULL, *lfs = NULL, *lfsNew = NULL;
 struct linkedFeatures *lf = NULL, *lfNext = NULL;
 struct bed *bedList= NULL;
 enum trackVisibility vis = tg->visibility;
 bedList = tg->items;
 
 if(tg->limitedVis == tvDense || tg->limitedVis == tvPack || tg->limitedVis == tvSquish)
     {