def assure_tree(params, tmp_dir='treetime_tmp'): """ Function that attempts to load a tree and build it from the alignment if no tree is provided. """ if params.tree is None: params.tree = os.path.basename(params.aln)+'.nwk' print("No tree given: inferring tree") utils.tree_inference(params.aln, params.tree, tmp_dir = tmp_dir) if os.path.isdir(tmp_dir): shutil.rmtree(tmp_dir) try: tt = TreeAnc(params.tree) except: print("Tree loading/building failed.") return 1 return 0
help='number of mutations/nodes that are printed to screen') parser.add_argument('--verbose', default=1, type=int, help='verbosity of output 0-6') params = parser.parse_args() ########################################################################### ### CHECK FOR TREE, build if not in place ########################################################################### if params.tree is None: from treetime.utils import tree_inference params.tree = os.path.basename(params.aln) + '.nwk' print("No tree given: inferring tree") tmp_dir = 'homoplasy_scanner_tmp_files' tree_inference(params.aln, params.tree, tmp_dir=tmp_dir) if os.path.isdir(tmp_dir): shutil.rmtree(tmp_dir) ########################################################################### ### GTR SET-UP ########################################################################### model = params.gtr gtr_params = params.gtr_params if model == 'infer': gtr = GTR.standard('jc') infer_gtr = True else: infer_gtr = False try: kwargs = {}