Ejemplo n.º 1
0
    def writeXml(self):
        assert os.path.isdir(self.workingDir)
        configPath = absSymPath(
            os.path.join(self.workingDir, "config.xml"))
        expPath = absSymPath(
            os.path.join(self.workingDir, "expTemplate.xml"))
        self.expWrapper.setConfigPath(configPath)
        self.configWrapper.writeXML(configPath)
        self.expWrapper.writeXML(expPath)

        projPath = os.path.join(self.workingDir,
                                ProjectWrapper.alignmentDirName)
        if os.path.exists(projPath) and self.options.overwrite:
            system("rm -rf %s" % projPath)
        if self.options.outputMaf is True:
            fixNames=1
        else:
            fixNames=0
        if os.path.exists(projPath):
           if not self.isSameAsExisting(expPath, projPath, fixNames):
               raise RuntimeError("Existing project %s not " % projPath+
                                  "compatible with current input.  Please "
                                  "erase the working directory or rerun "
                                  "with the --overwrite option to start "
                                  "from scratch.")
           else:
               logPath = os.path.join(self.workingDir, 'cactus.log')
               logFile = open(logPath, "a")
               logFile.write("\nContinuing existing alignment.  Use "
                             "--overwrite or erase the working directory to "
                             "force restart from scratch.\n")
               logFile.close()
        else:
            cmd = "cactus_createMultiCactusProject.py \"%s\" \"%s\" --fixNames=%d" % (
                expPath, projPath, fixNames)
            if len(self.seqFile.outgroups) > 0: 
                cmd += " --outgroupNames " + ",".join(self.seqFile.outgroups)
            if self.options.rootOutgroupDists:
                cmd += " --rootOutgroupDists %s" % self.options.rootOutgroupDists
                cmd += " --rootOutgroupPaths %s" % self.options.rootOutgroupPaths
            if self.options.root is not None:
                cmd += " --root %s" % self.options.root
            system(cmd)
Ejemplo n.º 2
0
    def writeXml(self):
        assert os.path.isdir(self.workingDir)
        configPath = absSymPath(os.path.join(self.workingDir, "config.xml"))
        expPath = absSymPath(os.path.join(self.workingDir, "expTemplate.xml"))
        self.expWrapper.setConfigPath(configPath)
        self.configWrapper.writeXML(configPath)
        self.expWrapper.writeXML(expPath)

        projPath = os.path.join(self.workingDir,
                                ProjectWrapper.alignmentDirName)
        if len(self.seqFile.outgroups) == 0:
            # No outgroups specified, assume the default outgroup set
            outgroups = None
        else:
            outgroups = self.seqFile.outgroups
        runCreateMultiCactusProject(expPath,
                                    projPath,
                                    outgroupNames=outgroups,
                                    root=self.options.root)
Ejemplo n.º 3
0
    def writeXml(self):
        assert os.path.isdir(self.workingDir)
        configPath = absSymPath(
            os.path.join(self.workingDir, "config.xml"))
        expPath = absSymPath(
            os.path.join(self.workingDir, "expTemplate.xml"))
        self.expWrapper.setConfigPath(configPath)
        self.configWrapper.writeXML(configPath)
        self.expWrapper.writeXML(expPath)

        projPath = os.path.join(self.workingDir,
                                ProjectWrapper.alignmentDirName)
        if len(self.seqFile.outgroups) == 0:
            # No outgroups specified, assume the default outgroup set
            outgroups = None
        else:
            outgroups = self.seqFile.outgroups
        runCreateMultiCactusProject(expPath, projPath, fixNames=0,
                                    outgroupNames=outgroups,
                                    root=self.options.root)
Ejemplo n.º 4
0
 def toXMLElement(self):
     assert self.tree is not None
     elem = ET.Element("cactus_workflow_experiment")
     seqString = ""
     for node in self.tree.postOrderTraversal():
         if self.tree.isLeaf(node):
             name = self.tree.getName(node)
             path = self.pathMap[name]
             path.replace(" ", "\ ")
             seqString += absSymPath(path) + " "
     elem.attrib["sequences"] = seqString
     elem.attrib["species_tree"] = NXNewick().writeString(self.tree)
     elem.attrib["config"] = "defaultProgressive"
     return elem
Ejemplo n.º 5
0
 def toXMLElement(self):
     assert self.tree is not None
     elem = ET.Element("cactus_workflow_experiment")
     seqString = ""
     for node in self.tree.postOrderTraversal():
         if self.tree.isLeaf(node):
             name = self.tree.getName(node)
             path = self.pathMap[name]
             path.replace(" ", "\ ")
             seqString += absSymPath(path) + " "
     elem.attrib["sequences"] = seqString
     elem.attrib["species_tree"] = NXNewick().writeString(self.tree)
     elem.attrib["config"] = "defaultProgressive"
     return elem
Ejemplo n.º 6
0
 def startJobTree(self, options):
     """Runs jobtree using the given options (see Stack.getDefaultOptions
     and Stack.addJobTreeOptions).
     """
     self.verifyJobTreeOptions(options)
     setLoggingFromOptions(options)
     options.jobTree = absSymPath(options.jobTree)
     if os.path.isdir(options.jobTree):
         config, batchSystem = reloadJobTree(options.jobTree)
     else:
         config, batchSystem = createJobTree(options)
         #Setup first job.
         command = self.makeRunnable(options.jobTree)
         memory = self.getMemory()
         cpu = self.getCpu()
         createFirstJob(command, config, memory=memory, cpu=cpu)
     loadEnvironment(config)
     return mainLoop(config, batchSystem)
