353a34ac7e7638457db3f55e57452069113d860b
braney
  Sun Sep 6 13:34:28 2026 -0700
Add a bigNet track type, a net of alignments in a bigBed, refs #20824

Track hubs have had no way to show a real net.  The usual stand-in is a
net rendered as a maf, which loses the level structure that makes a net
useful for establishing orthologous sequence.  bigNet holds the netAlign
columns in a bigBed, so a hub can carry the net itself.

The format is bed6+20: the target in chrom/chromStart/chromEnd, the query
sequence in name, the query strand in strand, then level and the rest of
the netAlign fields.  The trackDb line is

type bigNet <targetDb> <chainTrack>

mirroring type netAlign.  chainTrack is the plain trackDb name of the
bigChain track in the same hub; hgc adds the hub prefix itself.

chainNetLoadRangeHub() builds a chainNet from a bigBed range query and
hands it to the same helpToNet() the SQL path uses, so the nesting is
rebuilt the same way.  netDraw picks its loader off tg->isBigBed and the
drawing code below that is untouched.  genericNetClick does the same for
the details page and follows the named chain track for the alignment.

Also bounds the level walk in helpToNet() by help->maxDepth.  It could
read one past the end of the levels array.

netToBigNet converts a net file to bedToBigBed input.  It writes the tab
line itself rather than calling bigNetTabOut, because autoSql prints a
double with %g and that drops digits off a chain score.

diff --git src/hg/hgTracks/netTrack.c src/hg/hgTracks/netTrack.c
index fd1cfa1c6a5..c28d64ef9b1 100644
--- src/hg/hgTracks/netTrack.c
+++ src/hg/hgTracks/netTrack.c
@@ -1,17 +1,17 @@
 /* netTrack - stuff to handle loading and display of
- * netAlign type tracks in browser. Nets are derived
+ * netAlign and bigNet type tracks in browser. Nets are derived
  * from cross-species alignments usually. */
 
 /* Copyright (C) 2011 The Regents of the University of California 
  * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */
 
 #include "common.h"
 #include "hash.h"
 #include "linefile.h"
 #include "jksql.h"
 #include "hdb.h"
 #include "hgTracks.h"
 #include "netCart.h"
 #include "chainNetDbLoad.h"
 
 
@@ -231,31 +231,40 @@
 	if (gap->children)
 	    {
 	    rNetDraw(tg, hvg, gap->children, level+2, y + rNextLine);
 	    }
 	}
     }
 }
 
 static void netDraw(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width,
         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw routine for netAlign type tracks.  This will load
  * the items as well as drawing them. */
 {
 /* Load Net. */
-struct chainNet *net = chainNetLoadRange(database, tg->table, chromName,
+struct chainNet *net;
+if (tg->isBigBed)
+    {
+    char *fileName = hReplaceGbdb(trackDbSetting(tg->tdb, "bigDataUrl"));
+    if (fileName == NULL)
+        errAbort("No bigDataUrl in track %s", tg->track);
+    net = chainNetLoadRangeHub(fileName, chromName, seqStart, seqEnd);
+    }
+else
+    net = chainNetLoadRange(database, tg->table, chromName,
 	seqStart, seqEnd, NULL);
 
 if (net != NULL)
     {
     /* Copy parameters to statics for recursive routine. */
     rTg = tg;
     rHvg = hvg;
     rX = xOff;
 
     /* Clear cache. */
     netColorClearCache();
 
     /* Compute a few other positional things for recursive routine. */
     rHeightPer = tg->heightPer;
     rMidLineOff = rHeightPer/2;