def raxml( logfile, fastafile, bootstrap=False, threads=2, name_conversion=None, phylipize=False, verbalise=lambda *a: None, ): if phylipize: alignment = internal.make_phylip(fastafile, logfile) else: alignment = fastafile print "phylip done" if bootstrap: raxml_best = raxml_phylogeny(alignment, logfile, bootstrap=False, threads=threads) raxml_bstrap = raxml_phylogeny(alignment, logfile, bootstrap=bootstrap, threads=threads) raxml_final = apply_boostrap(raxml_best, raxml_bstrap, logfile) verbalise( "Y", "Best tree with bootstrap support can be found at %s" % raxml_final) else: print "Starting raxml" raxml_final = raxml_phylogeny(alignment, logfile, bootstrap=bootstrap, threads=threads) verbalise("Y", "Best tree can be found at %s" % raxml_final) if name_conversion: handle = open(name_conversion, 'rb') conv_dic = { line.split()[0]: (line.split()[2], line.split()[1]) for line in handle } handle.close() internal.rename_newick(raxml_final, conversiondic=conv_dic) return raxml_final
def raxml(logfile, fastafile, bootstrap=False, threads=2, name_conversion=None, phylipize=False, verbalise=lambda *a: None, ): if phylipize: alignment = internal.make_phylip(fastafile, logfile) else: alignment = fastafile print "phylip done" if bootstrap: raxml_best = raxml_phylogeny(alignment, logfile, bootstrap=False, threads=threads) raxml_bstrap = raxml_phylogeny(alignment, logfile, bootstrap=bootstrap, threads=threads) raxml_final = apply_boostrap(raxml_best, raxml_bstrap, logfile) verbalise("Y", "Best tree with bootstrap support can be found at %s" % raxml_final) else: print "Starting raxml" raxml_final = raxml_phylogeny(alignment, logfile, bootstrap=bootstrap, threads=threads) verbalise("Y", "Best tree can be found at %s" % raxml_final) if name_conversion: handle = open(name_conversion, 'rb') conv_dic = { line.split()[0]:(line.split()[2], line.split()[1]) for line in handle } handle.close() internal.rename_newick(raxml_final, conversiondic=conv_dic) return raxml_final
mafft_alignment = logfile[:-3] + 'mafft.fa' external.mafft_align(homolog_fasta, mafft_alignment) internal.display_alignment(mafft_alignment, conversiondic=conv_dic, outfile=logfile[:-3] + 'mafft.png', showplot=args.display_on, gapthresh=args.gapthresh) ######### RaXML phylogenetic analysis of alignment ######### """ Using PROT-LG-GAMMA model, a single tree and no bootstrapping (though all of these could be setup to allow overriding for fringe case analyses). """ verbalise("B", "Running RAxML analysis to construct phylogeny") final_tree = external.raxml(logfile, mafft_alignment, bootstrap=args.bootstrap, threads=args.threads, name_conversion=None, verbalise=verbalise) raxml_renamed = internal.rename_newick(final_tree, conversiondic=conv_dic) # clean up temp files and directory for file in [ homolog_fasta, ]: if os.path.exists(file): os.remove(file) os.rmdir(temp_dir) # dir must be empty!
internal.display_alignment( mafft_alignment, conversiondic=conv_dic, outfile=logfile[:-3] + "mafft.png", showplot=args.display_on, gapthresh=args.gapthresh, ) ######### RaXML phylogenetic analysis of alignment ######### """ Using PROT-LG-GAMMA model, a single tree and no bootstrapping (though all of these could be setup to allow overriding for fringe case analyses). """ verbalise("B", "Running RAxML analysis to construct phylogeny") final_tree = external.raxml( logfile, mafft_alignment, bootstrap=args.bootstrap, threads=args.threads, name_conversion=None, verbalise=verbalise, ) raxml_renamed = internal.rename_newick(final_tree, conversiondic=conv_dic) # clean up temp files and directory for file in [homolog_fasta]: if os.path.exists(file): os.remove(file) os.rmdir(temp_dir) # dir must be empty!