예제 #1
0
    def __pslCheck(self):
        """Runs pslCheck program on this table and sends result to reporter's filehandle."""
        self.reporter.beginStep(self.db, self.table, "pslCheck")
        # Get baseColorUseSequence setting
        tdbCommand = ["tdbQuery", "select baseColorUseSequence from " + self.db +\
                " where track='" + self.table +"' or table='"+ self.table +"'"]
        tdbOut, tdbErr = qaUtils.runCommand(tdbCommand)
        # Turn tdbOut into array so we can extract different pieces
        tdbOut = tdbOut.replace("\n", "")
        tdbOut = tdbOut.split(" ")
        # tdbOut[1] should be what option is used for baseColorUseSequence
        # We want to fully run pslCheck for those entries with "table" and "extFile"
        if len(tdbOut) > 2:
            if tdbOut[1] == "table":
                # Get sizes of sequences in specified table
                sizesOut = qaUtils.callHgsql(
                    self.db, "select name, length(seq) from " + tdbOut[2])
            elif tdbOut[1] == "extFile":
                # Extract sizes from named seq table
                sizesOut = qaUtils.callHgsql(
                    self.db, "select acc, size from " + tdbOut[2])

            # Write itemSizes to file
            itemSizes = open("%s.sizes" % self.table, 'w')
            itemSizes.write(sizesOut)
            itemSizes.close()
            # Check if $db.sizes file exists
            if not os.path.isfile("%s.chrom.sizes" % self.db):
                # If it doens't exist, get chrom sizes from chromInfo
                chromSizesOut = qaUtils.callHgsql(self.db,
                                                  "select * from chromInfo")
                chromSizes = open("%s.chrom.sizes" % self.db, 'w')
                chromSizes.write(chromSizesOut)
                chromSizes.close()
            # Run more in-depth version of pslCheck
            command = ("pslCheck", "-querySizes=%s.sizes" % self.table ,\
                    "-targetSizes=%s.chrom.sizes" % self.db, "-db=" + self.db, self.table)
            self.reporter.writeCommand(command)
            commandOut, commandErr, commandReturnCode = qaUtils.runCommandNoAbort(
                command)
            # Write output to file
            self.reporter.fh.write(commandErr)
            # Clean up intermediate item sizes file
            os.remove("%s.sizes" % self.table)

        # For everything else, use generic set of steps
        else:
            command = ["pslCheck", "db=" + self.db, self.table]
            self.reporter.writeCommand(command)
            commandOut, commandErr, commandReturnCode = qaUtils.runCommandNoAbort(
                command)
            self.reporter.fh.write(commandErr)

        if commandReturnCode:
            self.recordError()
        else:
            self.recordPass()
        self.reporter.endStep()
예제 #2
0
    def __pslCheck(self):
        """Runs pslCheck program on this table and sends result to reporter's filehandle."""
        self.reporter.beginStep(self.db, self.table, "pslCheck")
        # Get baseColorUseSequence setting
        tdbCommand = ["tdbQuery", "select baseColorUseSequence from " + self.db +\
                " where track='" + self.table +"' or table='"+ self.table +"'"]
        tdbOut, tdbErr = qaUtils.runCommand(tdbCommand)
        # Turn tdbOut into array so we can extract different pieces
        tdbOut = tdbOut.replace("\n","")
        tdbOut = tdbOut.split(" ")
        # tdbOut[1] should be what option is used for baseColorUseSequence
        # We want to fully run pslCheck for those entries with "table" and "extFile"
        if len(tdbOut) > 2:
            if tdbOut[1] == "table":
                # Get sizes of sequences in specified table
                sizesOut = qaUtils.callHgsql(self.db, "select name, length(seq) from " + tdbOut[2])
            elif tdbOut[1] == "extFile":
                # Extract sizes from named seq table
                sizesOut = qaUtils.callHgsql(self.db, "select acc, size from " + tdbOut[2])

            # Write itemSizes to tempfile
            itemSizesTemp = tempfile.NamedTemporaryFile(mode='w')
            itemSizes = open(itemSizesTemp.name, 'w')
            itemSizes.write(sizesOut)
            itemSizes.close()
            # Write chromSizes to tempfile
            chromSizesTemp = tempfile.NamedTemporaryFile(mode='w')
            chromSizesOut = qaUtils.callHgsql(self.db, "select chrom,size from chromInfo")
            chromSizes = open(chromSizesTemp.name, 'w')
            chromSizes.write(chromSizesOut)
            chromSizes.close()

            # Run more in-depth version of pslCheck
            command = ("pslCheck", "-querySizes=" + itemSizesTemp.name ,\
                    "-targetSizes=" + chromSizesTemp.name, "-db=" + self.db, self.table)
            self.reporter.writeCommand(command)
            commandOut, commandErr, commandReturnCode = qaUtils.runCommandNoAbort(command)
            # Write output to file
            self.reporter.fh.write(commandErr)

        # For everything else, use generic set of steps
        else:
            command = ["pslCheck", "db=" + self.db, self.table]
            self.reporter.writeCommand(command)
            commandOut, commandErr, commandReturnCode = qaUtils.runCommandNoAbort(command)
            self.reporter.fh.write(commandErr)

        if commandReturnCode:
            self.recordError()
        else:
            self.recordPass()
        self.reporter.endStep()
