2fc33abc4c89f2ca1881911666b7dbea8b6ae343
hiram
Tue Mar 24 15:05:26 2026 -0700
refactor the GC on fly calculation to move into a library function rfefs #35958
diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index ba853ae81d5..21ae16b4262 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -24197,46 +24197,38 @@
/* Display GC percent info for visible window, computed on the fly from sequence.
* No tdb or bigWig file needed - this is a synthetic track with no database table. */
{
char *winSizeStr = cartUsualString(cart, gcOnFlyWindowSize, gcOnFlyDefaultSize);
int span = atoi(winSizeStr);
char num1Buf[64], num2Buf[64];
cartWebStart(cart, database, "GC Percent On the Fly");
sprintLongWithCommas(num1Buf, BASE_1(winStart));
sprintLongWithCommas(num2Buf, winEnd);
printf("Position: %s:%s-%s
\n", seqName, num1Buf, num2Buf);
sprintLongWithCommas(num1Buf, winEnd - winStart);
printf("Total bases in view: %s
\n", num1Buf);
printf("Window size for GC calculation: %d bases
\n", span);
-struct dnaSeq *seq = hChromSeq(database, seqName, winStart, winEnd);
-if (seq != NULL)
- {
- int gcCount = 0, validBases = 0;
- int i;
- for (i = 0; i < seq->size; i++)
- {
- char b = seq->dna[i];
- if (b == 'g' || b == 'c') { gcCount++; validBases++; }
- else if (b != 'n') validBases++;
- }
- if (validBases > 0)
- printf("GC percent in view: %.3f%%
\n",
- 100.0 * gcCount / validBases);
- dnaSeqFree(&seq);
- }
+/* Use whole view as one window to get overall GC percent */
+struct gcOnTheFlyWindow *windows = NULL;
+int regionSize = winEnd - winStart;
+int windowCount = gcOnTheFlyCompute(database, seqName, winStart, winEnd,
+ regionSize, &windows);
+if (windowCount > 0)
+ printf("GC percent in view: %.3f%%
\n", windows[0].gcPct);
+freeMem(windows);
webIncludeHelpFile(GC_ON_FLY_TRACK_NAME, TRUE);
}
struct slName *cutterIsoligamers(struct cutter *myEnzyme)
/* Find enzymes with same cut site. */
{
struct sqlConnection *conn;
struct cutter *cutters = NULL;
struct slName *ret = NULL;
conn = hAllocConn("hgFixed");
char query[1024];
sqlSafef(query, sizeof query, "select * from cutters");
cutters = cutterLoadByQuery(conn, query);
ret = findIsoligamers(myEnzyme, cutters);