void readCachedSeqPart(char *seqName, int start, int size, boolean getMasked, struct hash *hash, struct dlList *fileCache, struct dnaSeq **retSeq, int *retOffset, boolean *retIsNib) /* Read sequence hopefully using file cashe. If sequence is in a nib * file just read part of it. */ { struct seqFilePos *sfp = hashMustFindVal(hash, seqName); FILE *f = openFromCache(fileCache, sfp); if (sfp->isTwoBit) { *retSeq = twoBitReadSeqFrag((struct twoBitFile *)f, seqName, start, start + size); *retOffset = start; *retIsNib = TRUE; } else if (sfp->isNib) { *retSeq = nibLdPartMasked((getMasked ? NIB_MASK_MIXED : 0), sfp->file, f, sfp->pos, start, size); *retOffset = start; *retIsNib = TRUE; } else { if (getMasked) errAbort("masked sequences not supported with fasta files"); *retSeq = readSeqFromFaPos(sfp, f); *retOffset = 0; *retIsNib = FALSE; } }
void readCachedSeqPart(char *seqName, int start, int size, struct hash *hash, struct dlList *fileCache, struct dnaSeq **retSeq, int *retOffset, boolean *retIsPartial) /* Read sequence hopefully using file cashe. If sequence is in a nib * file just read part of it. */ { struct seqFilePos *sfp = hashMustFindVal(hash, seqName); FILE *f = openFromCache(fileCache, sfp->file); if (sfp->isNib) { *retSeq = nibLdPartMasked(NIB_MASK_MIXED, sfp->file, f, sfp->pos, start, size); *retOffset = start; *retIsPartial = TRUE; } else if (sfp->isTwoBit) { *retSeq = twoBitReadSeqFrag(sfp->tbf, seqName, start, start+size); *retOffset = start; *retIsPartial = TRUE; } else { *retSeq = readSeqFromFaPos(sfp, f); *retOffset = 0; *retIsPartial = FALSE; } }
struct dnaSeq *nibTwoCacheSeqPartExt(struct nibTwoCache *ntc, char *seqName, int start, int size, boolean doMask, int *retFullSeqSize) /* Return part of sequence. If *retFullSeqSize is non-null then return full * size of sequence (not just loaded part) there. Sequence will be lower * case if doMask is false, mixed case (repeats in lower) * if doMask is true. */ { if (ntc->isTwoBit) { return twoBitReadSeqFragExt(ntc->tbf, seqName, start, start+size, doMask, retFullSeqSize); } else { struct nibInfo *nib = nibInfoFromCache(ntc->nibHash, ntc->pathName, seqName); int opts = (doMask ? NIB_MASK_MIXED : 0); if (retFullSeqSize != NULL) *retFullSeqSize = nib->size; return nibLdPartMasked(opts, nib->fileName, nib->f, nib->size, start, size); } }
struct dnaSeq *readFromCache(struct dlList *cache, char *dirName, char *seqName, int start, int size, int seqSize, boolean isTwoBit) /* Return dnaSeq read from the appropriate nib file. * You need to dnaSeqFree this when done (it is the nib * file that is cached, not the sequence). */ { struct cachedSeqFile *cn = openFromCache(cache, dirName, seqName, isTwoBit); if (isTwoBit) { return twoBitReadSeqFrag(cn->tbf, seqName, start, start+size); } else { if (seqSize != cn->size) errAbort("%s/%s is %d bases in .lav file and %d in .nib file\n", dirName, seqName, seqSize, cn->size); if ((start+size) > cn->size ) printf("%s/%s is %d bases in .lav file and %d in .nib file start %d size %d end %d\n", dirName, seqName, seqSize, cn->size, start, size, start+size); return nibLdPartMasked(NIB_MASK_MIXED, cn->fileName, cn->f, cn->size, start, size); } }
struct dnaSeq *nibInfoLoadSeq(struct nibInfo *nib, int start, int size) /* Load in a sequence in mixed case from nib file. */ { return nibLdPartMasked(NIB_MASK_MIXED, nib->fileName, nib->f, nib->size, start, size); }