예제 #3
0
 def __checkTableCoords(self):
     """Runs checkTableCoords program on this table."""
     self.reporter.beginStep(self.db, self.table, "checkTableCoords")
     command = ["checkTableCoords", self.db, self.table]
     self.reporter.writeCommand(command)
     commandOut, commandErr, commandReturnCode = qaUtils.runCommandNoAbort(command)
     self.reporter.fh.write(commandErr)
     if commandReturnCode:
         self.recordError()
     else:
         self.recordPass()
     self.reporter.endStep()
예제 #4
0
    def __genePredCheck(self):
        """Runs genePredCheck program on this table and sends results to reporter's filehandle."""
        self.reporter.beginStep(self.db, self.table, "genePredCheck")
        command = ["genePredCheck", "db=" + self.db, self.table]
        self.reporter.writeCommand(command)
	commandOut, commandErr, commandReturnCode = qaUtils.runCommandNoAbort(command)
        self.reporter.fh.write(commandErr)
        if commandReturnCode:
            self.recordError()
        else:
            self.recordPass()
        self.reporter.endStep()
예제 #5
0
 def __positionalTblCheck(self):
     """Runs positionalTblCheck program on this table. Excludes GenBank tables."""
     if not self.__isGenbankTable():
         self.reporter.beginStep(self.db, self.table, "positionalTblCheck")
         command = ["positionalTblCheck", self.db, self.table]
         self.reporter.writeCommand(command)
         commandOut, commandErr, commandReturnCode = qaUtils.runCommandNoAbort(command)
         self.reporter.fh.write(commandErr)
         if commandReturnCode:
             self.recordError()
         else:
             self.recordPass()
         self.reporter.endStep()
예제 #6
0
 def __genePredCheck(self):
     """Runs genePredCheck program on this table and sends results to reporter's filehandle."""
     self.reporter.beginStep(self.db, self.table, "genePredCheck")
     command = ["genePredCheck", "db=" + self.db, self.table]
     self.reporter.writeCommand(command)
     commandOut, commandErr, commandReturnCode = qaUtils.runCommandNoAbort(
         command)
     self.reporter.fh.write(commandErr)
     if commandReturnCode:
         self.recordError()
     else:
         self.recordPass()
     self.reporter.endStep()
예제 #7
0
def getTrackType(db, track):
    """Looks for a track type via tdbQuery."""
    cmd = ["tdbQuery", "select type from " + db + " where track='" + track +
           "' or table='" + track + "'"]
    cmdout, cmderr, cmdreturncode = qaUtils.runCommandNoAbort(cmd)
    
    if cmdreturncode != 0:
        # keep command arguments nicely quoted
        cmdstr = " ".join([pipes.quote(arg) for arg in cmd])
        raise Exception("Error from: " + cmdstr + ": " + cmderr)
    if cmdout:
        trackType = cmdout.split()[1]
    else:
        trackType = None
    return trackType
예제 #8
0
def getTrackType(db, table):
    """Looks for a track type via tdbQuery."""
    cmd = [
        "tdbQuery", "select type from " + db + " where track='" + table +
        "' or table='" + table + "'"
    ]
    cmdout, cmderr, cmdreturncode = qaUtils.runCommandNoAbort(cmd)

    if cmdreturncode != 0:
        # keep command arguments nicely quoted
        cmdstr = " ".join([pipes.quote(arg) for arg in cmd])
        raise Exception("Error from: " + cmdstr + ": " + cmderr)
    if cmdout:
        tableType = cmdout.split()[1]
    else:
        tableType = None
    return tableType