4d095031f42c038bde881b9c2e1af427a7358f14
rhead
  Fri May 18 14:44:20 2012 -0700
Got rid of most of the globals, except in the tableList processing.
diff --git src/utils/qa/qaGbTracks src/utils/qa/qaGbTracks
index 4a7e1a4..f07af93 100755
--- src/utils/qa/qaGbTracks
+++ src/utils/qa/qaGbTracks
@@ -42,58 +42,58 @@
 
 def checkTablesExist(db, tables):
     """Raises an exception if any table in the tables list does not exist in the database."""
     for name in tables:
         if not tableExists(db, name):
             raise Exception("Table " + name + " in " + db + " does not exist")
 
 def getTableList():
     if args.single:
         return [args.tableList]
     else:
         with open(args.tableList, "r") as f:
             raw = f.readlines()
         return [name.strip() for name in raw]
 
-delimiterLine = "==============================================="
-def runTests():
+def runTests(db, reporter, sumTable):
     """Runs validate() and statistics() methods on each table. Writes log output."""
+    delimiterLine = "==============================================="
     reporter.writeTimestamp()
     reporter.writeBlankLine()
     for table in tableList:
         reporter.writeLine(delimiterLine)
-        reporter.writeLine(args.db + "." + table +":\n")
-        table = factory.tableQaFactory(args.db, table, reporter, sumTable)
+        reporter.writeLine(db + "." + table +":\n")
+        table = factory.tableQaFactory(db, table, reporter, sumTable)
         table.validate()
         table.statistics()
     reporter.writeLine(delimiterLine)
     reporter.writeLine("Tests complete:")
     reporter.writeTimestamp()
 
-def writeSummaryFile():
+def writeSummaryFile(sumTable, sumFile):
     sumFile.write(sumTable.tabSeparated())
 
-def runChromCounts():
+def runChromCounts(db, chromFile):
     chromFile.write(time.asctime() + "\n")
-    chromFile.write("Database: " + args.db + "\n\n")
+    chromFile.write("Database: " + db + "\n\n")
     tableSet = set(tableList)
-    output, tablecounts = tableCheck.countPerChrom(args.db, tableSet)
+    output, tablecounts = tableCheck.countPerChrom(db, tableSet)
     for line in output:
         chromFile.write(line + "\n")
 
 args = parseCommandLine()
 tableList = getTableList()
 checkTablesExist(args.db, tableList)
 
 logFile = open(args.outFile + ".log", "w")
 chromFile = open(args.outFile + ".chroms", "w")
 sumFile = open(args.outFile + ".summary", "w")
 reporter = reporter.Reporter(logFile)
 sumTable = summary.SumTable()
 
-runTests()
-runChromCounts()
-writeSummaryFile()
+runTests(args.db, reporter, sumTable)
+runChromCounts(args.db, chromFile)
+writeSummaryFile(sumTable, sumFile)
 
 logFile.close()
 sumFile.close()
 chromFile.close()