11e45667d4e291b3038ccda729a1cdf5bcaf004a braney Mon Jul 11 15:46:54 2016 -0700 incorporate htslib in kent src, remove USE_BAM, USE_SAMTABIX, USE_TABIX defines, modify a bunch of makefiles to include kentSrc variable pointing to top of the tree. diff --git src/hg/lib/hgBam.c src/hg/lib/hgBam.c index 9d5ab91..de360f1 100644 --- src/hg/lib/hgBam.c +++ src/hg/lib/hgBam.c @@ -1,25 +1,24 @@ /* bamFile -- interface to binary alignment format files using Heng Li's samtools lib. */ /* Copyright (C) 2014 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "hdb.h" #include "hgBam.h" -#ifdef USE_BAM #include "htmshell.h" #include "samAlignment.h" char *bamFileNameFromTable(struct sqlConnection *conn, char *table, char *bamSeqName) /* Return file name from table. If table has a seqName column, then grab the * row associated with bamSeqName (which can be e.g. '1' not 'chr1' if that is the * case in the bam file). */ { boolean checkSeqName = (sqlFieldIndex(conn, table, "seqName") >= 0); if (checkSeqName && bamSeqName == NULL) errAbort("bamFileNameFromTable: table %s has seqName column, but NULL seqName passed in", table); char query[512]; if (checkSeqName) sqlSafef(query, sizeof(query), "select fileName from %s where seqName = '%s'", @@ -122,69 +121,57 @@ int i; for (i=0; ilm; struct samAlignment *sam; lmAllocVar(lm, sam); const bam1_core_t *core = &bam->core; struct dyString *dy = helper->dy; sam->qName = lmCloneString(lm, bam1_qname(bam)); sam->flag = core->flag; if (helper->chrom != NULL) sam->rName = helper->chrom; else -#ifdef USE_HTS sam->rName = lmCloneString(lm, header->target_name[core->tid]); -#else - sam->rName = lmCloneString(lm, helper->samFile->header->target_name[core->tid]); -#endif sam->pos = core->pos + 1; sam->mapQ = core->qual; dyStringClear(dy); bamUnpackCigar(bam, dy); sam->cigar = lmCloneStringZ(lm, dy->string, dy->stringSize); if (core->mtid >= 0) { if (core->tid == core->mtid) sam->rNext = "="; else -#ifdef USE_HTS sam->rNext = lmCloneString(lm, header->target_name[core->mtid]); -#else - sam->rNext = lmCloneString(lm, helper->samFile->header->target_name[core->mtid]); -#endif } else sam->rNext = "*"; sam->pNext = core->mpos + 1; sam->tLen = core->isize; sam->seq = lmAlloc(lm, core->l_qseq + 1); bamUnpackQuerySequence(bam, FALSE, sam->seq); char *bamQual = (char *)bam1_qual(bam); if (isAllSameChar(bamQual, core->l_qseq, -1)) sam->qual = "*"; else { sam->qual = lmCloneStringZ(lm, bamQual, core->l_qseq); addToChars(sam->qual, core->l_qseq, 33); } @@ -210,106 +197,44 @@ bamFetchPlus(fileOrUrl, posForBam, bamAddOneSamAlignment, &helper, &helper.samFile, refUrl, cacheDir); dyStringFree(&helper.dy); slReverse(&helper.samList); return helper.samList; } struct samAlignment *bamFetchSamAlignment(char *fileOrUrl, char *chrom, int start, int end, struct lm *lm) /* Fetch region as a list of samAlignments - which is more or less an unpacked * bam record. Results is allocated out of lm, since it tends to be large... */ { return bamFetchSamAlignmentPlus(fileOrUrl, chrom, start, end, lm, NULL, NULL); } -#ifdef USE_HTS struct samAlignment *bamReadNextSamAlignments(samfile_t *fh, bam_hdr_t *header, int count, struct lm *lm) -#else -struct samAlignment *bamReadNextSamAlignments(samfile_t *fh, int count, struct lm *lm) -#endif /* Read next count alignments in SAM format, allocated in lm. May return less than * count at end of file. */ { /* Set up helper. */ struct bamToSamHelper helper; helper.lm = lm; helper.chrom = NULL; helper.dy = dyStringNew(0); helper.samFile = fh; helper.samList = NULL; /* Loop through calling our own fetch function */ int i; bam1_t *b = bam_init1(); for (i=0; i