与itol.embl.de交互的api
itolapi的Python项目详细描述
用于交互式生命树(itol)的python api
由Albert Wang创建(git at Albertyw.com)
与iTOL (Interactive Tree of Life)、python requests package互补。
这个itol api允许本地软件使用^{tt1}将树上载到itol$ 并使用直接python使用itolexport.py导出上载的树 调用或通过shell。与 iTOL website是必需的。
安装
pip install itolapi
将树上载到itol(itol.py)
从命令行
(如果您需要做的不仅仅是显示基本的树结构, 必须从python程序中调用python itol api)
$ itol.py /path/to/example.tree http://itol.embl.de/external.cgi?tree=1234567890&restore_saved=1
来自python
从Python程序中运行比从运行中灵活得多 命令行并允许访问所有iTOL options
from itolapi import Itol itol_uploader = Itol() itol_uploader.add_file('/path/to/example.tree') itol_uploader.params['treeName'] = 'apple' status = itol_uploader.upload() assert status != False itol_uploader.comm.upload_output # SUCCESS: 1234567890 itol_uploader.comm.tree_id # 1234567890 itol_uploader.get_webpage() # http://itol.embl.de/external.cgi?tree=1234567890&restore_saved=1 itol_uploader.get_itol_export() # <ItolExport.ItolExport instance at 0x207c5f0>
使用python itol api的示例可以在 examples/example.py。
从itol下载树(itolexport.py)
从命令行
(如果要设置除树ID以外的任何参数, 保存文件的位置、文件格式以及是否显示数据集, 必须使用python程序中的itolexport)
$ itolexport.py TREEID FILELOCATION FORMAT [OPTIONS]
- 选项包括:
- -d:显示数据集
- -v:详细输出
- -h:帮助
来自python
从python程序运行itolexport.py可以使用 iTol提供的选项。
from itolapi import ItolExport itol_exporter = ItolExport() itol_exporter.add_export_param_value('tree', tree_id) assert format in ['png', 'svg', 'eps', 'ps', 'pdf', 'nexus', 'newick'] itol_exporter.add_export_param_value('format', format) itol_exporter.add_export_param_value(param_key, param_value) itol_exporter.export(file_location)
在the iTOL API page上可以找到有效的param_key和param_value值。
错误/评论
将错误和评论作为问题发送到Github存储库。
开发
运行测试:
python setup.py install pip install -r requirements-test.txt pip install -r requirements-test-python3.txt mypy itolapi coverage run setup.py test coverage report -m
更新pypi:
pip install twine python setup.py sdist bdist_wheel twine upload dist/*