src/hg/makeDb/hgLoadBed/hgLoadBed.c 1.68

1.68 2009/04/14 04:03:29 mikep
fix problem where fillInScore field might contain only -1 values which is the equivalent of a NULL in the not-null field
Index: src/hg/makeDb/hgLoadBed/hgLoadBed.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/makeDb/hgLoadBed/hgLoadBed.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -b -B -U 4 -r1.67 -r1.68
--- src/hg/makeDb/hgLoadBed/hgLoadBed.c	11 Mar 2009 22:30:11 -0000	1.67
+++ src/hg/makeDb/hgLoadBed/hgLoadBed.c	14 Apr 2009 04:03:29 -0000	1.68
@@ -486,11 +486,12 @@
                     if(row != NULL)
                         {
                         float min = sqlFloat(row[0]);
                         float max = sqlFloat(row[1]);
+			if ( !(max == -1 && min == -1)) // if score is -1 then ignore, as if it werent present
+			    {
 			if (max == min || sameString(row[0],row[1])) // this will lead to 'inf' score value in SQL update causing an error
 			    errAbort("Could not set score in table %s max(%s)=min(%s)=%s\n", track, fillInScoreColumn, fillInScoreColumn, row[0]);
-                        sqlFreeResult(&sr);
 
                         // Calculate a, b s/t f(x) = ax + b maps min-max => minScore-1000
                         float a = (1000-minScore) / (max - min);
                         float b = 1000 - ((1000-minScore) * max) / (max - min);
@@ -500,11 +501,13 @@
                         verbose(2, "update query: %s; changed: %d\n", query, changed);
                         }
                     else
                         {
-                        sqlFreeResult(&sr);
+			    verbose(2, "score not updated; all values for column %s are -1\n", fillInScoreColumn);
                         }
                     }
+                    sqlFreeResult(&sr);
+                    }
                 }
             }
 
         }