Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def runCactusPhylogeny(cactusDiskDatabaseString,
flowerNames=encodeFlowerNames((0,)),
logLevel=None):
logLevel = getLogLevelString2(logLevel)
cactus_call(stdin_string=flowerNames,
parameters=["cactus_phylogeny",
"--cactusDisk", cactusDiskDatabaseString,
"--logLevel", logLevel])
logger.info("Ran cactus_phylogeny okay")
def blockUntilKtserverIsRunning(logPath, createTimeout=1800):
"""Check status until it's successful, an error is found, or we timeout.
Returns True if the ktserver is now running, False if something went wrong."""
success = False
for i in xrange(createTimeout):
if isKtServerFailed(logPath):
logger.critical('Error starting ktserver.')
success = False
break
if isKtServerRunning(logPath):
logger.info('Ktserver running.')
success = True
break
sleep(1)
return success
def run(self, fileStore):
logger.info("Chunk IDs: %s" % self.chunkIDs)
#Avoid compression if just one chunk
self.blastOptions.compressFiles = self.blastOptions.compressFiles and len(self.chunkIDs) > 2
resultsIDs = []
for i in xrange(len(self.chunkIDs)):
resultsIDs.append(self.addChild(RunSelfBlast(self.blastOptions, self.chunkIDs[i])).rv())
logger.info("Made the list of self blasts")
#Setup job to make all-against-all blasts
logger.debug("Collating self blasts.")
logger.info("Blast file IDs: %s" % resultsIDs)
return self.addFollowOn(CollateBlasts(self.blastOptions, resultsIDs)).rv()
toilStats=False,
maxThreads=None,
maxCpus=None,
defaultMemory=None,
logFile=None,
intermediateResultsUrl=None,
extraToilArgumentsString=""):
args = ["--experiment", experimentFile] + _fn(toilDir,
logLevel, retryCount, batchSystem, rescueJobFrequency,
buildAvgs, buildReference, buildHal, buildFasta, toilStats, maxThreads, maxCpus, defaultMemory, logFile)
if intermediateResultsUrl is not None:
args += ["--intermediateResultsUrl", intermediateResultsUrl]
import cactus.pipeline.cactus_workflow as cactus_workflow
cactus_workflow.runCactusWorkflow(args)
logger.info("Ran the cactus workflow okay")
configNode = ET.parse(configFile).getroot()
workFlowArgs = CactusWorkflowArguments(self.options, experimentFile=experimentFile, configNode=configNode, seqIDMap = seqIDMap)
# copy over the options so we don't trail them around
workFlowArgs.buildHal = self.options.buildHal
workFlowArgs.buildFasta = self.options.buildFasta
workFlowArgs.globalLeafEventSet = self.options.globalLeafEventSet
if self.options.intermediateResultsUrl is not None:
# Give the URL prefix a special name for this particular
# subproblem (by suffixing it with the name of the
# internal node in the guide tree)
workFlowArgs.intermediateResultsUrl = self.options.intermediateResultsUrl + '-' + self.event
# Use the trimming strategy to blast ingroups vs outgroups.
finalExpWrapper = self.addChild(CactusTrimmingBlastPhase(cactusWorkflowArguments=workFlowArgs, phaseName="trimBlast")).rv()
logger.info("Going to create alignments and define the cactus tree")
return finalExpWrapper
phylogenyCostPerLossPerBase=self.getOptionalPhaseAttrib("phylogenyCostPerLossPerBase"),
referenceEventHeader=exp.getRootGenome(),
phylogenyDoSplitsWithSupportHigherThanThisAllAtOnce=self.getOptionalPhaseAttrib("phylogenyDoSplitsWithSupportHigherThanThisAllAtOnce"),
numTreeBuildingThreads=self.getOptionalPhaseAttrib("numTreeBuildingThreads"),
doPhylogeny=self.getOptionalPhaseAttrib("doPhylogeny", bool, False),
minimumBlockHomologySupport=self.getOptionalPhaseAttrib("minimumBlockHomologySupport"),
minimumBlockDegreeToCheckSupport=self.getOptionalPhaseAttrib("minimumBlockDegreeToCheckSupport"),
phylogenyNucleotideScalingFactor=self.getOptionalPhaseAttrib("phylogenyNucleotideScalingFactor"),
removeRecoverableChains=self.getOptionalPhaseAttrib("removeRecoverableChains"),
minimumNumberOfSpecies=self.getOptionalPhaseAttrib("minimumNumberOfSpecies", int),
phylogenyHomologyUnitType=self.getOptionalPhaseAttrib("phylogenyHomologyUnitType"),
phylogenyDistanceCorrectionMethod=self.getOptionalPhaseAttrib("phylogenyDistanceCorrectionMethod"),
maxRecoverableChainsIterations=self.getOptionalPhaseAttrib("maxRecoverableChainsIterations", int),
maxRecoverableChainLength=self.getOptionalPhaseAttrib("maxRecoverableChainLength", int))
for message in messages:
logger.info(message)
buildHal=None,
buildFasta=None,
buildAvgs=False,
toilStats=False,
maxThreads=None,
maxCpus=None,
logFile=None,
defaultMemory=None):
command = ["cactus_progressive.py", "--project", inputDir] + _fn(toilDir,
logLevel, retryCount, batchSystem, rescueJobFrequency,
buildAvgs, None,
buildHal,
buildFasta,
toilStats, maxThreads, maxCpus, defaultMemory, logFile)
system(command)
logger.info("Ran the cactus progressive okay")
# note that we copy the path into the options here
experimentFile = fileStore.readGlobalFile(self.project.expIDMap[self.event])
expXml = ET.parse(experimentFile).getroot()
experiment = ExperimentWrapper(expXml)
configPath = fileStore.readGlobalFile(experiment.getConfigID())
configXml = ET.parse(configPath).getroot()
seqIDMap = dict()
tree = experiment.getTree()
seqNames = []
for node in tree.postOrderTraversal():
name = tree.getName(node)
if tree.isLeaf(node) or (name == experiment.getRootGenome() and experiment.isRootReconstructed() == False):
seqIDMap[name] = self.project.outputSequenceIDMap[name]
seqNames.append(name)
logger.info("Sequences in progressive, %s: %s" % (self.event, seqNames))
experimentFile = fileStore.getLocalTempFile()
experiment.writeXML(experimentFile)
self.options.experimentFileID = fileStore.writeGlobalFile(experimentFile)
# take union of command line options and config options for hal and reference
halNode = findRequiredNode(configXml, "hal")
if self.options.buildHal == False:
self.options.buildHal = getOptionalAttrib(halNode, "buildHal", bool, False)
if self.options.buildFasta == False:
self.options.buildFasta = getOptionalAttrib(halNode, "buildFasta", bool, False)
# get parameters that cactus_workflow stuff wants
configFile = fileStore.readGlobalFile(experiment.getConfigID())
configNode = ET.parse(configFile).getroot()
workFlowArgs = CactusWorkflowArguments(self.options, experimentFile=experimentFile, configNode=configNode, seqIDMap = seqIDMap)
def runCactusCheck(cactusDiskDatabaseString,
flowerNames=encodeFlowerNames((0,)),
logLevel=None,
recursive=False,
checkNormalised=False):
logLevel = getLogLevelString2(logLevel)
args = ["--cactusDisk", cactusDiskDatabaseString, "--logLevel", logLevel]
if recursive:
args += ["--recursive"]
if checkNormalised:
args += ["--checkNormalised"]
cactus_call(stdin_string=flowerNames,
parameters=["cactus_check"] + args)
logger.info("Ran cactus check")