src/hg/lib/bamFile.c 1.3

1.3 2009/08/03 22:14:39 angie
Oops, silly flag-testing bug (& comment clarification) in bamGetQuerySequence.
Index: src/hg/lib/bamFile.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/bamFile.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -B -U 4 -r1.2 -r1.3
--- src/hg/lib/bamFile.c	3 Aug 2009 22:00:24 -0000	1.2
+++ src/hg/lib/bamFile.c	3 Aug 2009 22:14:39 -0000	1.3
@@ -49,17 +49,19 @@
 samclose(fh);
 }
 
 char *bamGetQuerySequence(const bam1_t *bam)
-/* Return the nucleotide sequence encoded in bam. */
+/* Return the nucleotide sequence encoded in bam.  The BAM format 
+ * reverse-complements query sequence when the alignment is on the - strand,
+ * so here we rev-comp it back to restore the original query sequence. */
 {
 const bam1_core_t *core = &bam->core;
 char *qSeq = needMem(core->l_qseq + 1);
 uint8_t *s = bam1_seq(bam);
 int i;
 for (i = 0; i < core->l_qseq; i++)
     qSeq[i] = bam_nt16_rev_table[bam1_seqi(s, i)];
-if ((core->flag & BAM_FREVERSE) == 1)
+if ((core->flag & BAM_FREVERSE))
     reverseComplement(qSeq, core->l_qseq);
 return qSeq;
 }