import sys import parameters, genbank, trees, genomes, scores, families, islands if __name__ == "__main__": paramFN = sys.argv[1] paramD = parameters.loadParametersD(paramFN) ## load data structures we'll use below tree, strainStr2NumD, strainNum2StrD = trees.readTree(paramD['treeFN']) # an object for gene name conversions geneNames = genomes.geneNames(paramD['geneOrderFN'], strainStr2NumD, strainNum2StrD) subtreeL = trees.createSubtreeL(tree) subtreeL.sort() geneOrderT = genomes.createGeneOrderTs(paramD['geneOrderFN'], geneNames, subtreeL, strainStr2NumD) ## read scores scoresO = scores.readScores(paramD['scoresFN'], geneNames) ## make gene families familyIslandFormationSummaryF = open( paramD['familyIslandFormationSummaryFN'], 'w') familyL = families.families( tree, subtreeL, geneNames, scoresO, paramD['minNormThresh'], paramD['minCoreSynThresh'], paramD['minSynThresh'], paramD['synAdjustThresh'], paramD['synAdjustExtent'], paramD['familyFN'], strainNum2StrD, familyIslandFormationSummaryF)
else: value = L[1] D[gene] = value return D ## main #TODO: proper CLI if __name__ == "__main__": speciesTreeFN = sys.argv[1] geneTreeFN = sys.argv[2] # load stuff speciesTree = trees.readTree(speciesTreeFN) geneTree = trees.loadOneGeneTree(geneTreeFN) bigTipMapD = loadD("tipMap.tsv") tipMapD = {} # cut down to those in this gene tree for leaf in trees.leafList(geneTree): tipMapD[leaf] = bigTipMapD[leaf] locusMapD = loadD("locusMap.tsv") gtLocusMapD = familiesDTLORstuff.reduceLocusMap(geneTree, locusMapD) locusMapForRootingD = trees.createLocusMapForRootingD( geneTree, copy.deepcopy(gtLocusMapD)) argT = (speciesTree, geneTree, tipMapD, gtLocusMapD, locusMapForRootingD, D, T, L, O, R)
for strain in s.split('\t')[1].split(','): nodes.append(int(strainStr2NumD[strain])) if strain not in uniqueStrains: uniqueStrains.append(strain) nodesLL.append(nodes) return nodesLL,uniqueStrains if __name__ == "__main__": #loading parameters from command line that will be used below paramFN=sys.argv[1] paramD = parameters.loadParametersD(paramFN) strainStr = sys.argv[2] validationFile = sys.argv[3] minGenes = int(sys.argv[4]) tree,strainStr2NumD,strainNum2StrD = trees.readTree(paramD['treeFN']) strainNum = strainStr2NumD[strainStr] #node = strainStr2NumD[strainStr] # load islands and genes islandByNodeL=islands.readIslands(paramD['islandOutFN'],tree,strainStr2NumD) geneNames = genomes.geneNames(paramD['geneOrderFN'],strainStr2NumD,strainNum2StrD) subtreeL=trees.createSubtreeL(tree) subtreeL.sort() geneOrderT=genomes.createGeneOrderTs(paramD['geneOrderFN'],geneNames,subtreeL,strainStr2NumD)
}, { 'no surfacing': { 0: 'no', 1: { 'flippers': { 0: { 'head': { 0: 'no', 1: 'yes' } }, 1: 'no' } } } }] return listOfTrees[i] if __name__ == "__main__": # createNode() dataSet = [[1, 1, 2, 'y'], [1, 1, 3, 'y'], [0, 1, 2, 'n'], [1, 0, 3, 'n'], [1, 0, 2, 'n'], [1, 1, 0, 'm']] # tree = trees.createTree(dataSet, ['A', 'B', 'C']) # 将构建的树直接放在这里, 减少测试时间 # tree = {'C': {0: 'm', 2: {'A': {0: 'n', 1: {'B': {0: 'n', 1: 'y'}}}}, 3: {'B': {0: 'n', 1: 'y'}}}} # print(getTreeDepth(tree)) # print(tree) tree = trees.readTree('forshow') createPlot(tree)