df6cf391270cbbfe12f9ec3869948c2813002a87 braney Thu May 23 13:47:45 2024 -0700 add support for baseView track type diff --git src/hg/utils/buildPairAssembly/buildPairAssembly.c src/hg/utils/buildPairAssembly/buildPairAssembly.c index 7b42bce..bd71c3f 100644 --- src/hg/utils/buildPairAssembly/buildPairAssembly.c +++ src/hg/utils/buildPairAssembly/buildPairAssembly.c @@ -71,31 +71,31 @@ } void buildPairAssembly(char *inputChain, char *tSequenceName, char *t2bitName, char *qSequenceName, char *q2bitName, char *outFaName, char *outQueryPsl, char *outTargetPsl, char *outMapBed, char *outDupBed, char *outMissBed, char *outBaseTargetBed, char *outBaseQueryBed) /* buildPairAssembly - From a single coverage chain build a pairwise assembly including all sequence from both query and target. */ { struct lineFile *lf = lineFileOpen(inputChain, TRUE); struct chain *chain; struct cBlock *blockList = NULL, *cBlock, *nextBlock; struct twoBitFile *q2bit = twoBitOpen(q2bitName); struct twoBitFile *t2bit = twoBitOpen(t2bitName); FILE *outFa = mustOpen(outFaName, "w"); FILE *outMap = mustOpen(outMapBed, "w"); FILE *outDup = mustOpen(outDupBed, "w"); FILE *outMiss = mustOpen(outMissBed, "w"); FILE *outBaseTarget = mustOpen(outBaseTargetBed, "w"); -//FILE *outBaseQuery = mustOpen(outBaseQueryBed, "w"); +FILE *outBaseQuery = mustOpen(outBaseQueryBed, "w"); fprintf(outFa, ">buildPair\n"); while ((chain = chainRead(lf)) != NULL) { if (!sameString(tSequenceName, chain->tName) || !sameString(qSequenceName, chain->qName)) continue; for (cBlock = chain->blockList; cBlock; cBlock = nextBlock) { nextBlock = cBlock->next; if (chain->qStrand == '-') { unsigned qStart = cBlock->qStart; cBlock->qStart = chain->qSize - cBlock->qEnd; @@ -358,30 +358,62 @@ } //else if (linearBlock->tStart != linearBlock->tEnd) { if (startT == 0) { startAddress = currentAddress; startT = linearBlock->tStart; } endT = linearBlock->tEnd; } //totalSize += size; currentAddress += size; } +startAddress = 0; +currentAddress = 0; +totalSize = 0; +startT = 0; +endT = 0; +for(linearBlock = linearBlockList; linearBlock; linearBlock = linearBlock->next) + { + if (linearBlock->tStart == linearBlock->tEnd) + size = linearBlock->qEnd - linearBlock->qStart; + else + size = linearBlock->tEnd - linearBlock->tStart; + + if ((linearBlock->qStart == linearBlock->qEnd) || ((endT != 0) && (endT != linearBlock->qStart))) + { + if (startT != 0) + fprintf(outBaseQuery, "buildPair %d %d %d %d\n",startAddress, currentAddress, startT, endT); + startT = endT = totalSize = 0; + } + //else + if (linearBlock->qStart != linearBlock->qEnd) + { + if (startT == 0) + { + startAddress = currentAddress; + startT = linearBlock->qStart; + } + endT = linearBlock->qEnd; + } +//totalSize += size; + currentAddress += size; + } + // validate slSort(&linearBlockList, lbCmpTarget); firstBlock = TRUE; for(linearBlock = linearBlockList; linearBlock; linearBlock = linearBlock->next) { if (linearBlock->tStart == linearBlock->tEnd) continue; if (!firstBlock) { if (linearBlock->tStart != startAddress) errAbort("tStart %d %d", startAddress, linearBlock->tStart); } else firstBlock = FALSE;