b74993f9080884bcc8c767693abed3f4a387ec41
braney
  Sat Mar 1 12:42:39 2025 -0800
quickLift for bigWigs

diff --git src/hg/lib/bigChain.c src/hg/lib/bigChain.c
index 407d1d62706..6665c6a4e91 100644
--- src/hg/lib/bigChain.c
+++ src/hg/lib/bigChain.c
@@ -179,15 +179,36 @@
 
 /* -------------------------------- End autoSql Generated Code -------------------------------- */
 
 
 int bigChainCmpTarget(const void *va, const void *vb)
 /* Compare to sort based on target position. */
 {
 const struct bigChain *a = *((struct bigChain **)va);
 const struct bigChain *b = *((struct bigChain **)vb);
 int dif = strcmp(a->chrom, b->chrom);
 if (dif == 0)
     dif = a->chromStart - b->chromStart;
 return dif;
 }
 
+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 */
+{
+char linkBuffer[4096];
+
+if (!endsWith(chainBigBedName, ".bb"))
+    errAbort("chain bigBed file (%s) must end in .bb", chainBigBedName);
+
+safef(linkBuffer, sizeof linkBuffer, "%s", chainBigBedName);
+
+// truncate string at ending ".bb"
+int insertOffset = strlen(linkBuffer) - sizeof ".bb" + 1;
+char *insert = &linkBuffer[insertOffset];
+*insert = 0;
+
+// add .link.bb
+strcpy(insert, ".link.bb");
+
+return cloneString(linkBuffer);
+}