def RootAllTrees(): import tree speciesIDs = util.FirstWordExtractor("SpeciesIDs.txt").GetIDToNameDict() species_tree_rooted = tree.Tree("SpeciesTree_ids_0_rooted_unresolved.txt") GeneToSpecies = GeneToSpecies_dash for fn in glob.glob("Trees_ids/OG*txt"): print("*** " + fn + " ***") t = tree.Tree(fn) root = GetRoot(t, species_tree_rooted, GeneToSpecies) if root == None: print("Fail: " + fn) else: if root != t: t.set_outgroup(root) for n in t: n.name = speciesIDs[n.name.split("_")[0]] t.write(outfile="Trees_ids_rooted/" + os.path.split(fn)[1]) util.Success()
parser.add_argument("trees_dir") parser.add_argument("rooted_species_tree") # parser.add_argument("-p", "--prune", action='store_true') parser.add_argument("-s", "--separator", choices=("dot", "dash", "second_dash", "3rd_dash", "hyphen"), help="Separator been species name and gene name in gene tree taxa") args = parser.parse_args() output_dir = os.path.split(args.trees_dir)[0] qSingleTree = False try: tree_lib.Tree(args.trees_dir) qSingleTree = True print("Analysing single tree") except: try: tree = tree_lib.Tree(args.trees_dir) qSingleTree = True except: pass if not os.path.exists(output_dir): os.mkdir(output_dir) GeneToSpecies = GetGeneToSpeciesMap(args) output_dir = output_dir + "/../Orthologues_M3/" print(output_dir) if not os.path.exists(output_dir): os.mkdir(output_dir) # GetOrthologuesStandalone_Parallel(args.trees_dir, args.rooted_species_tree, GeneToSpecies, output_dir, qSingleTree) GetOrthologuesStandalone_Serial(args.trees_dir, args.rooted_species_tree, GeneToSpecies, output_dir, qSingleTree) # RootTreeStandalone_Serial(args.trees_dir, args.rooted_species_tree, GeneToSpecies, output_dir, qSingleTree) util.Success()