mirror of
https://github.com/biopython/biopython.git
synced 2025-10-20 21:53:47 +08:00
bug fix handle NoneType when writing to newick with branch_length_only=True
added test for phyloxml -> newick with branch_length_only=True Peter: This is a rebased version of pull request #552.
This commit is contained in:
committed by
Peter J. A. Cock
parent
aea4f9988e
commit
b6f74f2f71
@ -357,7 +357,7 @@ class Writer:
|
||||
# write only branchlengths, ignore support
|
||||
def make_info_string(clade, terminal=False):
|
||||
return (
|
||||
":" + format_branch_length % clade.branch_length
|
||||
":" + format_branch_length % (clade.branch_length or 0.0)
|
||||
) + _get_comment(clade)
|
||||
|
||||
else:
|
||||
|
@ -164,6 +164,18 @@ class IOTests(unittest.TestCase):
|
||||
os.remove(tmp_filename)
|
||||
self.assertEqual(14, count)
|
||||
|
||||
def test_convert_phyloxml_to_newick_branch_length_only(self):
|
||||
"""Write phyloxml with bootstrap values to newick format using branch_length_only=True"""
|
||||
trees = Phylo.parse(EX_APAF, "phyloxml")
|
||||
tmp_filename = tempfile.mktemp()
|
||||
|
||||
try:
|
||||
Phylo.write(trees, tmp_filename, "newick", branch_length_only=True)
|
||||
os.remove(tmp_filename)
|
||||
|
||||
except TypeError:
|
||||
self.fail()
|
||||
|
||||
def test_int_labels(self):
|
||||
"""Read newick formatted tree with numeric labels."""
|
||||
tree = Phylo.read(
|
||||
|
Reference in New Issue
Block a user