50367dd2101774592c5367431d32a7b9ef5c17ab
hiram
  Fri Nov 5 14:53:51 2021 -0700
fixup integer overflow error which eliminated CpG detection in high GC content regions refs #26707

diff --git src/utils/cpgIslandExt/cpg_lh.c src/utils/cpgIslandExt/cpg_lh.c
index 5baa608..1714b77 100644
--- src/utils/cpgIslandExt/cpg_lh.c
+++ src/utils/cpgIslandExt/cpg_lh.c
@@ -157,59 +157,59 @@
       if ( sc == 0 && lsc )  /* should threshold here */
 	{
 	  /* imn+1 is the start of the match. 
 	     imx+1 is the end of the match, given pattern-length=2.
 	     fetchdb using reported co-ordinates will return a sequence
 	     which both starts and ends with a complete pattern.
 	     Further +1 adjusts so that start of sequence = 1 
 	  */
 
 	  getstats ( imn+1, imx+2, seq, seqname, &ncpg, &ngpc, &ng, &nc ) ;
 	  ngc = ng + nc;
       if (((imx+2)-(imn+2))>199 && (ngc*100.0/(imx+1-imn))>50.0 ) {
 	/* old gos estimate	  printf("%s\t %d\t %d\t %d\t CpG: %d\t %.1f\t %.1f\n", seqname, imn+2, imx+2, mx, ncpg, ngc*100.0/(imx+1-imn), 1.0*ncpg/ngpc) ; */
 	winlen=imx+1-imn;
 	/* ASH 3/23/04: expected val from Gardiner-Garden & Frommer '87: */
-	expect = (float)(nc * ng) / (float)winlen;
+	expect = ((float)nc * (float)ng) / (float)winlen;
 	obsToExp = (float)ncpg / expect;
 	if ( obsToExp > 0.60 )
            printf("%s\t %d\t %d\t %d\t CpG: %d\t %.1f\t %.2f\t %.2f\n",
 		  seqname, imn+2, imx+2, mx, ncpg, ngc*100.0/(imx+1-imn),
 		  1.0*ncpg/ngpc, obsToExp) ; 
       }
 /* 	  printf("%s \t %d\t %d\t %d \n", seqname, imn+2, imx+2, mx ) ; 
   */
 	  /* Recursive call searches from one position after the end of the 
 	     last match to the current position */
 	  findspans( imx+2, i, seq, seqname ) ;
 	  sc = lsc = imn = imx =  mx = 0 ;
 	}
       imx = sc > mx ? i : imx ;
       mx = sc > mx ? sc : mx ;
       imn = sc == 0 ? i : imn ;
       ++i ;
     }
   if ( sc != 0 )  /* should threshold here */
     {
 /*      printf("%d \t %d \t%d \t %d \t%d \t%d\n", i, sc, lsc, imn, imx, mx) ;  */
       
       /* ASH 3/23/04: Make this test & output consistent w/above. */
       getstats ( imn+1, imx+2, seq, seqname, &ncpg, &ngpc, &ng, &nc ) ;
       ngc = nc + ng;
       if (((imx+2)-(imn+2))>199 && (ngc*100.0/(imx+1-imn))>50.0 ) {
 	winlen=imx+1-imn;
-	expect = (float)(nc * ng) / (float)winlen;
+	expect = ((float)nc * (float)ng) / (float)winlen;
 	obsToExp = (float)ncpg / expect;
 	if ( obsToExp > 0.60 )
            printf("%s\t %d\t %d\t %d\t CpG: %d\t %.1f\t %.2f\t %.2f\n",
 		  seqname, imn+2, imx+2, mx, ncpg, ngc*100.0/(imx+1-imn),
 		  1.0*ncpg/ngpc, obsToExp) ; 
       }
       
 /*      printf("%s \t %d\t %d\t %d \n", seqname, imn+2, imx+2, mx ) ; 
    */
       findspans( imx+2, end, seq, seqname ) ;
     }
 }
 
 /* ASH 3/23/04: Return separate counts of G's and C's for expected val calc. */
 void getstats ( int start, int end, char *seq, char *seqname, int *ncpg, int *ngpc, int *ng, int *nc )