def createFileStructure(mcProj, expTemplate, configTemplate, options): if not os.path.exists(options.path): os.makedirs(options.path) mcProj.writeXML(os.path.join(options.path, "%s_project.xml" % options.name)) seqMap = expTemplate.seqMap portOffset = 0 for name, expPath in mcProj.expMap.items(): path = os.path.join(options.path, name) seqMap[name] = os.path.join(path, name + '.fa') for name, expPath in mcProj.expMap.items(): path = os.path.join(options.path, name) children = mcProj.entireTree.getChildNames(name) exp = copy.deepcopy(expTemplate) # Get outgroups outgroups = [] if configTemplate.getOutgroupStrategy() != 'none' \ and name in mcProj.outgroup.ogMap: for og, ogDist in mcProj.outgroup.ogMap[name]: if og in seqMap: ogPath = seqMap[og] else: ogPath = os.path.join(options.path, og) ogPath = os.path.join(ogPath, refFileName(og)) seqMap[og] = ogPath outgroups += [og] # Get subtree connecting children + outgroups assert len(children) > 0 subtree = mcProj.entireTree.extractSpanningTree(children + outgroups) dbBase = path if expTemplate.getDbDir() is not None: dbBase = os.path.abspath(expTemplate.getDbDir()) exp.setDbDir(os.path.join(dbBase, name, "%s_DB" % name)) if expTemplate.getDbType() == "kyoto_tycoon" and \ os.path.splitext(name)[1] != ".kch": exp.setDbName("%s.kch" % name) else: exp.setDbName(name) if expTemplate.getDbType() == "kyoto_tycoon": exp.setDbPort(expTemplate.getDbPort() + portOffset) portOffset += 1 host = expTemplate.getDbHost() if host is not None: exp.setDbHost(host) exp.setReferencePath(os.path.join(path, name + '.fa')) if configTemplate.getBuildHal() == True: exp.setHALPath(os.path.join(path, "%s_hal.c2h" % name)) if configTemplate.getBuildFasta() == True: exp.setHALFastaPath(os.path.join(path, "%s_hal.fa" % name)) exp.updateTree(subtree, seqMap, outgroups) exp.setConfigPath(os.path.join(path, "%s_config.xml" % name)) if not os.path.exists(exp.getDbDir()): os.makedirs(exp.getDbDir()) if not os.path.exists(path): os.makedirs(path) exp.writeXML(expPath) config = ConfigWrapper(copy.deepcopy(configTemplate.xmlRoot)) config.setReferenceName(name) config.verifyMinBlockDegree(exp) config.writeXML(exp.getConfigPath())