static void cnvGenePred(struct hash *chromHash, struct genePred *gp, FILE *pslFh, FILE *cdsFh) /* convert a genePred to a psl and CDS */ { int chromSize = hashIntValDefault(chromHash, gp->chrom, 0); if (chromSize == 0) errAbort("Couldn't find chromosome/scaffold '%s' in chromInfo", gp->chrom); int e = 0, qSize=0; for (e = 0; e < gp->exonCount; ++e) qSize+=(gp->exonEnds[e] - gp->exonStarts[e]); struct psl *psl = pslNew(gp->name, qSize, 0, qSize, gp->chrom, chromSize, gp->txStart, gp->txEnd, gp->strand, gp->exonCount, 0); psl->blockCount = gp->exonCount; for (e = 0; e < gp->exonCount; ++e) { psl->blockSizes[e] = (gp->exonEnds[e] - gp->exonStarts[e]); psl->qStarts[e] = e==0 ? 0 : psl->qStarts[e-1] + psl->blockSizes[e-1]; psl->tStarts[e] = gp->exonStarts[e]; } psl->match = qSize; psl->tNumInsert = psl->blockCount-1; psl->tBaseInsert = (gp->txEnd - gp->txStart) - qSize; pslTabOut(psl, pslFh); pslFree(&psl); if (gp->cdsStart < gp->cdsEnd) cnvGenePredCds(gp, qSize, cdsFh); }
static struct mapAln *chainToPsl(struct chain *ch) /* convert a chain to a psl, ignoring match counts, etc */ { struct psl *psl; struct cBlock *cBlk; int iBlk; int qStart = ch->qStart, qEnd = ch->qEnd; char strand[2]; strand[0] = ch->qStrand; strand[1] = '\0'; if (ch->qStrand == '-') reverseIntRange(&qStart, &qEnd, ch->qSize); psl = pslNew(ch->qName, ch->qSize, qStart, qEnd, ch->tName, ch->tSize, ch->tStart, ch->tEnd, strand, slCount(ch->blockList), 0); for (cBlk = ch->blockList, iBlk = 0; cBlk != NULL; cBlk = cBlk->next, iBlk++) { psl->blockSizes[iBlk] = (cBlk->tEnd - cBlk->tStart); psl->qStarts[iBlk] = cBlk->qStart; psl->tStarts[iBlk] = cBlk->tStart; psl->match += psl->blockSizes[iBlk]; } psl->blockCount = iBlk; if (swapMap) pslSwap(psl, FALSE); return mapAlnNew(psl, ch->id); }
static struct psl *bedToPsl(struct bed *bed, struct hash *chromSizes) /* Convert a single bed to a PSL. */ { int qSize = bedTotalBlockSize(bed); struct psl *psl; if (keepQuery) psl = pslNew(bed->chrom, hashIntVal(chromSizes, bed->chrom), bed->chromStart, bed->chromEnd, bed->chrom, hashIntVal(chromSizes, bed->chrom), bed->chromStart, bed->chromEnd, ((bed->strand[0] == '\0') ? "+" : bed->strand), (bed->blockCount == 0) ? 1 : bed->blockCount, 0); else psl = pslNew(bed->name, qSize, 0, qSize, bed->chrom, hashIntVal(chromSizes, bed->chrom), bed->chromStart, bed->chromEnd, ((bed->strand[0] == '\0') ? "+" : bed->strand), (bed->blockCount == 0) ? 1 : bed->blockCount, 0); psl->match = psl->qSize; if (bed->blockCount == 0) bedToPsl4(bed, psl); else bedToPsl12(bed, psl); return psl; }
static struct psl* createMappedPsl(struct psl* inPsl, struct psl *mapPsl, int mappedPslMax) /* setup a PSL for the output alignment */ { char strand[3]; assert(pslTStrand(inPsl) == pslQStrand(mapPsl)); /* strand can be taken from both alignments, since common sequence is in same * orientation. */ strand[0] = pslQStrand(inPsl); strand[1] = pslTStrand(mapPsl); strand[2] = '\n'; return pslNew(inPsl->qName, inPsl->qSize, 0, 0, mapPsl->tName, mapPsl->tSize, 0, 0, strand, mappedPslMax, 0); }
struct psl *pslBuildFromHsp(char *qName, int qSize, int qStart, int qEnd, char qStrand, char *qAln, char *tName, int tSize, int tStart, int tEnd, char tStrand, char *tAln, unsigned flags) /* construct a new psl from an HSP. Chaining is left to other programs. */ { if ((flags & tblastx) && (flags & bldPslx)) errAbort("can't convert TBLASTX to PSLX"); struct block blk; blkInit(&blk, qStart, qAln, tStart, tAln, flags); // construct psl int pslSpace = 8; char strand[3]; safef(strand, sizeof(strand), "%c%c", qStrand, tStrand); struct psl *psl = pslNew(qName, blk.qCoordMult * qSize, blk.qCoordMult * qStart, blk.qCoordMult * qEnd, tName, blk.tCoordMult * tSize, blk.tCoordMult * tStart, blk.tCoordMult * tEnd, strand, pslSpace, ((flags & bldPslx) ? PSL_XA_FORMAT : 0)); // fill in psl hspToBlocks(psl, &pslSpace, &blk, flags); finishPsl(psl, flags); return psl; }