API for interacting with itol.embl.de
Project description
iTOL Python API
Notice: Due to iTOL requiring paid subscriptions for batch uploads, this library will be deprecated after October 1, 2020.
Python API for the Interactive Tree of Life (iTOL)
Created by Albert Wang (git at albertyw.com)
With Complements to iTOL (Interactive Tree of Life).
This iTOL API allows local software to upload trees to iTOL using
itol.py
and export uploaded trees using itolexport.py
using direct
Python calls or through shell. An active internet connection to the
iTOL website is required.
Installation
pip install itolapi
Uploading Trees To iTOL (itol.py)
From Command Line
(If you need to do anything more than displaying basic tree structures, you must call the Python iTOL API from within a Python program)
$ itol.py /path/to/example.tree
http://itol.embl.de/external.cgi?tree=1234567890&restore_saved=1
From Python
Running from a python program is much more flexible than running from command line and allows access to all iTOL options.
from itolapi import Itol
from pathlib import Path
itol_uploader = Itol()
itol_uploader.add_file(Path('/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>
An example for using the Python iTOL API can found in
examples/example.py
.
Downloading Trees From iTOL (itolexport.py)
From Command Line
(If you would like to set any parameters other than the tree id, location to save the file, file format, and whether to display datasets, you must use ItolExport from a Python program)
$ itolexport.py TREEID FILELOCATION FORMAT [OPTIONS]
Options include:
-d
: show datasets-v
: verbose output-h
: help
From Python
Running itolexport.py from a Python program allows you to use all the options that iTOL has available.
from itolapi import ItolExport
from pathlib import Path
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(Path('/path/to/example_tree'))
Valid param_key
and param_value
values can be found on the iTOL API
page.
Bugs/Comments
Send bugs and comments as issues on the itolapi Github repository.
Development
To run tests:
pip install -e .[test]
ruff check .
mypy .
coverage run -m unittest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file itolapi-4.1.5.tar.gz
.
File metadata
- Download URL: itolapi-4.1.5.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ce2f6c0560b4b3898913a61a821667ea62aca330aad008e4c71fe98ec26c874 |
|
MD5 | 5c5076c08bdb40eb3f782b3c9c2bec27 |
|
BLAKE2b-256 | 6c078d12abeae08c21710ad369a58b316acc8b0bda916e0b0f9cfd8fdd2a36bf |
File details
Details for the file itolapi-4.1.5-py3-none-any.whl
.
File metadata
- Download URL: itolapi-4.1.5-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 471f644c3754c3ea89e362a08d8714d09cade7d869b0ec29af121be86b0ed9ed |
|
MD5 | 72690cf0cc6d528a8d46b9de8a9165ab |
|
BLAKE2b-256 | 9a473306f7f8785a9edd3c24926d3fc294095980fa86cdd3a0dd8930e4528c14 |