Skip to content

itol-config

To annotate trees in iTOL requres special config files that are time-consuming to create. This python package contains functions to create configuration files automatically from a CSV file.

Installation

pip install git+https://github.com/jodyphelan/itol-config.git

CLI Usage

This command will automatically create a config file for each column in the specified input csv file.

itol-config --input <input.csv> --out <prefix_for_output_files> --id <id_column> --type <annotation_type>

If you you already have colours in mind, you can specify them with the --colour-conf option. This requires a toml file with the following format:

[Column_name_1]
value1 = "colour"
value2 = "colour"

[Column_name_2]
value1 = "colour"
value2 = "colour"

Use functions in your own scripts

You can also call the functions in your own code. For example:

from itol_config import get_config_writer
import random

# generate some example data
countries = ["UK", "USA", "France", "Germany", "Spain"]
data = {f'sample_{i}': random.choice(countries)  for i in range(10)}

# create a config writer
writer = get_config_writer(
    config_type="colour_strip", 
    data=data, 
    label="Countries"
)
outfile = "countries_strip_config.txt"
writer.write(outfile)

Developers

The following annotation types are currently supported:

If you want to contribute a new annotation type this package, please clone the repository and create a new branch for your changes. Then create a pull request to merge your changes into the master branch.

Adding a new annotation type

Each annotation type is defined as a class in itol_config/interfaces. The class must inherit from the ConfigWriter class and implement the write method. Have a look at the existing classes for examples. Make sure to add your new class to interfaces_types dictionary in the __init__.py file in the same directory.