src/hg/hgGenome/import.c 1.18

1.18 2010/04/23 04:20:19 galt
handling wiggle density better for sparse variableStep wiggles
Index: src/hg/hgGenome/import.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgGenome/import.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -b -B -U 4 -r1.17 -r1.18
--- src/hg/hgGenome/import.c	25 Mar 2010 17:20:40 -0000	1.17
+++ src/hg/hgGenome/import.c	23 Apr 2010 04:20:19 -0000	1.18
@@ -1364,15 +1364,25 @@
 	AllocArray(depth, numWindows);
 	AllocArray(hit, numWindows);
 	}
 
+    //debug
+    //hPrintf("length of statsList=%d<br>\n", slCount(statsList));
+
+
     for(stats=statsList;stats;stats=stats->next)
 	{
+
+
+	//debug
+	//hPrintf("stats-> count=%d start=%d end=%d (end-start)=%d mean=%f <br>\n", 
+	  //  stats->count, stats->chromStart, stats->chromEnd, stats->chromEnd - stats->chromStart, stats->mean);
+
 	totalValues += stats->count;
 	int i; 
 	int start = stats->chromStart;
 	int end = stats->chromEnd;
-	double sumData = stats->mean;
+	double sumData = (stats->span * stats->mean * stats->count) / (stats->chromEnd - stats->chromStart);  // fixing this line
 	for(i = start/windowSize; i*windowSize < end; ++i)
 	    {
 	    overlap = rangeIntersection(start, end, i*windowSize, (i+1)*windowSize);
 	    if (overlap > 0)
@@ -1451,8 +1464,12 @@
     {
     isChromGraphCt = isChromGraph(curTrack);
     }
 
+//debug
+//hPrintf("isCt=%d isWig=%d isPositional=%d isMaf=%d isBedGr=%d<br>\n", 
+    //isCt, isWig, isPositional, isMaf, isBedGr);
+
 struct sqlConnection *conn = curTrack ? hAllocConnTrack(database, curTrack) : hAllocConn(database);
 if (isPositional && !isWig && !isMaf && !isBedGr && !isChromGraphCt)
     {  /* simple positional */
     char *convertType =