72327e4e2d294b9d2fcb6cbdadd4e628c006345b
braney
  Fri Sep 18 10:07:40 2026 -0700
bigChain: move the chain to bigChain conversion into the library

chainRecToBigChain() and chainBlockToBigLink() sat in chainToBigChain.c
next to its main(), so a CGI could not link against them.  Move both into
hg/lib/bigChain.c, add chainToBigChainOne() for one chain and
chainToBigChainList() for a list, and leave the utility as a thin main().
No behavior change; the chainToBigChain test output is unchanged.

refs #38382

diff --git src/hg/inc/bigChain.h src/hg/inc/bigChain.h
index 53d081507ed..84a03ebe437 100644
--- src/hg/inc/bigChain.h
+++ src/hg/inc/bigChain.h
@@ -1,81 +1,99 @@
 /* bigChain.h was originally generated by the autoSql program, which also 
  * generated bigChain.c and bigChain.sql.  This header links the database and
  * the RAM representation of objects. */
 
 #ifndef BIGCHAIN_H
 #define BIGCHAIN_H
 
 #define BIGCHAIN_NUM_COLS 12
 
 extern char *bigChainCommaSepFieldNames;
 
 struct bigChain
 /* bigChain pairwise alignment */
     {
     struct bigChain *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 or ID of item, ideally both human readable and unique */
     unsigned score;	/* Score (0-1000) */
     char strand[2];	/* + or - for strand */
     unsigned tSize;	/* size of target sequence */
     char *qName;	/* name of query sequence */
     unsigned qSize;	/* size of query sequence */
     unsigned qStart;	/* start of alignment on query sequence */
     unsigned qEnd;	/* end of alignment on query sequence */
     double chainScore;	/* score from chain */
     };
 
 void bigChainStaticLoad(char **row, struct bigChain *ret);
 /* Load a row from bigChain table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 
 struct bigChain *bigChainLoad(char **row);
 /* Load a bigChain from row fetched with select * from bigChain
  * from database.  Dispose of this with bigChainFree(). */
 
 struct bigChain *bigChainLoadAll(char *fileName);
 /* Load all bigChain from whitespace-separated file.
  * Dispose of this with bigChainFreeList(). */
 
 struct bigChain *bigChainLoadAllByChar(char *fileName, char chopper);
 /* Load all bigChain from chopper separated file.
  * Dispose of this with bigChainFreeList(). */
 
 #define bigChainLoadAllByTab(a) bigChainLoadAllByChar(a, '\t');
 /* Load all bigChain from tab separated file.
  * Dispose of this with bigChainFreeList(). */
 
 struct bigChain *bigChainCommaIn(char **pS, struct bigChain *ret);
 /* Create a bigChain out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new bigChain */
 
 void bigChainFree(struct bigChain **pEl);
 /* Free a single dynamically allocated bigChain such as created
  * with bigChainLoad(). */
 
 void bigChainFreeList(struct bigChain **pList);
 /* Free a list of dynamically allocated bigChain's */
 
 void bigChainOutput(struct bigChain *el, FILE *f, char sep, char lastSep);
 /* Print out bigChain.  Separate fields with sep. Follow last field with lastSep. */
 
 #define bigChainTabOut(el,f) bigChainOutput(el,f,'\t','\n');
 /* Print out bigChain as a line in a tab-separated file. */
 
 #define bigChainCommaOut(el,f) bigChainOutput(el,f,',',',');
 /* Print out bigChain as a comma separated list including final comma. */
 
 /* -------------------------------- End autoSql Generated Code -------------------------------- */
 
 int bigChainCmpTarget(const void *va, const void *vb);
 /* Compare to sort based on target position. */
 
 char *bigChainGetLinkFile(char *chainBigBedName);
 /* Construct the file name of the chain link file from the name of a chain file. 
  * That is, change file.bb to file.link.bb */
 
+struct chain;
+struct cBlock;
+struct bigLink;
+
+struct bigChain *chainRecToBigChain(struct chain *chain);
+/* make a bigChain from a chain */
+
+struct bigLink *chainBlockToBigLink(struct chain *chain, struct cBlock *cblk);
+/* make a chain link from a chain block */
+
+void chainToBigChainOne(struct chain *chain, struct bigChain **bigChains, struct bigLink **bigLinks);
+/* convert one chain to a bigChain and a bigLink per block, adding them to the
+ * heads of the given lists */
+
+void chainToBigChainList(struct chain *chains, struct bigChain **bigChains, struct bigLink **bigLinks);
+/* convert a list of chains to bigChains and bigLinks, sorted by target position.
+ * The new records are added to whatever is already on the given lists */
+
 #endif /* BIGCHAIN_H */