54406b80d5d435970989acff7b22dd6146c6b411 braney Sat Jan 22 15:24:59 2022 -0800 adding chrom alias support to big files diff --git src/hg/lib/chainNetDbLoad.c src/hg/lib/chainNetDbLoad.c index bf24efe..41c21bc 100644 --- src/hg/lib/chainNetDbLoad.c +++ src/hg/lib/chainNetDbLoad.c @@ -4,30 +4,31 @@ /* Copyright (C) 2014 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 "chain.h" #include "chainDb.h" #include "chainLink.h" #include "chainNet.h" #include "netAlign.h" #include "chainNetDbLoad.h" +#include "chromAlias.h" struct cnFill *cnFillFromNetAlign(struct netAlign *na, struct hash *nameHash) /* Convert netAlign to cnFill. Name hash is a place to store * the strings. */ { struct cnFill *fill; AllocVar(fill); fill->tStart = na->tStart; fill->tSize = na->tEnd - na->tStart; fill->qName = hashStoreName(nameHash, na->qName); fill->qStrand = na->strand[0]; fill->qStart = na->qStart; fill->qSize = na->qEnd - na->qStart; fill->chainId = na->chainId; @@ -214,31 +215,31 @@ b->qStart = link.qStart; b->qEnd = link.qStart + (link.tEnd - link.tStart); slAddHead(&list, b); } slSort(&list, cBlockCmpTarget); chain->blockList = list; } struct chain *chainLoadIdRangeHub(char *fileName, char *linkFileName, char *chrom, int start, int end, int id) /* Load parts of chain of given ID from bigChain file. Note the chain header * including score, tStart, tEnd, will still reflect the whole chain, * not just the part in range. However only the blocks of the chain * overlapping the range will be loaded. */ { struct lm *lm = lmInit(0); -struct bbiFile *bbi = bigBedFileOpen(fileName); +struct bbiFile *bbi = bigBedFileOpenAlias(fileName, chromAliasGetHash(NULL)); struct bigBedInterval *bb, *bbList = bigBedIntervalQuery(bbi, chrom, start, end, 0, lm); char *bedRow[12]; char startBuf[16], endBuf[16]; bbiFileClose(&bbi); boolean loadAll = FALSE; struct chain *chain; AllocVar(chain); for (bb = bbList; bb != NULL; bb = bb->next) { bigBedIntervalToRow(bb, chrom, startBuf, endBuf, bedRow, ArraySize(bedRow)); unsigned chainId = sqlUnsigned(bedRow[3]); if (chainId == id) @@ -249,31 +250,31 @@ errAbort("chain %d is not in %s", id, fileName); chain->tName = cloneString(chrom); chain->tSize = sqlUnsigned(bedRow[6]); chain->tStart = sqlUnsigned(bedRow[1]); chain->tEnd = sqlUnsigned(bedRow[2]); chain->qName = cloneString(bedRow[7]); chain->qSize = sqlUnsigned(bedRow[8]); chain->qStrand = *bedRow[5]; chain->qStart = sqlUnsigned(bedRow[9]); chain->qEnd = sqlUnsigned(bedRow[10]); chain->score = sqlUnsigned(bedRow[11]); chain->id = id; // Now load the links. -bbi = bigBedFileOpen(linkFileName); +bbi = bigBedFileOpenAlias(linkFileName, chromAliasGetHash(NULL)); if (loadAll) { start = chain->tStart; end = chain->tEnd; } bbList = bigBedIntervalQuery(bbi, chrom, start, end, 0, lm); bbiFileClose(&bbi); for (bb = bbList; bb != NULL; bb = bb->next) { bigBedIntervalToRow(bb, chrom, startBuf, endBuf, bedRow, ArraySize(bedRow)); unsigned chainId = sqlUnsigned(bedRow[3]); if (chainId == id) { struct cBlock *cBlock;