Skip to main content

API for interacting with itol.embl.de

Project description

![PyPI](https://img.shields.io/pypi/v/itolapi) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/itolapi) ![PyPI - License](https://img.shields.io/pypi/l/itolapi)

[![Build Status](https://drone.albertyw.com/api/badges/albertyw/itolapi/status.svg)](https://drone.albertyw.com/albertyw/itolapi) [![Test Coverage](https://api.codeclimate.com/v1/badges/365d217b9dd6c2f97cb4/test_coverage)](https://codeclimate.com/github/albertyw/itolapi/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/365d217b9dd6c2f97cb4/maintainability)](https://codeclimate.com/github/albertyw/itolapi/maintainability) [![Updates](https://pyup.io/repos/github/albertyw/itolapi/shield.svg)](https://pyup.io/repos/github/albertyw/itolapi/)

> Notice: Due to [iTOL requiring paid subscriptions for batch uploads](https://itol.embl.de/infoReg.cgi), > 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)](http://itol.embl.de/).

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](http://itol.embl.de/) 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](http://itol.embl.de/help.cgi#batch).

`python 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.

`python 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](http://itol.embl.de/help.cgi#batch).

Bugs/Comments

Send bugs and comments as issues on the [itolapi Github](https://github.com/albertyw/itolapi/) repository.

Development

To run tests:

`bash python setup.py develop pip install -r requirements-test.txt flake8 mypy itolapi coverage run -m unittest `

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-4.0.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

itolapi-4.0.2-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: itolapi-4.0.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for itolapi-4.0.2.tar.gz
Algorithm Hash digest
SHA256 21c1fcd5fa31af74f2e5297720e4c3613409ed295b35ed366ea89a51790ec6c4
MD5 f341feb11ec0ecaf149e0fe668289c3a
BLAKE2b-256 1f577f776d6f01c9c1b34d2912176e0708197a1d4b45e98afce8655636076d83

See more details on using hashes here.

File details

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

File metadata

  • Download URL: itolapi-4.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for itolapi-4.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d4912a54f86e857345232e270db6e376aa87923b3d050bd3ea346ac7096e7b3
MD5 544cfe28afbbc849b6f9996c74526472
BLAKE2b-256 2c0d083fa2a71ed7da20154b423471f2e8aca7b4e08593b2f454f836c0b02ddf

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