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
  • Tools Installation
    • pmotools-python installation
  • pmotools-python usages
    • Command line interface

    • pmotools-python
    • Command line interface to pmotools-python with pmotools-python
    • Extracting out of PMO
    • Extracting allele tables using pmotools-python
    • Subset PMO
    • Subsetting from a PMO using pmotools-python
    • Getting sub info from PMO
    • Getting basic info out of PMO using pmotools-python
    • Getting panel info out of PMO using pmotools-python
    • Handling Multiple PMOs
    • Handling multiple PMOs pmotools-python
    • Validating PMO files
    • Validating PMOs pmotools-python

    • Python interface
    • Getting basic info out of a PMO
    • Creating a PMO File
  • 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

  • pmotools-python
    • Installation
      • Development
      • Set up
        • Setting up python environment
      • Installing
      • Adding autocompletion

pmotools-python installation

  • Show All Code
  • Hide All Code

  • View Source

pmotools-python

pmotools-python is a tool base for interacting with the PMO format file in python. It provides both code to include in your python package as well as a command line interface to run some basic scripts on PMO files.

Installation

pmotools-python code can be found on github https://github.com/PlasmoGenEpi/pmotools-python/tree/develop and is available via pypi

Code
pip install pmotools 

Development

To install the developmental version, you can download the code from github

Set up

Downloading repo

Code
git clone git@github.com:PlasmoGenEpi/pmotools-python.git

Currently (as 2025-09) majority of code is currently still in develop branch

Code
cd pmotools-python
git checkout develop

Setting up python environment

To set up a conda environment that has all the python libraries that would be needed by pmotools-python

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

conda active pmotools

Installing

From within repo can install with pip in a virtual environment

Code
pip install -e . 

Adding autocompletion

To enable bash auto-completion for pmotools-python, add the following to your ~/.bash_completion and make sure it’s being loaded as part of your .bashrc and/or ~/.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

The above can also be found within the repo in the etc/ folder.

Source Code
---
title: pmotools-python installation
---

```{r setup, echo=F}
source("../common.R")
```


# pmotools-python

pmotools-python is a tool base for interacting with the PMO format file in python. It provides both code to include in your python package as well as a command line interface to run some basic scripts on PMO files. 


## Installation 

pmotools-python code can be found on github <https://github.com/PlasmoGenEpi/pmotools-python/tree/develop> and is available via [pypi](https://pypi.org/project/pmotools/) 

```{bash, eval = F}
pip install pmotools 
```


### Development 

To install the developmental version, you can download the code from github 

### Set up

Downloading repo 

```{bash, eval = F}
git clone git@github.com:PlasmoGenEpi/pmotools-python.git
```

Currently (as 2025-09) majority of code is currently still in develop branch 
```{bash, eval = F}
cd pmotools-python
git checkout develop
```


#### Setting up python environment 

To set up a conda environment that has all the python libraries that would be needed by pmotools-python 

```{bash, eval = F}
conda env create -f envs/pmotools-env.yml 

conda active pmotools

```

### Installing 

From within repo can install with pip in a virtual environment 

```{bash, eval = F}
pip install -e . 

```

### Adding autocompletion 

To enable bash auto-completion for `pmotools-python`, add the following to your `~/.bash_completion` and make sure it's being loaded as part of your .bashrc and/or ~/.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

```

The above can also be found within the repo in the `etc/` folder.