Skip to content
Browse files

Only surround a label with quotes if the label is not empty.

  • Loading branch information...
1 parent 83f824a commit b484b714f4b618fe9279244bc64cf40b2e513251 @bendmorris bendmorris committed with etal Feb 15, 2013
Showing with 4 additions and 3 deletions.
  1. +4 −3 Bio/Phylo/NewickIO.py
View
7 Bio/Phylo/NewickIO.py
@@ -251,9 +251,10 @@ def to_strings(self, confidence_as_branch_length=False,
def newickize(clade):
"""Convert a node tree to a Newick tree string, recursively."""
label = clade.name or ''
- unquoted_label = re.match(token_dict['unquoted node label'], label)
- if (not unquoted_label) or (unquoted_label.end() < len(label)):
- label = "'%s'" % label.replace("'", "\\'")
+ if label:
+ unquoted_label = re.match(token_dict['unquoted node label'], label)
+ if (not unquoted_label) or (unquoted_label.end() < len(label)):
+ label = "'%s'" % label.replace('\\', '\\\\').replace("'", "\\'")
if clade.is_terminal(): # terminal
return (label

0 comments on commit b484b71

Please sign in to comment.
Something went wrong with that request. Please try again.