e63eaf218669b968f124b81ca45ea0c287943f75 braney Fri Mar 11 16:26:26 2022 -0800 use bpt index if available for 2bit assembly hubs diff --git src/index/bptForTwoBit/bptForTwoBit.c src/index/bptForTwoBit/bptForTwoBit.c index f353bcf..86ae60f 100644 --- src/index/bptForTwoBit/bptForTwoBit.c +++ src/index/bptForTwoBit/bptForTwoBit.c @@ -52,30 +52,33 @@ } void bptForTwoBit(char *twoBitIn, char *indexOut) /* bptForTwoBit - Create a b+ tree index for a .2bit file. Key is the sequence name. * Value is the position of the start of the compressed DNA in the .2bit file. */ { /* Read two bit file, and convert linked list index to array. */ struct twoBitFile *tbf = twoBitOpen(twoBitIn); struct twoBitIndex *tbi, **tbiArray; int elCount = tbf->hash->elCount; AllocArray(tbiArray, elCount); int i; for (i=0, tbi=tbf->indexList; i < elCount; ++i, tbi=tbi->next) tbiArray[i] = tbi; +// array MUST be sorted +qsort(tbiArray, elCount, sizeof(tbiArray[0]), twoBitIndexCmp); + /* Calculate longest name. */ int maxSize = 0; for (tbi = tbf->indexList; tbi != NULL; tbi = tbi->next) { int size = strlen(tbi->name); if (maxSize < size) maxSize = size; } /* Create index. */ bptFileCreate(tbiArray, sizeof(tbiArray[0]), elCount, blockSize, twoBitIndexKey, maxSize, twoBitIndexVal, sizeof(tbi->offset), indexOut); verbose(1, "Created index of %d sequences in %s\n", elCount, indexOut); }