Skip to content

Malformed skbio.TreeNode object has broken copy function #54

Open
@mortonjt

Description

@mortonjt

This is a weird issue.

from bp import to_skbio_treenode, parse_newick
tree = parse_newick(open('16S_taxa.biom.nwk').read())
tree.copy()

yields the following error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[10], line 1
----> 1 sktree.copy()

File ~/miniconda3/envs/dynomics/lib/python3.9/site-packages/skbio/tree/_tree.py:514, in TreeNode.copy(self)
    511             result.__dict__[key] = deepcopy(node_to_copy.__dict__[key])
    512     return result
--> 514 root = __copy_node(self)
    515 nodes_stack = [[root, self, len(self.children)]]
    517 while nodes_stack:
    518     # check the top node, any children left unvisited?

File ~/miniconda3/envs/dynomics/lib/python3.9/site-packages/skbio/tree/_tree.py:511, in TreeNode.copy.<locals>.__copy_node(node_to_copy)
    509 for key in node_to_copy.__dict__:
    510     if key not in efc:
--> 511         result.__dict__[key] = deepcopy(node_to_copy.__dict__[key])
    512 return result

File ~/miniconda3/envs/dynomics/lib/python3.9/copy.py:146, in deepcopy(x, memo, _nil)
    144 copier = _deepcopy_dispatch.get(cls)
    145 if copier is not None:
--> 146     y = copier(x, memo)
    147 else:
    148     if issubclass(cls, type):

File ~/miniconda3/envs/dynomics/lib/python3.9/copy.py:237, in _deepcopy_method(x, memo)
    236 def _deepcopy_method(x, memo): # Copy instance methods
--> 237     return type(x)(x.__func__, deepcopy(x.__self__, memo))

File ~/miniconda3/envs/dynomics/lib/python3.9/copy.py:153, in deepcopy(x, memo, _nil)
    151 copier = getattr(x, "__deepcopy__", None)
    152 if copier is not None:
--> 153     y = copier(memo)
    154 else:
    155     reductor = dispatch_table.get(cls)

TypeError: copy() takes 1 positional argument but 2 were given

But running tree = skbio.TreeNode.read('16S_taxa.biom.nwk').copy() doesn't return such an error, hinting at the skbio.TreeNode conversion in this package.

Now, this does not occur in iow==1.0.3 suggesting that this is a recent error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions