etetoolkit / ete

Python package for building, comparing, annotating, manipulating and visualising trees. It provides a comprehensive API and a collection of command line tools, including utilities to work with the NCBI taxonomy tree.
http://etetoolkit.org
GNU General Public License v3.0
773 stars 216 forks source link

Please provide any working version of ete #684

Closed edikedik closed 1 year ago

edikedik commented 1 year ago

Hello, folks,

I have used your tool previously to draw some trees. Now, coming back to edit some minor things, I can't get it to work.

Firstly, I've tried installing ete3 using your instructions. I'm on Mac OS.

conda install -c etetoolkit ete3 ete_toolchain

which fails with an error

Encountered problems while solving:
  - package ete_toolchain-3.0.0-h73706c9_0 requires pmodeltest 1.4.*, but none of the providers can be installed

Trying to remove ete_toolchain like so

conda install -c etetoolkit ete3

yield this dependency issue

Encountered problems while solving:
  - nothing provides qt 4.8.* needed by pyqt-4.11.4-py27_0

OK, so the recommended way fails due to dependency issues. I tried to install it from conda-forge which has your latest 3.1.2 release. It works, presumably due to upscaling the Pyqt version to PyQt5. However, the simplest example fails with an exception:

from ete3 import Tree

t = Tree( "((a,b),c);" )
t.render('%%inline')

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 4
      1 from ete3 import Tree
      3 t = Tree( "((a,b),c);" )
----> 4 t.render('%%inline')

File ~/conda/miniconda3/envs/ete/lib/python3.11/site-packages/ete3/coretype/tree.py:1392, in TreeNode.render(self, file_name, layout, w, h, tree_style, units, dpi)
   1388     return drawer.get_img(self, w=w, h=h,
   1389                           layout=layout, tree_style=tree_style,
   1390                           units=units, dpi=dpi, return_format=file_name)
   1391 else:
-> 1392     return drawer.render_tree(self, file_name, w=w, h=h,
   1393                             layout=layout, tree_style=tree_style,
   1394                               units=units, dpi=dpi)

File ~/conda/miniconda3/envs/ete/lib/python3.11/site-packages/ete3/treeview/drawer.py:111, in render_tree(t, imgName, w, h, layout, tree_style, header, units, dpi)
    109 scene.addItem(scene.master_item)
    110 if imgName.startswith("%%inline"):
--> 111     imgmap = save(scene, imgName, w=w, h=h, units=units, dpi=dpi)
    112 else:
    113     x_scale, y_scale = save(scene, imgName, w=w, h=h, units=units, dpi=dpi)

File ~/conda/miniconda3/envs/ete/lib/python3.11/site-packages/ete3/treeview/main.py:752, in save(scene, imgName, w, h, dpi, take_region, units)
    750 else:
    751     targetRect = QRectF(0, 0, w, h)
--> 752     ii= QImage(w, h, QImage.Format_ARGB32)
    753     ii.fill(QColor(Qt.white).rgb())
    754     ii.setDotsPerMeterX(dpi / 0.0254) # Convert inches to meters

TypeError: arguments did not match any overloaded call:
  QImage(): too many arguments
  QImage(size: QSize, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(width: int, height: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(data: bytes, width: int, height: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(data: PyQt5.sip.voidptr, width: int, height: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(data: bytes, width: int, height: int, bytesPerLine: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(data: PyQt5.sip.voidptr, width: int, height: int, bytesPerLine: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(xpm: List[str]): argument 1 has unexpected type 'float'
  QImage(fileName: str, format: typing.Optional[str] = None): argument 1 has unexpected type 'float'
  QImage(a0: QImage): argument 1 has unexpected type 'float'
  QImage(variant: Any): too many arguments

Alright, the next thing I try is to install the newest version from GitHub.

git clone https://github.com/etetoolkit/ete.git
mamba install cython
pip install flask flask-cors flask-httpauth flask-restful flask-compress numpy PyQt5
pip install -e ete

It all works fine and, as a result, I get

Successfully installed ete4-4.0.0b0

Again, trying the example above

from ete4 import Tree

t = Tree( "((a,b),c);" )
t.render('%%inline')

I get this error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 from ete4 import Tree
      3 t = Tree( "((a,b),c);" )
      4 t.render('%%inline')

File ~/Projects/ete_sandbox/ete/ete4/__init__.py:8
      6 from .ncbi_taxonomy import *
      7 from .gtdb_taxonomy import *
----> 8 from .coretype.tree import *
      9 from .coretype.seqgroup import *
     10 from .phylo.phylotree import *

File ~/Projects/ete_sandbox/ete/ete4/coretype/tree.pyx:25, in init ete4.coretype.tree()

File ~/Projects/ete_sandbox/ete/ete4/smartview/__init__.py:6
      4 from .renderer.treelayout import TreeLayout
      5 from .renderer.nodestyle import NodeStyle
----> 6 from .renderer.layouts.default_layouts import *
      7 from .renderer import layouts as layout_modules

File ~/Projects/ete_sandbox/ete/ete4/smartview/renderer/layouts/__init__.py:1
----> 1 from . import staple_layouts
      2 from . import context_layouts
      3 from . import evol_events_layouts

File ~/Projects/ete_sandbox/ete/ete4/smartview/renderer/layouts/staple_layouts.py:1
----> 1 import matplotlib as mpl
      2 import numpy as np
      4 from ..treelayout import TreeLayout

ModuleNotFoundError: No module named 'matplotlib'

Alright, after installing Matplotlib with

mamba install -c conda-forge matplotlib

and rerunning the example above I get the same error as with the old ete=3.1.2


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 4
      1 from ete4 import Tree
      3 t = Tree( "((a,b),c);" )
----> 4 t.render('%%inline')

File ~/Projects/ete_sandbox/ete/ete4/coretype/tree.pyx:1375, in ete4.coretype.tree.Tree.render()

File ~/Projects/ete_sandbox/ete/ete4/treeview/drawer.py:72, in render_tree(t, imgName, w, h, layout, tree_style, header, units, dpi)
     70 scene.addItem(scene.master_item)
     71 if imgName.startswith("%%inline"):
---> 72     imgmap = save(scene, imgName, w=w, h=h, units=units, dpi=dpi)
     73 else:
     74     x_scale, y_scale = save(scene, imgName, w=w, h=h, units=units, dpi=dpi)

File ~/Projects/ete_sandbox/ete/ete4/treeview/main.py:711, in save(scene, imgName, w, h, dpi, take_region, units)
    709 else:
    710     targetRect = QRectF(0, 0, w, h)
--> 711     ii= QImage(w, h, QImage.Format_ARGB32)
    712     ii.fill(QColor(Qt.white).rgb())
    713     ii.setDotsPerMeterX(dpi / 0.0254) # Convert inches to meters

TypeError: arguments did not match any overloaded call:
  QImage(): too many arguments
  QImage(size: QSize, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(width: int, height: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(data: bytes, width: int, height: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(data: PyQt5.sip.voidptr, width: int, height: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(data: bytes, width: int, height: int, bytesPerLine: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(data: PyQt5.sip.voidptr, width: int, height: int, bytesPerLine: int, format: QImage.Format): argument 1 has unexpected type 'float'
  QImage(xpm: List[str]): argument 1 has unexpected type 'float'
  QImage(fileName: str, format: typing.Optional[str] = None): argument 1 has unexpected type 'float'
  QImage(a0: QImage): argument 1 has unexpected type 'float'
  QImage(variant: Any): too many arguments

After reading the traceback, I tried replacing the line

ii= QImage(w, h, QImage.Format_ARGB32)
=>
ii= QImage(int(w), int(h), QImage.Format_ARGB32)

Which leads to an error below:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 4
      1 from ete4 import Tree
      3 t = Tree( "((a,b),c);" )
----> 4 t.render('%%inline')

File ~/Projects/ete_sandbox/ete/ete4/coretype/tree.pyx:1375, in ete4.coretype.tree.Tree.render()

File ~/Projects/ete_sandbox/ete/ete4/treeview/drawer.py:72, in render_tree(t, imgName, w, h, layout, tree_style, header, units, dpi)
     70 scene.addItem(scene.master_item)
     71 if imgName.startswith("%%inline"):
---> 72     imgmap = save(scene, imgName, w=w, h=h, units=units, dpi=dpi)
     73 else:
     74     x_scale, y_scale = save(scene, imgName, w=w, h=h, units=units, dpi=dpi)

File ~/Projects/ete_sandbox/ete/ete4/treeview/main.py:714, in save(scene, imgName, w, h, dpi, take_region, units)
    712 # ii= QImage(w, h, QImage.Format_ARGB32)
    713 ii.fill(QColor(Qt.white).rgb())
--> 714 ii.setDotsPerMeterX(dpi / 0.0254) # Convert inches to meters
    715 ii.setDotsPerMeterY(dpi / 0.0254)
    716 pp = QPainter(ii)

TypeError: setDotsPerMeterX(self, a0: int): argument 1 has unexpected type 'float'

Again, I tried casting to the correct type

# ii.setDotsPerMeterX(dpi / 0.0254) # Convert inches to meters
# ii.setDotsPerMeterY(dpi / 0.0254)
ii.setDotsPerMeterX(int(dpi / 0.0254)) # Convert inches to meters
ii.setDotsPerMeterY(int(dpi / 0.0254))

which lead me to the following error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[3], line 4
      1 from ete4 import Tree
      3 t = Tree( "((a,b),c);" )
----> 4 t.render('%%inline')

File ~/Projects/ete_sandbox/ete/ete4/coretype/tree.pyx:1375, in ete4.coretype.tree.Tree.render()

File ~/Projects/ete_sandbox/ete/ete4/treeview/drawer.py:65, in render_tree(t, imgName, w, h, layout, tree_style, header, units, dpi)
     63     n.add_prop("_nid", nid)
     64 scene, img = init_scene(t, layout, tree_style)
---> 65 tree_item, n2i, n2f = render(t, img)
     67 scene.init_values(t, img, n2i, n2f)
     68 tree_item.setParentItem(scene.master_item)

File ~/Projects/ete_sandbox/ete/ete4/treeview/qt4_render.py:212, in render(root_node, img, hide_root)
    209     na_face = faces.AttrFace("name", fsize=10, ftype="Arial", fgcolor="black")
    211 for n in root_node.traverse(is_leaf_fn=_leaf):
--> 212     set_style(n, layout_fn)
    214     if img.show_branch_length:
    215         n.add_face(bl_face, 0, position="branch-top")

File ~/Projects/ete_sandbox/ete/ete4/treeview/qt4_render.py:731, in set_style(n, layout_func)
    726 def set_style(n, layout_func):
    727     #if not isinstance(getattr(n, "img_style", None), NodeStyle):
    728     #    print "Style of", n.name ,"is None"
    729     #    n.set_style()
    730     #    n.img_style = NodeStyle()
--> 731     n.add_prop("_temp_faces", _FaceAreas())
    734     for func in layout_func:
    735         func(n)

File ~/Projects/ete_sandbox/ete/ete4/treeview/main.py:522, in _FaceAreas.__init__(self)
    520 def __init__(self):
    521     for a in FACE_POSITIONS:
--> 522         setattr(self, a, FaceContainer())

File ~/Projects/ete_sandbox/ete/ete4/treeview/main.py:527, in _FaceAreas.__setattr__(self, attr, val)
    525 if attr not in FACE_POSITIONS:
    526     raise AttributeError("Face area [%s] not in %s" %(attr, FACE_POSITIONS) )
--> 527 return super(_FaceAreas, self).__setattr__(attr, val)

TypeError: super(type, obj): obj must be an instance or subtype of type

OK, so, at this point, I gave up.

So, please, dear developers, provide at least a single working version of your tool so that the people like me who relied on it in the past (and cited your work) can at least edit their own code. Thanks for your attention.