Portable Microhaplotype Object (PMO)Portable Microhaplotype Object (PMO) Portable Microhaplotype Object (PMO)
  • Home
  • Format Info
    • Overview of Format

    • PMO fields overview
    • PMO within a Data Analysis Ecosystem
    • History of Format Development

    • History of how PMO Format was derived
    • Overview of Format For Bioinformaticians

    • PMO Examples
    • Format Overview For Developers
  • PMO App
  • pmotools-python
    • Overview
    • Installation
    • Manual
    • Python Interface Tutorials
    • Building a PMO with minimum required fields
    • Updating the Specimen Meta Information in a minimum PMO
    • Building a PMO including optional sections and fields
    • Getting basic information from a PMO file
    • Command line Interface Tutorials
    • Command line interface guide
    • Extracting allele tables from a PMO
    • Subsetting a PMO
    • Getting basic information from a PMO
    • Extracting panel info from PMO
    • Handling Multiple PMOs
    • Validating PMO files
  • Resources
    • References
    • Documentation
    • Documentation Source Code
    • Comment or Report an issue for Documentation

    • pmotools-python
    • pmotools-python Source Code
    • Comment or Report an issue for pmotools-python

Contents

  • Install from PyPI
  • Install from source (development)
    • Clone the repository
    • Set up a Conda environment (recommended)
    • Install the package
  • Bash autocompletion (optional)

pmotools-python installation

  • Show All Code
  • Hide All Code

  • View Source

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.

Install from PyPI

The latest release is on PyPI. Source code is on GitHub. For most users, we recommend installing with pip:

Code
pip install pmotools

To try building a PMO after installation, see Creating a minimum PMO.

Install from source (development)

To install the latest development version, clone the repository and install in editable mode.

Clone the repository

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

Code
conda env create -f envs/pmotools-env.yml
conda activate pmotools

Install the package

From within the cloned repository:

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

Code
_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/.

Source Code
---
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/`.
 

A PlasmoGenEpi project