Code
pip install pmotoolspmotools-python is a Python toolkit for working with PMO files. It provides a library you can import in your own scripts and a command-line interface (pmotools-python) for common PMO tasks. For an overview of what you can do after installing, see the getting started guide.
The latest release is on PyPI. Source code is on GitHub. For most users, we recommend installing with pip:
To try building a PMO after installation, see Creating a minimum PMO.
To install the latest development version, clone the repository and install in editable mode.
To create a conda environment with the dependencies tested against pmotools-python:
From within the cloned repository:
To enable tab completion for pmotools-python, add the following to ~/.bash_completion and ensure that file is sourced from your shell profile (for example ~/.bashrc, ~/.bash_profile on macOS, or ~/.profile on Ubuntu):
_pmotools_python_complete()
{
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# 1) Completing the command name (1st arg): list all commands
if [[ ${COMP_CWORD} -eq 1 ]]; then
# Our CLI prints machine-friendly list via --list-plain:
# "<command>\t<group>\t<help>"
local lines cmds
lines="$(${COMP_WORDS[0]} --list-plain 2>/dev/null)"
cmds="$(printf '%s\n' "${lines}" | awk -F'\t' '{print $1}')"
COMPREPLY=( $(compgen -W "${cmds}" -- "${cur}") )
return 0
fi
# 2) Completing flags for a leaf command: scrape leaf -h
if [[ "${cur}" == -* ]]; then
local helps opts
helps="$(${COMP_WORDS[0]} ${COMP_WORDS[1]} -h 2>/dev/null)"
# Pull out flag tokens and split comma-separated forms
opts="$(printf '%s\n' "${helps}" \
| sed -n 's/^[[:space:]]\{0,\}\(-[-[:alnum:]][-[:alnum:]]*\)\(, *-[[:alnum:]][-[:alnum:]]*\)\{0,\}.*/\1/p' \
| sed 's/, / /g')"
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
# 3) Otherwise, fall back to filename completion for positional args
COMPREPLY=( $(compgen -f -- "${cur}") )
return 0
}
complete -F _pmotools_python_complete pmotools-pythonThis script is also available in the repository under etc/.
---
title: pmotools-python installation
---
```{r setup, echo=F}
source("../common.R")
```
**pmotools-python** is a Python toolkit for working with PMO files. It provides a library you can import in your own scripts and a command-line interface (`pmotools-python`) for common PMO tasks. For an overview of what you can do after installing, see the [getting started guide](../pmotools-python-usages/general_info.qmd).
## Install from PyPI
The latest release is on [PyPI](https://pypi.org/project/pmotools/). Source code is on [GitHub](https://github.com/PlasmoGenEpi/pmotools-python/tree/develop). For most users, we recommend installing with pip:
```{bash, eval = F}
pip install pmotools
```
To try building a PMO after installation, see [Creating a minimum PMO](../pmotools-python-usages-notebooks/building_a_minimum_pmo/Create_minimal_pmo.ipynb).
## Install from source (development)
To install the latest development version, clone the repository and install in editable mode.
### Clone the repository
```{bash, eval = F}
git clone git@github.com:PlasmoGenEpi/pmotools-python.git
cd pmotools-python
git checkout develop
```
### Set up a Conda environment (recommended)
To create a conda environment with the dependencies tested against pmotools-python:
```{bash, eval = F}
conda env create -f envs/pmotools-env.yml
conda activate pmotools
```
### Install the package
From within the cloned repository:
```{bash, eval = F}
pip install -e .
```
## Bash autocompletion (optional)
To enable tab completion for `pmotools-python`, add the following to `~/.bash_completion` and ensure that file is sourced from your shell profile (for example `~/.bashrc`, `~/.bash_profile` on macOS, or `~/.profile` on Ubuntu):
```{bash, eval = F}
_pmotools_python_complete()
{
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# 1) Completing the command name (1st arg): list all commands
if [[ ${COMP_CWORD} -eq 1 ]]; then
# Our CLI prints machine-friendly list via --list-plain:
# "<command>\t<group>\t<help>"
local lines cmds
lines="$(${COMP_WORDS[0]} --list-plain 2>/dev/null)"
cmds="$(printf '%s\n' "${lines}" | awk -F'\t' '{print $1}')"
COMPREPLY=( $(compgen -W "${cmds}" -- "${cur}") )
return 0
fi
# 2) Completing flags for a leaf command: scrape leaf -h
if [[ "${cur}" == -* ]]; then
local helps opts
helps="$(${COMP_WORDS[0]} ${COMP_WORDS[1]} -h 2>/dev/null)"
# Pull out flag tokens and split comma-separated forms
opts="$(printf '%s\n' "${helps}" \
| sed -n 's/^[[:space:]]\{0,\}\(-[-[:alnum:]][-[:alnum:]]*\)\(, *-[[:alnum:]][-[:alnum:]]*\)\{0,\}.*/\1/p' \
| sed 's/, / /g')"
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
# 3) Otherwise, fall back to filename completion for positional args
COMPREPLY=( $(compgen -f -- "${cur}") )
return 0
}
complete -F _pmotools_python_complete pmotools-python
```
This script is also available in the repository under `etc/`.