21b0e3916a8d9580e1f0eb726c268f001aff5890
braney
  Mon Apr 27 15:57:17 2015 -0700
don't pay attention to mate pos information if it's on a different chrom
refs #15248

diff --git src/hg/hgTracks/bamTrack.c src/hg/hgTracks/bamTrack.c
index 11e541e..a00e929 100644
--- src/hg/hgTracks/bamTrack.c
+++ src/hg/hgTracks/bamTrack.c
@@ -356,31 +356,32 @@
 	// not properly paired: make it a lighter shade.
 	lf->grayIx -= 4;
     }
 else
     {
     struct linkedFeatures *lfMate = (struct linkedFeatures *)hashFindVal(btd->pairHash, lf->name);
     if (lfMate == NULL)
 	{
 	if (core->flag & BAM_FPROPER_PAIR)
 	    {
 	    // If we know that this is properly paired, but don't have the mate,
 	    // make a bogus item off the edge of the window so that if we don't
 	    // encounter its mate later, we can at least draw an arrow off the
 	    // edge of the window.
 	    struct linkedFeatures *stub;
-	    if (core->mpos < 0)
+	    // don't link to pair that's not on the same chrom
+	    if ((core->mpos < 0) || (core->tid != core->mtid))
 		{
 		int offscreen;
 		if (lf->orientation > 0)
 		    offscreen = max(winEnd, lf->end) + 10;
 		else
 		    offscreen = min(winStart, lf->start) - 10;
 		if (offscreen < 0) offscreen = 0;
 		stub = lfStub(offscreen, -lf->orientation);
 		}
 	    else
 		{
 		stub = lfStub(core->mpos, -lf->orientation);
 		}
 	    lf->next = stub;
 	    }