443522be5baf8c9418caf54491f6657dac6329f5 rhead Fri Apr 27 16:34:59 2012 -0700 Added summary module for making tab-separated summary output for table QA. Also made qaGbTracks make 3 different files. The .chrom output is just using the tableCheck countPerChrom function for now. diff --git src/utils/qa/qaGbTracks src/utils/qa/qaGbTracks index 2caa40a..dacb66d 100755 --- src/utils/qa/qaGbTracks +++ src/utils/qa/qaGbTracks @@ -1,60 +1,79 @@ #!/usr/bin/env python2.7 import sys import argparse -import logging +import time from ucscgenomics.qa import qaUtils from ucscgenomics.qa.tables import factory from ucscgenomics.qa.tables import reporter +from ucscgenomics.qa.tables import summary +from ucscgenomics.qa.encode import tableCheck def parseCommandLine(): parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description='Runs the New Track Checklist table tests', epilog=""" The following tests are run: genePredCheck pslCheck checkTblCoords positionalTblCheck runBits.csh check for the existence of table descriptions check for shortLabels and longLabels that are too long check for underscores in table names check for tables missing an index (joinerCheck) - not yet implemented countPerChrom """) - parser.add_argument('database', help='the database to check') + parser.add_argument('db', help='the database to check') parser.add_argument('tableList', help='a file listing the tables to check') - parser.add_argument('outFileName', help='name to use to write results files') + parser.add_argument('outFileName', help='base name for results files') parser.add_argument('-v', '--verbose', action='store_true', help='turn on verbose messages in error log') return parser.parse_args() def getTableListFromFile(): with open(args.tableList, "r") as f: raw = f.readlines() return [name.strip() for name in raw] -def runTests(reporter, tableList): +def runValidators(): reporter.writeTimestamp() reporter.writeBlankLine() for table in tableList: reporter.writeLine("===============================================") - reporter.writeLine("Tests for " + args.database + "." + table +":\n") - table = factory.tableQaFactory(args.database, table, reporter) + reporter.writeLine("Tests for " + args.db + "." + table +":\n") + table = factory.tableQaFactory(args.db, table, reporter, sumTable) table.validate() reporter.writeLine("===============================================") reporter.writeLine("Tests complete:") reporter.writeTimestamp() +def writeSummaryFile(): + sumFile.write(sumTable.tabSeparated()) + +def runChromCounts(): + chromFile.write(time.asctime() + "\n") + chromFile.write("Database: " + args.db + "\n\n") + tableSet = set(tableList) + output, tablecounts = tableCheck.countPerChrom(args.db, tableSet) + for line in output: + chromFile.write(line + "\n") + args = parseCommandLine() tableList = getTableListFromFile() -qaUtils.checkTablesExist(args.database, tableList) -fh = open(args.outFileName + ".log", "w") -reporter = reporter.Reporter(fh) -runTests(reporter, tableList) - +qaUtils.checkTablesExist(args.db, tableList) +logFile = open(args.outFileName + ".log", "w") +chromFile = open(args.outFileName + ".chroms", "w") +sumFile = open(args.outFileName + ".summary", "w") +reporter = reporter.Reporter(logFile) +sumTable = summary.SumTable() +runValidators() +runChromCounts() +writeSummaryFile() -fh.close() +logFile.close() +sumFile.close() +chromFile.close()