donovan-h-parks / PhyloRank

Assign taxonomic ranks based on evolutionary divergence.
GNU General Public License v3.0
21 stars 4 forks source link

fix an issue where none labeled nodes would fail #12

Closed aaronmussig closed 4 years ago

aaronmussig commented 4 years ago

When writing to the reference tree... possibly a DendroPy issue with the tree input format.

Automatic line formatting went a bit out of control there. Line 834 is the only change:

From:

            if n.is_leaf():
                n.taxon.label += "|RED={:.3f}".format(red)
            else:
                n.label += "|RED={:.3f}".format(red)

To:

            red_str = "|RED={:.3f}".format(red)
            if n.is_leaf():
                n.taxon.label += red_str
            else:
                if n.label:
                    n.label += red_str
                else:
                    n.label = red_str
Unexpected error: <class 'TypeError'>
Traceback (most recent call last):
  File "/srv/sw/miniconda3/envs/phylorank-0.1.3/bin/phylorank", line 360, in <module>
    parser.parse_options(args)
  File "/srv/sw/miniconda3/envs/phylorank-0.1.3/lib/python3.8/site-packages/phylorank/main.py", line 484, in parse_options
    self.outliers(options)
  File "/srv/sw/miniconda3/envs/phylorank-0.1.3/lib/python3.8/site-packages/phylorank/main.py", line 75, in outliers
    o.run(options.input_tree,
  File "/srv/sw/miniconda3/envs/phylorank-0.1.3/lib/python3.8/site-packages/phylorank/outliers.py", line 1121, in run
    self._write_rd_tree(orig_tree, rel_node_dists, output_rd_tree)
  File "/srv/sw/miniconda3/envs/phylorank-0.1.3/lib/python3.8/site-packages/phylorank/outliers.py", line 834, in _write_rd_tree
    n.label += "|RED={:.3f}".format(red)
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'
donovan-h-parks commented 4 years ago

Thanks Aaron. Fix seems good to me. Not sure how this hasn't been an issue previously, so indeed is maybe a change to have DendroPy initialized the label properties of nodes (i.e. set to None instead of an empty string)