220b1cd2e293b7627533ad6a7761ee93c94b3035
angie
  Tue Mar 8 20:53:31 2011 -0800
Bug #3150 (blat is crashing): The gfPepTile logic assumes that aaValcontains either -1 or 0 to 19.  Previously, aaVal['X'] was -1.  Then
in 1b5e64c4, 'X' was added to dnautil.c's aminoAcidTable and therefore
to aaVal, with aaVal['X'] = 20.  One of the peptide test sequences
ends with "XXXXX", which caused gfPepTile to produce an out-of-range
tile, leading to a SEGV in gfStraightFindHits.  Fix: if aaVal[] is > 19,
treat as if -1.

diff --git src/jkOwnLib/genoFind.c src/jkOwnLib/genoFind.c
index 49f72a1..3fc3a43 100644
--- src/jkOwnLib/genoFind.c
+++ src/jkOwnLib/genoFind.c
@@ -200,31 +200,31 @@
         return -1;
     tile += c;
     }
 return tile;
 }
 
 int gfPepTile(AA *pep, int n)
 /* Make up packed representation of translated protein. */
 {
 int tile = 0;
 int aa;
 while (--n >= 0)
     {
     tile *= 20;
     aa = aaVal[(int)(*pep++)];
-    if (aa < 0)
+    if (aa < 0 || aa > 19)
         return -1;
     tile += aa;
     }
 return tile;
 }
 
 static void gfCountSeq(struct genoFind *gf, bioSeq *seq)
 /* Add all N-mers in seq. */
 {
 char *poly = seq->dna;
 int tileSize = gf->tileSize;
 int stepSize = gf->stepSize;
 int tileHeadSize = gf->tileSize - gf->segSize;
 int maxPat = gf->maxPat;
 int tile;