src/hg/hgTracks/hgTracks.c 1.1648
1.1648 2010/05/18 19:01:16 kent
Adding parent field to struct track, and filling it in for composite and container subtracks. For supertracks, the existing parent finding at the track (as opposed to trackDb) level is buried enough this is difficult, so putting this off until the mythical day when supertracks are refactored out. Making mrna searches open mrna track in hg19, and in general improving search auto-opening when track and table name are different.
Index: src/hg/hgTracks/hgTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/hgTracks.c,v
retrieving revision 1.1647
retrieving revision 1.1648
diff -b -B -U 4 -r1.1647 -r1.1648
--- src/hg/hgTracks/hgTracks.c 11 May 2010 01:43:27 -0000 1.1647
+++ src/hg/hgTracks/hgTracks.c 18 May 2010 19:01:16 -0000 1.1648
@@ -3952,8 +3952,41 @@
track->visibility = tvHide;
}
}
+struct track *rFindTrackWithTable(char *tableName, struct track *trackList)
+/* Recursively search through track list looking for first one that matches table. */
+{
+struct track *track;
+for (track = trackList; track != NULL; track = track->next)
+ {
+ if (sameString(tableName, track->table))
+ return track;
+ struct track *subTrack = rFindTrackWithTable(tableName, track->subtracks);
+ if (subTrack != NULL)
+ return subTrack;
+ }
+return NULL;
+}
+
+static void setSearchedTrackToPackOrFull(struct track *trackList)
+/* Open track associated with search position if any. Also open its parents
+ * if any. At the moment parents include composites but not supertracks. */
+{
+if (NULL != hgp && NULL != hgp->tableList && NULL != hgp->tableList->name)
+ {
+ char *tableName = hgp->tableList->name;
+ struct track *matchTrack = rFindTrackWithTable(tableName, trackList);
+ if (matchTrack != NULL)
+ {
+ struct track *track;
+ for (track = matchTrack; track != NULL; track = track->parent)
+ cartSetString(cart, track->track, hCarefulTrackOpenVis(database, track->track));
+ }
+ }
+}
+
+
struct track *getTrackList( struct group **pGroupList, int vis)
/* Return list of all tracks, organizing by groups.
* If vis is -1, restore default groups to tracks.
* Shared by hgTracks and configure page. */
@@ -3974,9 +4007,9 @@
if (wikiTrackEnabled(database, NULL))
addWikiTrack(&trackList);
loadCustomTracks(&trackList);
groupTracks(&trackList, pGroupList, vis);
-
+setSearchedTrackToPackOrFull(trackList);
if (cgiOptionalString( "hideTracks"))
changeTrackVis(groupList, NULL, tvHide);
/* Get visibility values if any from ui. */
@@ -5104,19 +5137,8 @@
cartSetString(cart, "position", position);
}
}
-if (NULL != hgp && NULL != hgp->tableList && NULL != hgp->tableList->name)
- {
- char *trackName = hgp->tableList->name;
- char *parent = hGetParent(database, trackName); // This only works for a composite track (not superTrack)
- if (parent) // TODO: Therefore I wonder about the need for this code.
- trackName = cloneString(parent);
- char *vis = cartOptionalString(cart, trackName);
- if (vis == NULL || differentString(vis, "full"))
- cartSetString(cart, trackName, hTrackOpenVis(database, trackName));
- }
-
/* After position is found set up hash of matches that should
be drawn with names highlighted for easy identification. */
createHgFindMatchHash();