Skip to content

Commit 4e2e679

Browse files
committed
added verbose option
can use verbose to suppress/allow program progress to be displayed
1 parent cd527b7 commit 4e2e679

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

phy2html.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,21 @@ def add_node_depth(tree: tree_utils.Node, max_depth: int) -> None:
186186

187187
def create_html_tree(inname: str, outname: str, col_width: str = "40px", row_height: str = "10px",
188188
name_width: str = "200px", prefix: str = "", label_branches: bool = False,
189-
rows_per_tip: int = 2) -> list:
189+
rows_per_tip: int = 2, verbose: bool = True) -> list:
190190
with open(inname, "r") as infile:
191191
newick_str = infile.read()
192192
newick_str = newick_str[:newick_str.find(";")+1]
193193
newick_str.replace("\n", "")
194-
print()
195-
print("Input file: " + inname)
196-
print("Imported Tree String: ", newick_str)
197-
print()
194+
if verbose:
195+
print()
196+
print("Input file: " + inname)
197+
print("Imported Tree String: ", newick_str)
198+
print()
198199
tree = tree_utils.read_newick_tree(newick_str)
199-
print("File read successfully.")
200-
print("Tree contains", tree.n_tips(), "tips.")
201-
print()
200+
if verbose:
201+
print("File read successfully.")
202+
print("Tree contains", tree.n_tips(), "tips.")
203+
print()
202204
ntips = tree.n_tips()
203205
nrows = total_rows_per_node(ntips, rows_per_tip)
204206
ncols = tree.max_node_tip_count() + 1
@@ -213,7 +215,8 @@ def create_html_tree(inname: str, outname: str, col_width: str = "40px", row_hei
213215
if outname != "": # if output file name is provided, write to file
214216
with open(outname, "w") as outfile:
215217
outfile.writelines(outlist)
216-
print("HTML file created: " + outname)
218+
if verbose:
219+
print("HTML file created: " + outname)
217220
return outlist
218221

219222

0 commit comments

Comments
 (0)