c876503e3152499aad11157a06071aa37ab3e8df
braney
  Fri Jul 27 18:25:17 2012 -0700
round #3.  Now genePredToBed matches what comes out of genePredToFakePsl followed by pslToBed if you make thickStart and thickEnd equal 0 when they equal each other.   Now cdsEnd points to the base after the last base in CDS, even if that base is not in one of the exons.
diff --git src/hg/pslToBed/pslToBed.c src/hg/pslToBed/pslToBed.c
index 4be663e..eabf22d 100644
--- src/hg/pslToBed/pslToBed.c
+++ src/hg/pslToBed/pslToBed.c
@@ -47,52 +47,55 @@
 	}
     else if (psl->qStarts[blockNum] + psl->blockSizes[blockNum] > queryAddress)
 	{
 	// since block addresses are always increasing we know if the end
 	// of the block is beyond our address that the address is 
 	// in this block
 	unsigned offsetInBlock = queryAddress - psl->qStarts[blockNum];
 
 	assert(offsetInBlock < psl->blockSizes[blockNum]);
 
 	return psl->tStarts[blockNum] + offsetInBlock;
 	}
     }
 
 // we don't have any blocks with this query in it, just point
-// to the end
-return psl->tEnd;
+// to the last base
+return psl->tEnd - 1;
 }
 
 static void setThick(struct psl *psl, struct bed *bed, struct cds *cds)
 // set thickStart and thickEnd based on CDS record
 {
 unsigned thickStart, thickEnd;
 unsigned cdsStart = cds->start - 1;
 unsigned cdsEnd = cds->end;
 
 if (psl->strand[0] == '-')
     {
     // if on negative strand, cds is from end
     unsigned temp = cdsStart;
     cdsStart = psl->qSize - cdsEnd;
     cdsEnd = psl->qSize - temp;
     }
 
 // we subtract one from start to convert to PSL coordinate system
 thickStart = getTargetForQuery(psl, cdsStart);
-thickEnd = getTargetForQuery(psl, cdsEnd);
+
+// cdsEnd actually points to one base after the end, so
+// we translate the base address, then add one
+thickEnd = getTargetForQuery(psl, cdsEnd - 1) + 1;
 
 // if thickStart equals thickEnd, then there is no CDS
 if (thickStart == thickEnd)
     thickStart = thickEnd = 0;
 
 bed->thickStart = thickStart;
 bed->thickEnd = thickEnd;
 }
 
 void pslToBed(char *pslFile, char *bedFile, struct hash *cdsHash)
 /* pslToBed -- tranform a psl format file to a bed format file */
 {
 struct lineFile *pslLf = pslFileOpen(pslFile);
 FILE *bedFh = mustOpen(bedFile, "w");
 struct psl *psl;