Open kamurani opened 1 year ago
`from Bio import AlignIO, Phylo
from Bio.Phylo.TreeConstruction import DistanceCalculator, DistanceTreeConstructor
from ete3 import Tree, TreeStyle, TextFace
import matplotlib.pyplot as plt
# Load the alignment from a file in fasta format
alignment_file = "20cd-hit-clust.fa"
alignment = AlignIO.read(alignment_file, "fasta")
# Построение дерева методом Neighbor Joining
calculator = DistanceCalculator('blosum62')
dm = calculator.get_distance(alignment)
nj_constructor = DistanceTreeConstructor(calculator, 'nj')
tree = nj_constructor.build_tree(alignment)
# Сохранение дерева в файл в формате newick
Phylo.write(tree, "my_tree.newick", "newick")
# Создать объект для вывода дерева в формате newick
ete_tree = Tree(tree.to_newick())
# Создать некорневое дерево и настроить его стиль
ts = TreeStyle()
ts.show_leaf_name = False
ts.mode = "c"
ts.arc_start = -180 # установить начальный угол на -180 градусов, чтобы дерево было некорневым
ts.arc_span = 360
ts.scale = 120 # установить масштаб дерева
ts.branch_vertical_margin = 10 # установить отступ между ветвями
ts.title.add_face(TextFace("Unrooted Tree", fsize=20), column=0) # добавить заголовок дерева
# Вывести некорневое дерево в виде изображения
ete_tree.render("my_tree.png", w=1200, h=800, tree_style=ts)
Traceback (most recent call last):
File "C:\Users\rusla\AppData\Roaming\JetBrains\PyCharmCE2021.2\scratches\unrooted_tree.py", line 97, in
Process finished with exit code 1
Hi,
I ran into the same issue (caused by PyQT5) today. It turned out, that it's not enough to install pyqt with pip. To show what error you actually have you should try to print the error where it's caused and silenced:
#/path/to/lib/pythonx.y/site-packages/ete3/__init__.py
try:
from .treeview.svg_colors import *
from .treeview.main import *
from .treeview.faces import *
from .treeview import faces
from .treeview import layouts
except ImportError as e:
pass
#add e.g.
print(e)
in my case the error message was:
libGL.so.1: cannot open shared object file: No such file or directory
meaning, that I was missing the openGL system library. Maybe you should check wheter this is available on your system:
ldconfig -p | grep libGL
or locate libGL
Bad news is: I did not find a way to install libGL.so via pip or conda, so if you don't have root access to your machine, users might not be able to solve this on their own.
Hi,
not sure what I'm doing wrong, but I am trying to use a minimal example of rendering trees using ete3 version
3.1.2
.I get:
Other instances of this issue mention the need to install
pyqt5
which I did successfully, but did not change the error.Any ideas would be greatly appreciated!