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/inc/bigNet.h src/hg/inc/bigNet.h new file mode 100644 index 00000000000..b33f6724436 --- /dev/null +++ src/hg/inc/bigNet.h @@ -0,0 +1,91 @@ +/* bigNet.h was originally generated by the autoSql program, which also + * generated bigNet.c and bigNet.sql. This header links the database and + * the RAM representation of objects. */ + +#ifndef BIGNET_H +#define BIGNET_H + +#define BIGNET_NUM_COLS 26 + +extern char *bigNetCommaSepFieldNames; + +struct bigNet +/* bigNet - a net of pairwise alignments in bigBed format */ + { + struct bigNet *next; /* Next in singly linked list. */ + char *chrom; /* Reference sequence chromosome or scaffold */ + unsigned chromStart; /* Start position in chromosome */ + unsigned chromEnd; /* End position in chromosome */ + char *name; /* Name of the query sequence */ + unsigned score; /* Score (0-1000) */ + char strand[2]; /* + or - for strand of the query sequence */ + unsigned level; /* Depth in the net. Odd levels are fills, even levels are gaps */ + unsigned qStart; /* Start of alignment on query sequence */ + unsigned qEnd; /* End of alignment on query sequence */ + unsigned chainId; /* Id of the chain that fills this gap. 0 for a gap */ + unsigned ali; /* Bases in gap-free alignments */ + double chainScore; /* Score from the chain */ + char *type; /* Syntenic type: gap, top, syn, nonSyn or inv */ + int qOver; /* Overlap with parent gap on query side. -1 for undefined */ + int qFar; /* Distance from parent gap on query side. -1 for undefined */ + int qDup; /* Bases with two or more copies in query. -1 for undefined */ + int tN; /* Unsequenced bases on target. -1 for undefined */ + int qN; /* Unsequenced bases on query. -1 for undefined */ + int tR; /* RepeatMasker bases on target. -1 for undefined */ + int qR; /* RepeatMasker bases on query. -1 for undefined */ + int tNewR; /* Lineage specific repeat bases on target. -1 for undefined */ + int qNewR; /* Lineage specific repeat bases on query. -1 for undefined */ + int tOldR; /* Bases of ancient repeats on target. -1 for undefined */ + int qOldR; /* Bases of ancient repeats on query. -1 for undefined */ + int tTrf; /* Bases of tandem repeats on target. -1 for undefined */ + int qTrf; /* Bases of tandem repeats on query. -1 for undefined */ + }; + +void bigNetStaticLoad(char **row, struct bigNet *ret); +/* Load a row from bigNet table into ret. The contents of ret will + * be replaced at the next call to this function. */ + +struct bigNet *bigNetLoad(char **row); +/* Load a bigNet from row fetched with select * from bigNet + * from database. Dispose of this with bigNetFree(). */ + +struct bigNet *bigNetLoadAll(char *fileName); +/* Load all bigNet from whitespace-separated file. + * Dispose of this with bigNetFreeList(). */ + +struct bigNet *bigNetLoadAllByChar(char *fileName, char chopper); +/* Load all bigNet from chopper separated file. + * Dispose of this with bigNetFreeList(). */ + +#define bigNetLoadAllByTab(a) bigNetLoadAllByChar(a, '\t'); +/* Load all bigNet from tab separated file. + * Dispose of this with bigNetFreeList(). */ + +struct bigNet *bigNetCommaIn(char **pS, struct bigNet *ret); +/* Create a bigNet out of a comma separated string. + * This will fill in ret if non-null, otherwise will + * return a new bigNet */ + +void bigNetFree(struct bigNet **pEl); +/* Free a single dynamically allocated bigNet such as created + * with bigNetLoad(). */ + +void bigNetFreeList(struct bigNet **pList); +/* Free a list of dynamically allocated bigNet's */ + +void bigNetOutput(struct bigNet *el, FILE *f, char sep, char lastSep); +/* Print out bigNet. Separate fields with sep. Follow last field with lastSep. */ + +#define bigNetTabOut(el,f) bigNetOutput(el,f,'\t','\n'); +/* Print out bigNet as a line in a tab-separated file. */ + +#define bigNetCommaOut(el,f) bigNetOutput(el,f,',',','); +/* Print out bigNet as a comma separated list including final comma. */ + +/* -------------------------------- End autoSql Generated Code -------------------------------- */ + +int bigNetCmpTarget(const void *va, const void *vb); +/* Compare to sort based on target position, then by level. */ + +#endif /* BIGNET_H */ +