src/hg/hgTracks/cds.c 1.100

1.100 2009/06/10 19:46:20 angie
Some code for codons smaller than 3 bases was erroneously applied to noncoding blocks smaller than 3 bases.
Index: src/hg/hgTracks/cds.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/cds.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -b -B -U 4 -r1.99 -r1.100
--- src/hg/hgTracks/cds.c	29 May 2009 21:05:04 -0000	1.99
+++ src/hg/hgTracks/cds.c	10 Jun 2009 19:46:20 -0000	1.100
@@ -57,9 +57,9 @@
                                         int chromStart, int chromEnd,
                                         double scale, int xOff, int y,
                                         int height, Color color, int score,
                                         MgFont *font, char *text, bool zoomed,
-                                        int winStart, int maxPixels)
+                                        int winStart, int maxPixels, boolean isCoding)
 /* Draw a box scaled from chromosome to window coordinates with
    a codon or set of 3 or less bases drawn in the box. */
 {
 
@@ -82,12 +82,12 @@
     w = x2-x1;
     if (w < 1)
         w = 1;
 
-    if (chromEnd - chromStart == 3)
+    if (chromEnd - chromStart == 3 && isCoding)
         spreadBasesString(hvg,x1,y,w,height,whiteIndex(),
 		     font,text,strlen(text), TRUE);
-    else if (chromEnd - chromStart < 3)
+    else if (chromEnd - chromStart < 3 && isCoding)
         spreadBasesString(hvg,x1,y,w,height,cdsColor[CDS_PARTIAL_CODON],font,
 		     text,strlen(text), TRUE);
     else
         {
@@ -1288,14 +1288,15 @@
     char mrnaBases[4];
     char genomicCodon[2];
     char mrnaCodon[2]; 
     boolean queryInsertion = FALSE;
+    boolean isCoding = (drawOpt == baseColorDrawItemCodons || drawOpt == baseColorDrawDiffCodons);
 
     mrnaBases[0] = '\0';
-    if (psl)
+    if (psl && isCoding)
 	getMrnaBases(psl, mrnaSeq, mrnaS, s, e, (lf->orientation == -1),
 		    mrnaBases, &queryInsertion);
-    if (queryInsertion)
+    if (queryInsertion && isCoding)
 	color = cdsColor[CDS_QUERY_INSERTION];
 
     dyStringAppendN(dyMrnaSeq, (char*)&mrnaSeq->dna[mrnaS], e-s);
 
@@ -1304,9 +1305,9 @@
 	if (cartUsualBooleanDb(cart, database, COMPLEMENT_BASES_VAR, FALSE))
 	    complement(dyMrnaSeq->string, dyMrnaSeq->stringSize);
 	drawScaledBoxSampleWithText(hvg, s, e, scale, xOff, y, heightPer, 
 				    color, lf->score, font, dyMrnaSeq->string,
-				    zoomedToBaseLevel, winStart, maxPixels);
+				    zoomedToBaseLevel, winStart, maxPixels, isCoding);
 	}
     else if (drawOpt == baseColorDrawItemCodons)
 	{
 	if (e <= lf->tallEnd)
@@ -1324,9 +1325,9 @@
                 color = cdsColor[CDS_START];
 	    drawScaledBoxSampleWithText(hvg, s, e, scale, xOff, y, heightPer, 
 					color, lf->score, font, mrnaCodon,
 					zoomedToCodonLevel, winStart,
-					maxPixels);
+					maxPixels, isCoding);
 	    }
 	else
 	    drawScaledBox(hvg, s, e, scale, xOff, y, heightPer, color);
 	}
@@ -1340,9 +1341,9 @@
 	if (cartUsualBooleanDb(cart, database, COMPLEMENT_BASES_VAR, FALSE))
 	    complement(diffStr, strlen(diffStr));
 	drawScaledBoxSampleWithText(hvg, s, e, scale, xOff, y, heightPer, 
 				    color, lf->score, font, diffStr, 
-				    zoomedToBaseLevel, winStart, maxPixels);
+				    zoomedToBaseLevel, winStart, maxPixels, isCoding);
 	freeMem(diffStr);
 	dnaSeqFree(&genoSeq);
 	}
     else if (drawOpt == baseColorDrawDiffCodons)
@@ -1363,9 +1364,9 @@
 		{
 		drawScaledBoxSampleWithText(hvg, s, e, scale, xOff, y, 
 					    heightPer, color, lf->score, font,
 					    mrnaCodon, zoomedToCodonLevel,
-					    winStart, maxPixels );
+					    winStart, maxPixels, isCoding);
 		}
 	    else
 		drawScaledBox(hvg, s, e, scale, xOff, y, heightPer, color);
 	    }
@@ -1408,9 +1409,9 @@
 if (drawOpt == baseColorDrawGenomicCodons && (e-s <= 3))
     {
     drawScaledBoxSampleWithText(hvg, s, e, scale, xOff, y, heightPer, 
                                 color, lf->score, font, codon, 
-                                zoomedToCodonLevel, winStart, maxPixels);
+                                zoomedToCodonLevel, winStart, maxPixels, TRUE);
     }
 else if (mrnaSeq != NULL && (psl != NULL || sf != NULL) && !zoomedOutToPostProcessing &&
 	 drawOpt != baseColorDrawGenomicCodons)
     {
@@ -1753,9 +1754,9 @@
     Color color = colorAndCodonFromGrayIx(hvg, codon, sf->grayIx, MG_GRAY);
     if (zoomedToText)
         drawScaledBoxSampleWithText(hvg, sf->start, sf->end, scale, insideX, y,
 				    height, color, 1.0, font, codon, TRUE,
-				    winStart, maxPixels);
+				    winStart, maxPixels, TRUE);
     else
         /* zoomed in just enough to see colored boxes */
         drawScaledBox(hvg, sf->start, sf->end, scale, xOff, y, height, color);
     }