8a940dcb6fc605db13ab429c600e5160dcd4e72b
chinhli
Mon Jun 27 09:29:46 2011 -0700
redmine #4036: per data provider's request, skip printing sequence quality score in the bam file
diff --git src/hg/hgc/bamClick.c src/hg/hgc/bamClick.c
index 451dc96..e026ff1 100644
--- src/hg/hgc/bamClick.c
+++ src/hg/hgc/bamClick.c
@@ -15,31 +15,31 @@
static char const rcsid[] = "$Id: bamClick.c,v 1.21 2010/05/11 01:43:28 kent Exp $";
#include "bamFile.h"
struct bamTrackData
{
int itemStart;
char *itemName;
struct hash *pairHash;
};
/* Maybe make this an option someday -- for now, I find it too confusing to deal with
* CIGAR that is anchored to positive strand while showing rc'd sequence. I think
* to do it right, we would need to reverse the CIGAR string for display. */
static boolean useStrand = FALSE;
-
+static boolean skipQualityScore = FALSE;
static void singleBamDetails(const bam1_t *bam)
/* Print out the properties of this alignment. */
{
const bam1_core_t *core = &bam->core;
char *itemName = bam1_qname(bam);
int tLength = bamGetTargetLength(bam);
int tStart = core->pos, tEnd = tStart+tLength;
boolean isRc = useStrand && bamIsRc(bam);
printPosOnChrom(seqName, tStart, tEnd, NULL, FALSE, itemName);
printf("Alignment Quality: %d
\n", core->qual);
printf("CIGAR string: %s (", bamGetCigar(bam));
bamShowCigarEnglish(bam);
printf(")
\n");
printf("Tags:");
bamShowTags(bam);
@@ -48,41 +48,44 @@
bamShowFlagsEnglish(bam);
puts("
");
if (bamIsRc(bam))
printf("Note: although the read was mapped to the reverse strand of the genome, "
"the sequence and CIGAR in BAM are relative to the forward strand.
\n");
puts("
");
char nibName[HDB_MAX_PATH_STRING];
hNibForChrom(database, seqName, nibName);
struct dnaSeq *genoSeq = hFetchSeq(nibName, seqName, tStart, tEnd);
char *qSeq = NULL;
struct ffAli *ffa = bamToFfAli(bam, genoSeq, tStart, useStrand, &qSeq);
printf("Alignment of %s to %s:%d-%d%s:
\n", itemName,
seqName, tStart+1, tEnd, (isRc ? " (reverse complemented)" : ""));
ffShowSideBySide(stdout, ffa, qSeq, 0, genoSeq->dna, tStart, tLength, 0, tLength, 8, isRc,
FALSE);
+if (!skipQualityScore)
+ {
printf("Sequence quality scores:
\n\n");
UBYTE *quals = bamGetQueryQuals(bam, useStrand);
int i;
for (i = 0; i < core->l_qseq; i++)
{
if (i > 0 && (i % 24) == 0)
printf("
\n");
printf("%c %d | ", qSeq[i], quals[i]);
}
printf("
\n");
}
+}
static void showOverlap(const bam1_t *leftBam, const bam1_t *rightBam)
/* If the two reads overlap, show how. */
{
const bam1_core_t *leftCore = &(leftBam->core), *rightCore = &(rightBam->core);
int leftStart = leftCore->pos, rightStart = rightCore->pos;
int leftLen = bamGetTargetLength(leftBam), rightLen = bamGetTargetLength(rightBam);
char *leftSeq = bamGetQuerySequence(leftBam, useStrand);
char *rightSeq = bamGetQuerySequence(rightBam, useStrand);
if (useStrand && bamIsRc(leftBam))
reverseComplement(leftSeq, strlen(leftSeq));
if (useStrand && bamIsRc(rightBam))
reverseComplement(rightSeq, strlen(rightSeq));
if ((rightStart > leftStart && leftStart + leftLen > rightStart) ||
(leftStart > rightStart && rightStart+rightLen > leftStart))
@@ -153,30 +156,34 @@
{
bamPairDetails(firstBam, bam);
hashRemove(btd->pairHash, btd->itemName);
}
}
}
return 0;
}
void doBamDetails(struct trackDb *tdb, char *item)
/* Show details of an alignment from a BAM file. */
{
if (item == NULL)
errAbort("doBamDetails: NULL item name");
int start = cartInt(cart, "o");
+if (!tdb || !trackDbSetting(tdb, "noScoreFilter"))
+ skipQualityScore = FALSE;
+else
+ skipQualityScore = TRUE;
// TODO: libify tdb settings table_pairEndsByName, stripPrefix and pairSearchRange
#if (defined USE_BAM && defined KNETFILE_HOOKS)
knetUdcInstall();
if (udcCacheTimeout() < 300)
udcSetCacheTimeout(300);
#endif//def USE_BAM && KNETFILE_HOOKS
if (sameString(item, "zoom in"))
printf("Zoom in to a region with fewer items to enable 'detail page' links for individual items.
");
char varName[1024];
safef(varName, sizeof(varName), "%s_pairEndsByName", tdb->track);
boolean isPaired = cartUsualBoolean(cart, varName,
(trackDbSetting(tdb, "pairEndsByName") != NULL));