Save the phylogenetic tree drawn by Bio.Phylo's draw_ascii function in text format

Since the phylogenetic tree obtained by the draw_ascii function of Biopython was not the return value but the standard output, a memo about how to save it in text format.

from Bio import Phylo
import sys

f = open("output.txt","w")
sys.stdout = f

tree = Phylo.read("****.dnd", "newick")
Phylo.draw_ascii(tree)

sys.stdout.close()
スクリーンショット 2016-12-08 1.06.05.png

I can't think of any particular advantage in preserving the phylogenetic tree drawn in ASCII art ...

Recommended Posts

Save the phylogenetic tree drawn by Bio.Phylo's draw_ascii function in text format
Save the audio data acquired by the browser in wav format on the server
Correct the week set by index in datetime format
Save the graph drawn by pyqtgraph to an image
Have the equation graph of the linear function drawn in Python