src/hg/hgc/bamClick.c 1.14

1.14 2010/01/11 18:34:25 angie
Added read name (wasn't obvious!). Added overall position & size for paired reads.
Index: src/hg/hgc/bamClick.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgc/bamClick.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -b -B -U 4 -r1.13 -r1.14
--- src/hg/hgc/bamClick.c	10 Dec 2009 15:02:12 -0000	1.13
+++ src/hg/hgc/bamClick.c	11 Jan 2010 18:34:25 -0000	1.14
@@ -94,8 +94,19 @@
 
 static void bamPairDetails(const bam1_t *leftBam, const bam1_t *rightBam)
 /* Print out details for paired-end reads. */
 {
+if (leftBam && rightBam)
+    {
+    const bam1_core_t *leftCore = &leftBam->core, *rightCore = &rightBam->core;
+    int leftLength = bamGetTargetLength(leftBam), rightLength = bamGetTargetLength(rightBam);
+    int start = min(leftCore->pos, rightCore->pos);
+    int end = max(leftCore->pos+leftLength, rightCore->pos+rightLength);
+    char *itemName = bam1_qname(leftBam);
+    printf("<B>Paired read name:</B> %s<BR>\n", itemName);
+    printPosOnChrom(seqName, start, end, NULL, FALSE, itemName);
+    puts("<P>");
+    }
 showOverlap(leftBam, rightBam);
 printf("<TABLE><TR><TD><H4>Left end read</H4>\n");
 singleBamDetails(leftBam);
 printf("</TD><TD><H4>Right end read</H4>\n");
@@ -114,10 +125,13 @@
     {
     if (btd->pairHash == NULL || (core->flag & BAM_FPAIRED) == 0)
 	{
 	if (core->pos == btd->itemStart)
+	    {
+	    printf("<B>Read name:</B> %s<BR>\n", btd->itemName);
 	    singleBamDetails(bam);
 	}
+	}
     else
 	{
 	bam1_t *firstBam = (bam1_t *)hashFindVal(btd->pairHash, btd->itemName);
 	if (firstBam == NULL)
@@ -180,8 +194,10 @@
 	if (! (core->flag & BAM_FMUNMAP))
 	    printf("<B>Note: </B>unable to find paired end for %s "
 		   "within +-%d bases of viewing window %s<BR>\n",
 		   item, pairSearchRange, addCommasToPos(database, cartString(cart, "position")));
+	else
+	    printf("<B>Paired read name:</B> %s<BR>\n", item);
 	singleBamDetails(bam);
 	}
     }
 }