20fbb7ae479a31744136198cb1d6d4e3fc26e6f0
angie
  Tue Apr 12 16:31:02 2011 -0700
Bug #3575 (GTF output in Table Browser contains start > end): Fixed byadding an end > start test I forgot to work into a42565e69, which was
the fix for #2964.

diff --git src/hg/hgTables/gffOut.c src/hg/hgTables/gffOut.c
index a614b19..a9d9a8a 100644
--- src/hg/hgTables/gffOut.c
+++ src/hg/hgTables/gffOut.c
@@ -153,30 +153,31 @@
 		cdsPortionStart = stopCodonEnd;
 	    addGffLineFromBed(bed, source, "stop_codon", exonCdsStart, stopCodonEnd, '.', txName);
 	    }
 	if (cdsPortionStart < exonCdsEnd)
 	    addGffLineFromBed(bed, source, "CDS", cdsPortionStart, exonCdsEnd,
 			      frames[exonIndx], txName);
 	}
     else
 	{
 	int stopCodonStart = offsetToGenomic(bed, exonIndx, exonCdsEnd, -3);
 	int cdsPortionEnd = exonCdsEnd;
 	if (stopCodonStart >= 0 && stopCodonStart >= bed->thickStart)
 	    {
 	    if (gtf2StopCodons)
 		cdsPortionEnd = stopCodonStart;
+	    if (cdsPortionEnd > exonCdsStart)
 	    addGffLineFromBed(bed, source, "CDS", exonCdsStart, cdsPortionEnd,
 			      frames[exonIndx], txName);
 	    addGffLineFromBed(bed, source, "stop_codon", stopCodonStart, exonCdsEnd, '.', txName);
 	    }
 	else if (cdsPortionEnd > exonCdsStart)
 	    addGffLineFromBed(bed, source, "CDS", exonCdsStart, cdsPortionEnd,
 			      frames[exonIndx], txName);
 	}
     }
 else
     {
     int cdsPortionStart = exonCdsStart;
     int cdsPortionEnd = exonCdsEnd;
     if (gtf2StopCodons)
 	{