Skip to main content

iTOL Python API

PyPI PyPI - Python Version PyPI - License

Build Status Maintainability Code Coverage

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

Metadata

Release files for itolapi 4.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for itolapi 4.1.6
File Size Uploaded Provenance Actions
itolapi-4.1.6.tar.gz 6.8 kB Without provenance Details for itolapi-4.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for itolapi 4.1.6
File Interpreter ABI Platform Actions
itolapi-4.1.6-py3-none-any.whl Python 3 none any Details for itolapi-4.1.6-py3-none-any.whl

Total release size: 14.0 kB

Release files / itolapi-4.1.6.tar.gz

Download URL itolapi-4.1.6.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2d124a244abbdf227801aad6a61bc9e466177001edd164fd731f3e18f008f00d
BLAKE2b-256 checksum
How to use checksums
82fb95ad9900e507bb14cb1bd238734be3a8e45233bbf79808dda3a61b381edc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / itolapi-4.1.6-py3-none-any.whl

Download URL itolapi-4.1.6-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3925d8193bd1816037b921b061e2b10cbb3fb3d3f120e301eaba0ce0d2e0ade
BLAKE2b-256 checksum
How to use checksums
f3ce33069504004a3023c964c96d064984863abb3e6bcef85685ba75f6e0a7ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for itolapi 4.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page