void pslRecalcMatch(char *inName, char *targetName, char *queryName, char *outName) /* pslRecalcMatch - Recalculate match,mismatch,repMatch columns in psl file. * This can be useful if the psl went through pslMap, or if you've added * lower-case repeat masking after the fact. */ { struct nibTwoCache *tCache = nibTwoCacheNew(targetName); struct dnaSeq *qSeqList = dnaLoadAll(queryName); struct hash *qHash = dnaSeqHash(qSeqList); struct psl *psl; struct lineFile *lf = pslFileOpen(inName); FILE *f = mustOpen(outName, "w"); while ((psl = pslNext(lf)) != NULL) { int tSize; struct dnaSeq *tSeqPart = nibTwoCacheSeqPart(tCache, psl->tName, psl->tStart, psl->tEnd - psl->tStart, &tSize); struct dnaSeq *qSeq = hashMustFindVal(qHash, getQName(psl->qName)); recalcMatches(psl, tSeqPart, psl->tStart, qSeq); pslTabOut(psl, f); dnaSeqFree(&tSeqPart); } carefulClose(&f); lineFileClose(&lf); }
void txgAnalyze(char *inTxg, char *dnaPath, char *outFile) /* txgAnalyze - Analyse transcription graph for alt exons, alt 3', alt 5', * retained introns, alternative promoters, etc.. */ { struct lineFile *lf = lineFileOpen(inTxg, TRUE); FILE *f = mustOpen(outFile, "w"); char *row[TXGRAPH_NUM_COLS]; struct nibTwoCache *ntc = nibTwoCacheNew(dnaPath); struct dnaSeq *chrom = NULL; while (lineFileRow(lf, row)) { struct txGraph *txg = txGraphLoad(row); if (chrom == NULL || !sameString(chrom->name, txg->tName)) { dnaSeqFree(&chrom); chrom = nibTwoCacheSeq(ntc, txg->tName); verbose(2, "Loaded %s into %s\n", txg->tName, chrom->name); } struct range *exonsWithIntrons = retainedIntrons(txg, f); cassetteExons(txg, f); altThreePrime(txg, exonsWithIntrons, f); altFivePrime(txg, exonsWithIntrons, f); altPromoter(txg, f); strangeSplices(txg, chrom, f); bleedsIntoIntrons(txg, f); refSeparateButJoined(txg, f); if (fConst != NULL) constExons(txg, fConst); slFreeList(&exonsWithIntrons); txGraphFree(&txg); } carefulClose(&f); }
void netToAxt(char *netName, char *chainName, char *tNibDir, char *qNibDir, char *axtName) /* netToAxt - Convert net (and chain) to axt.. */ { Bits *usedBits = findUsedIds(netName); struct hash *chainHash; struct chainNet *net; struct lineFile *lf = lineFileOpen(netName, TRUE); FILE *f = mustOpen(axtName, "w"); struct dnaSeq *tChrom = NULL; struct nibTwoCache *qNtc = nibTwoCacheNew(qNibDir); char *gapFileName = optionVal("gapOut", NULL); FILE *gapFile = NULL; if (gapFileName) gapFile = mustOpen(gapFileName, "w"); lineFileSetMetaDataOutput(lf, f); chainHash = chainReadUsedSwap(chainName, qChain, usedBits); bitFree(&usedBits); while ((net = chainNetRead(lf)) != NULL) { verbose(1, "Processing %s\n", net->name); tChrom = nibTwoLoadOne(tNibDir, net->name); if (tChrom->size != net->size) errAbort("Size mismatch on %s. Net/nib out of sync or possibly nib dirs swapped?", tChrom->name); rConvert(net->fillList, tChrom, qNtc, qNibDir, chainHash, f, gapFile); freeDnaSeq(&tChrom); chainNetFree(&net); } nibTwoCacheFree(&qNtc); }
void doIt(char *inName, char *tNibDirOr2bit, char *qNibDirOr2bit, char *outName) /* chainToAxt - Convert from chain to axt file. */ { struct lineFile *lf = lineFileOpen(inName, TRUE); struct nibTwoCache *tSeqCache = nibTwoCacheNew(tNibDirOr2bit); struct nibTwoCache *qSeqCache = nibTwoCacheNew(qNibDirOr2bit); struct chain *chain = NULL; FILE *f = mustOpen(outName, "w"); while ((chain = chainRead(lf)) != NULL) { if (chain->score >= minScore) doAChain(chain, tSeqCache, qSeqCache, f); chainFree(&chain); } lineFileClose(&lf); carefulClose(&f); }
static struct seqReader *seqReaderNew(char *seqSpec) /* construct a new seqReader object */ { struct seqReader *seqReader; AllocVar(seqReader); seqReader->spec = cloneString(seqSpec); if (endsWith(seqSpec, ".fa") || endsWith(seqSpec, ".fa.gz") || endsWith(seqSpec, ".fa.Z") || endsWith(seqSpec, ".fa.bz2")) seqReaderLoadFasta(seqReader); else seqReader->nibTwo = nibTwoCacheNew(seqSpec); return seqReader; }