Skip to main content

API for interacting with itol.embl.de

Project description

Latest Version Python Version License

Codeship CodeCov CodeClimate Dependency Status

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), Python requests package.

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
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>

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
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)

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 Github repository.

Development

To run tests:

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

To update PyPI:

pip install twine
python setup.py sdist bdist_wheel
twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itolapi-3.0.2.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

itolapi-3.0.2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file itolapi-3.0.2.tar.gz.

File metadata

  • Download URL: itolapi-3.0.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for itolapi-3.0.2.tar.gz
Algorithm Hash digest
SHA256 dfbe3a95f54edb41705b161ed87ee9c6fa6014692cc427339332e9501248b39e
MD5 1157e17ccbc17b002a39c3a7691f4d7c
BLAKE2b-256 6f032d2699a1b227b815f67082400ad4841df05e0ddd88b27542f91002e1c18b

See more details on using hashes here.

File details

Details for the file itolapi-3.0.2-py3-none-any.whl.

File metadata

  • Download URL: itolapi-3.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for itolapi-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 01445a0b0e1d6fc3dacbffdb62a084a37f28cdbd63047f445b104541f69bcec0
MD5 52049f25717c510bf2226575b7f44e53
BLAKE2b-256 4c0334361be9a6df61488982e3308b0ec48cb42ebf7b144b6e47fe40dcf6f5a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page