Ejemplo n.º 7
0
 def startJobTree(self, options):
     """Runs jobtree using the given options (see Stack.getDefaultOptions
     and Stack.addJobTreeOptions).
     """
     self.verifyJobTreeOptions(options)
     setLoggingFromOptions(options)
     options.jobTree = absSymPath(options.jobTree)
     if os.path.isdir(options.jobTree):
         config, batchSystem = reloadJobTree(options.jobTree)
     else:
         config, batchSystem = createJobTree(options)
         #Setup first job.
         command = self.makeRunnable(options.jobTree)
         memory = self.getMemory()
         cpu = self.getCpu()
         createFirstJob(command, config, memory=memory, cpu=cpu)
     loadEnvironment(config)
     return mainLoop(config, batchSystem)
Ejemplo n.º 8
0
def createJobTree(options):
    logger.info("Starting to create the job tree setup for the first time")
    options.jobTree = absSymPath(options.jobTree)
    os.mkdir(options.jobTree)
    os.mkdir(getJobFileDirName(options.jobTree))
    config = ET.Element("config")
    config.attrib["log_level"] = getLogLevelString()
    config.attrib["job_tree"] = options.jobTree
    config.attrib["parasol_command"] = options.parasolCommand
    config.attrib["try_count"] = str(int(options.retryCount) + 1)
    config.attrib["max_job_duration"] = str(float(options.maxJobDuration))
    config.attrib["batch_system"] = options.batchSystem
    config.attrib["job_time"] = str(float(options.jobTime))
    config.attrib["max_log_file_size"] = str(int(options.maxLogFileSize))
    config.attrib["default_memory"] = str(int(options.defaultMemory))
    config.attrib["default_cpu"] = str(int(options.defaultCpu))
    config.attrib["max_cpus"] = str(int(options.maxCpus))
    config.attrib["max_memory"] = str(int(options.maxMemory))
    config.attrib["max_threads"] = str(int(options.maxThreads))
    if options.bigBatchSystem != None:
        config.attrib["big_batch_system"] = options.bigBatchSystem
        config.attrib["big_memory_threshold"] = str(
            int(options.bigMemoryThreshold))
        config.attrib["big_cpu_threshold"] = str(int(options.bigCpuThreshold))
        config.attrib["big_max_cpus"] = str(int(options.bigMaxCpus))
        config.attrib["big_max_memory"] = str(int(options.bigMaxMemory))

    if options.stats:
        config.attrib["stats"] = ""
    #Load the batch system.
    batchSystem = loadTheBatchSystem(config, options)
    logger.info("Loaded the batch system %s" % batchSystem)

    #Set the parameters determining the polling frequency of the system.
    config.attrib["rescue_jobs_frequency"] = str(
        float(batchSystem.getRescueJobFrequency()))
    if options.rescueJobsFrequency != None:
        config.attrib["rescue_jobs_frequency"] = str(
            float(options.rescueJobsFrequency))

    writeConfig(config)

    logger.info("Finished the job tree setup")
    return config, batchSystem
Ejemplo n.º 9
0
def main():
    usage = "usage: %prog <project xml path>"
    description = "Update the _project.xml and _experiment.xml files to use current directory structure"
    parser = OptionParser(usage=usage, description=description)
    
    options, args = parser.parse_args()
    
    if len(args) != 1:
        parser.print_help()
        raise RuntimeError("Wrong number of arguments")
    
    path = absSymPath(args[0])
    
    if not os.path.isfile(path):
        raise RuntimeError("Project file %s not found\n" % path)
    
    system("cp %s %s.old" %(path, path))
    updateProject(path)
    
    return 0
Ejemplo n.º 10
0
def createJobTree(options):
    logger.info("Starting to create the job tree setup for the first time")
    options.jobTree = absSymPath(options.jobTree)
    os.mkdir(options.jobTree)
    os.mkdir(getJobFileDirName(options.jobTree))
    config = ET.Element("config")
    config.attrib["log_level"] = getLogLevelString()
    config.attrib["job_tree"] = options.jobTree
    config.attrib["parasol_command"] = options.parasolCommand
    config.attrib["try_count"] = str(int(options.retryCount) + 1)
    config.attrib["max_job_duration"] = str(float(options.maxJobDuration))
    config.attrib["batch_system"] = options.batchSystem
    config.attrib["job_time"] = str(float(options.jobTime))
    config.attrib["max_log_file_size"] = str(int(options.maxLogFileSize))
    config.attrib["default_memory"] = str(int(options.defaultMemory))
    config.attrib["default_cpu"] = str(int(options.defaultCpu))
    config.attrib["max_cpus"] = str(int(options.maxCpus))
    config.attrib["max_memory"] = str(int(options.maxMemory))
    config.attrib["max_threads"] = str(int(options.maxThreads))
    if options.bigBatchSystem != None:
        config.attrib["big_batch_system"] = options.bigBatchSystem
        config.attrib["big_memory_threshold"] = str(int(options.bigMemoryThreshold))
        config.attrib["big_cpu_threshold"] = str(int(options.bigCpuThreshold))
        config.attrib["big_max_cpus"] = str(int(options.bigMaxCpus))
        config.attrib["big_max_memory"] = str(int(options.bigMaxMemory))
        
    if options.stats:
        config.attrib["stats"] = ""
    #Load the batch system.
    batchSystem = loadTheBatchSystem(config)
    
    #Set the parameters determining the polling frequency of the system.  
    config.attrib["rescue_jobs_frequency"] = str(float(batchSystem.getRescueJobFrequency()))
    if options.rescueJobsFrequency != None:
        config.attrib["rescue_jobs_frequency"] = str(float(options.rescueJobsFrequency))
    
    writeConfig(config)
    
    logger.info("Finished the job tree setup")
    return config, batchSystem