def runWorkflow_TestScript(sequences, newickTreeString, batchSystem="single_machine", buildAvgs=False, buildReference=False, buildCactusPDF=False, buildAdjacencyPDF=False, makeCactusTreeStats=False, makeMAFs=False, configFile=None, buildJobTreeStats=False): """Runs the workflow and various downstream utilities. """ #Setup the temp dir tempDir = getTempDirectory(".") logger.info("Using the temp dir: %s" % tempDir) #Setup the output dir outputDir = getTempDirectory(tempDir) logger.info("Using the output dir: %s" % outputDir) experiment = cactus.shared.test.runWorkflow_TestScript(sequences, newickTreeString, outputDir=outputDir, batchSystem=batchSystem, buildAvgs=buildAvgs, buildReference=buildReference, configFile=configFile, buildJobTreeStats=buildJobTreeStats) cactusDiskDatabaseString = experiment.getDatabaseString() #Run the cactus tree graph-viz plot if buildCactusPDF: cactusTreeDotFile = os.path.join(outputDir, "cactusTree.dot") cactusTreePDFFile = os.path.join(outputDir, "cactusTree.pdf") runCactusTreeViewer(cactusTreeDotFile, cactusDiskDatabaseString) runGraphViz(cactusTreeDotFile, cactusTreePDFFile) logger.info("Ran the cactus tree plot script") else: logger.info("Not building a cactus tree plot") #Run the cactus tree graph-viz plot if buildAdjacencyPDF: adjacencyGraphDotFile = os.path.join(outputDir, "adjacencyGraph.dot") adjacencyGraphPDFFile = os.path.join(outputDir, "adjacencyGraph.pdf") runCactusAdjacencyGraphViewer(adjacencyGraphDotFile, cactusDiskDatabaseString) #runGraphViz(adjacencyGraphDotFile, adjacencyGraphPDFFile) //Taking this line out to avoid graphviz crashing in an annoying way logger.info("Ran the adjacency graph plot script") else: logger.info("Not building a adjacency graph plot") if makeCactusTreeStats: cactusTreeFile = os.path.join(outputDir, "cactusStats.xml") runCactusTreeStats(cactusTreeFile, cactusDiskDatabaseString) #Now run the latex script statsFileTEX = os.path.join(outputDir, "cactusStats.tex") runCactusTreeStatsToLatexTables([ cactusTreeFile ], [ "region0" ], statsFileTEX) logger.info("Ran the tree stats script") else: logger.info("Not running cactus tree stats") if makeMAFs: mAFFile = os.path.join(outputDir, "cactus.maf") runCactusMAFGenerator(mAFFile, cactusDiskDatabaseString) logger.info("Ran the MAF building script") else: logger.info("Not building the MAFs") #Now remove everything we generate experiment.cleanupDatabase() system("rm -rf %s" % tempDir)
def runVanilla(self): logger.debug("Going to put the alignment in %s" % self.outputDir) if not os.path.isdir(self.outputDir): os.mkdir(self.outputDir) if not os.path.exists(os.path.join(self.outputDir, "cactusAlignmentVanilla")): xmlTree = ET.parse(os.path.join(getRootPathString(), "lib", "cactus_workflow_config.xml")) #Set the parameters tempLocalDir = os.path.join(self.outputDir, "tempVanillaCactusAlignment") system("rm -rf %s" % tempLocalDir) os.mkdir(tempLocalDir) #Set the config parameters self.params.applyToXml(xmlTree) config = xmlTree.getroot() assert config is not None #Write the config file tempConfigFile = os.path.join(tempLocalDir, "config.xml") fileHandle = open(tempConfigFile, 'w') assert fileHandle is not None tree = ET.ElementTree(config) tree.write(fileHandle) fileHandle.close() #Make the experiment file tempExperimentFile = os.path.join(tempLocalDir, "experiment.xml") #Now do standard cactus.. #Make the experiment file tempExperimentFile2 = os.path.join(tempLocalDir, "experiment.xml") cactusWorkflowExperiment = CactusWorkflowExperiment( sequences=self.sequences, newickTreeString=self.newickTree, #requiredSpecies=self.requiredSpecies, #singleCopySpecies=self.singleCopySpecies, databaseName="cactusAlignmentVanilla", outputDir=tempLocalDir, configFile=tempConfigFile) tempExperimentDir2 = os.path.join(tempLocalDir, "cactusAlignmentVanilla") cactusWorkflowExperiment.writeExperimentFile(tempExperimentFile2) # apply naming to the event tree to be consistent with progressive exp = ExperimentWrapper(ET.parse(tempExperimentFile2).getroot()) cleanEventTree(exp) exp.writeXML(tempExperimentFile2) #We're done with the progressive, now run the vanilla cactus for comparison tempJobTreeDir2 = os.path.join(tempLocalDir, "jobTreeVanilla") runCactusWorkflow(tempExperimentFile2, tempJobTreeDir2, jobTreeStats=True, setupAndBuildAlignments=True, buildReference=True, maxThreads=4) runJobTreeStatusAndFailIfNotComplete(tempJobTreeDir2) logger.info("Checked the job tree dir for the vanilla run") runCactusMAFGenerator(os.path.join(self.outputDir, "cactusVanilla.maf"), getCactusDiskString(tempExperimentDir2)) #Run the cactus tree stats treeStatsFile = os.path.join(self.outputDir, "treeStats.xml") system("cactus_treeStats --cactusDisk \'%s\' --flowerName 0 --outputFile %s" %(exp.getDiskDatabaseString(), treeStatsFile)) system("jobTreeStats --jobTree %s --outputFile %s/jobTreeStats.xml" % (tempJobTreeDir2, self.outputDir)) system("mv %s %s" % (tempExperimentDir2, self.outputDir)) system("mv %s %s/experiment.xml" % (tempExperimentFile2, self.outputDir))
def runWorkflow_TestScript(sequences, newickTreeString, batchSystem="single_machine", buildAvgs=False, buildReference=False, buildCactusPDF=False, buildAdjacencyPDF=False, makeCactusTreeStats=False, makeMAFs=False, configFile=None, buildJobTreeStats=False): """Runs the workflow and various downstream utilities. """ #Setup the temp dir tempDir = getTempDirectory(".") logger.info("Using the temp dir: %s" % tempDir) #Setup the output dir outputDir = getTempDirectory(tempDir) logger.info("Using the output dir: %s" % outputDir) experiment = cactus.shared.test.runWorkflow_TestScript( sequences, newickTreeString, outputDir=outputDir, batchSystem=batchSystem, buildAvgs=buildAvgs, buildReference=buildReference, configFile=configFile, buildJobTreeStats=buildJobTreeStats) cactusDiskDatabaseString = experiment.getDatabaseString() #Run the cactus tree graph-viz plot if buildCactusPDF: cactusTreeDotFile = os.path.join(outputDir, "cactusTree.dot") cactusTreePDFFile = os.path.join(outputDir, "cactusTree.pdf") runCactusTreeViewer(cactusTreeDotFile, cactusDiskDatabaseString) runGraphViz(cactusTreeDotFile, cactusTreePDFFile) logger.info("Ran the cactus tree plot script") else: logger.info("Not building a cactus tree plot") #Run the cactus tree graph-viz plot if buildAdjacencyPDF: adjacencyGraphDotFile = os.path.join(outputDir, "adjacencyGraph.dot") adjacencyGraphPDFFile = os.path.join(outputDir, "adjacencyGraph.pdf") runCactusAdjacencyGraphViewer(adjacencyGraphDotFile, cactusDiskDatabaseString) #runGraphViz(adjacencyGraphDotFile, adjacencyGraphPDFFile) //Taking this line out to avoid graphviz crashing in an annoying way logger.info("Ran the adjacency graph plot script") else: logger.info("Not building a adjacency graph plot") if makeCactusTreeStats: cactusTreeFile = os.path.join(outputDir, "cactusStats.xml") runCactusTreeStats(cactusTreeFile, cactusDiskDatabaseString) #Now run the latex script statsFileTEX = os.path.join(outputDir, "cactusStats.tex") runCactusTreeStatsToLatexTables([cactusTreeFile], ["region0"], statsFileTEX) logger.info("Ran the tree stats script") else: logger.info("Not running cactus tree stats") if makeMAFs: mAFFile = os.path.join(outputDir, "cactus.maf") runCactusMAFGenerator(mAFFile, cactusDiskDatabaseString) logger.info("Ran the MAF building script") else: logger.info("Not building the MAFs") #Now remove everything we generate experiment.cleanupDatabase() system("rm -rf %s" % tempDir)