Created
October 4, 2019 11:02
-
-
Save Ken-Kuroki/30ed01f1612fc345c60e68319110bba1 to your computer and use it in GitHub Desktop.
Call iTOL API to draw and save a phylogenetic tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itolapi import Itol | |
def itol(tree_file: str, save_file: str, save_format: str) -> str: | |
if tree_file[-5:] != ".tree" and tree_file[-9:] != ".tree.txt": | |
raise Exception("Input tree file name must end with .tree or .tree.txt") | |
if save_format not in ['png', 'svg', 'eps', 'ps', 'pdf', 'nexus', 'newick']: | |
raise Exception("Unsupported save format") | |
itol_uploader = Itol() | |
itol_uploader.add_file(tree_file) | |
itol_uploader.upload() | |
itol_exporter = itol_uploader.get_itol_export() | |
itol_exporter.add_export_param_dict({"format": save_format}) | |
itol_exporter.export(save_file) | |
return itol_uploader.get_webpage() | |
itol("mytree.tree.txt", "save.svg", "svg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment