Skip to content

Commit 35ada75

Browse files
authored
Merge pull request #37 from evogytis/newick-parse
Add assertions for newick string formats
2 parents 5ddbc5f + bb01009 commit 35ada75

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

baltic/baltic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,10 @@ def make_tree(data,ll=None,verbose=False):
18231823
if isinstance(data,str)==False: ## tree string is not an instance of string (could be unicode) - convert
18241824
data=str(data)
18251825

1826+
# Add in some checks that the data are in correct format
1827+
assert data.endswith(";"), "Improperly formatted string: must end in semicolon"
1828+
assert data.count("(")==data.count(")"), "Improperly formatted string: must have matching parentheses"
1829+
18261830
if ll==None: ## calling without providing a tree object - create one
18271831
ll=tree()
18281832
i=0 ## is an adjustable index along the tree string, it is incremented to advance through the string

0 commit comments

Comments
 (0)