.. _installation:
Installation
============
.. note::
``PyEvoMotion`` performs its sequence alignment with a bundled pure-Rust port of `mafft `_ (the `mafft crate `_), compiled into the package. There is no external ``mafft`` binary to install.
Pre-built wheels are published for Linux, macOS and Windows on CPython 3.12. Installing from the source distribution requires a Rust toolchain (``cargo``).
From PyPI
---------
The simplest way to install PyEvoMotion is from PyPI:
.. code-block:: bash
pip install PyEvoMotion
This will install the package and its dependencies *(but not the tests nor the test data)*.
From Source
-----------
Alternatively, you can install it directly from the repository:
.. code-block:: bash
git clone https://github.com/luksgrin/PyEvoMotion
cd PyEvoMotion
pip install .
Verification
------------
To check if the installation was successful, you can run the following command:
.. code-block:: bash
PyEvoMotion
If the installation was successful, you should see the following output:
.. code-block:: bash
Welcome to Rodrigolab's
_____ ______ __ __ _ _
| __ \ | ____| | \/ | | | (_)
| |__) | _| |____ _____ | \ / | ___ | |_ _ ___ _ __
| ___/ | | | __\ \ / / _ \| |\/| |/ _ \| __| |/ _ \| '_ \
| | | |_| | |___\ V / (_) | | | | (_) | |_| | (_) | | | |
|_| \__, |______\_/ \___/|_| |_|\___/ \__|_|\___/|_| |_|
__/ |
|___/
usage: PyEvoMotion [-h] [-dt DELTA_T] [-sh] [-ep] [-l LENGTH_FILTER] [-xj] [-ij IMPORT_JSON] [-k {all,total,substitutions,insertions,deletions,indels}] [-f FILTER [FILTER ...]] [-gp GENOME_POSITIONS] [-dr DATE_RANGE] seqs meta out
PyEvoMotion
positional arguments:
seqs Path to the input fasta file containing the sequences.
meta Path to the corresponding metadata file for the sequences.
out Path to the output filename prefix used to save the different results.
options:
-h, --help show this help message and exit
-dt DELTA_T, --delta_t DELTA_T
Time interval to calculate the statistics. Default is 7 days (7D).
-sh, --show Show the plots of the analysis.
-ep, --export_plots Export the plots of the analysis.
-l LENGTH_FILTER, --length_filter LENGTH_FILTER
Length filter for the sequences (removes sequences with length less than the specified value). Default is 0.
-xj, --export_json Export the run arguments to a json file.
-ij IMPORT_JSON, --import_json IMPORT_JSON
Import the run arguments from a JSON file. If this argument is passed, the other arguments are ignored. The JSON file must contain the mandatory keys 'seqs', 'meta', and 'out'.
-k {all,total,substitutions,indels}, --kind {all,total,substitutions,indels}
Kind of mutations to consider for the analysis. Default is 'all'.
-f FILTER [FILTER ...], --filter FILTER [FILTER ...]
Specify filters to be applied on the data with keys followed by values. If the values are multiple, they must be enclosed in square brackets. Example: --filter key1 value1 key2 [value2 value3] key3 value4. If either the keys or values
contain spaces, they must be enclosed in quotes. keys must be present in the metadata file as columns for the filter to be applied. Use '*' as a wildcard, for example Bio* to filter all columns starting with 'Bio'.
-gp GENOME_POSITIONS, --genome_positions GENOME_POSITIONS
Genome positions to restrict the analysis. The positions must be separated by two dots. Example: 1..1000. Open start or end positions are allowed by omitting the first or last position, respectively. If not specified, the whole
reference genome is considered.
-dr DATE_RANGE, --date_range DATE_RANGE
Date range to filter the data. The date range must be separated by two dots and the format must be YYYY-MM-DD. Example: 2020-01-01..2020-12-31. If not specified, the whole dataset is considered. Note that if the origin is specified, the
most restrictive date range is considered.
Error: the following arguments are required: seqs, meta, out
Running Tests
-------------
This package has been developed using ``pytest`` for testing. To run the tests, you may install PyEvoMotion from the ``sdist`` archive, decompress it, install it and run the tests:
.. code-block:: bash
pip download --no-deps --no-binary :all: PyEvoMotion
tar -xvzf pyevomotion-*.tar.gz
cd pyevomotion-*/
pip install . pytest
pytest
.. note::
The UK/USA dataset tests run, by default, on a fixed-seed subset of the manuscript sample (1,000 sequences per country, about 20 MB), downloaded on first use from the ``ci-data-v1`` release of the GitHub repository into ``tests/data/test3/ci/``.
The synthetic-dataset tests likewise run on a fixed-seed sample of 400 of their 2,001 sequences.
Set ``PYEVOMOTION_FULL_TEST_DATA=1`` to run everything against the full data (the UK/USA dataset is about 11 GB, downloaded from ``https://sourceforge.net/projects/pyevomotion/files/test_data.zip/download``). That takes several hours.
Docker Installation
-------------------
A Docker image containing a virtual environment with ``PyEvoMotion`` pre-installed, its dependencies, and the test data is available.
Pull the image from GitHub Container Registry:
.. code-block:: bash
docker pull ghcr.io/luksgrin/pyevomotion:latest
Alternatively, to build the main image, run:
.. code-block:: bash
docker build -t ghcr.io/luksgrin/pyevomotion:latest -f docker/Dockerfile
Running the Container
^^^^^^^^^^^^^^^^^^^^^
To start an interactive container:
.. code-block:: bash
docker run -it ghcr.io/luksgrin/pyevomotion:latest
This will open a prompt that displays a welcome message and allows you to start using ``PyEvoMotion`` right away.
Included Data in Docker
^^^^^^^^^^^^^^^^^^^^^^^
The image includes input files (``FASTA`` and metadata) in:
.. code-block:: bash
/home/pyevomotion/pyevomotion-*/tests/data/test3
which are used by the test suite.
Also, the source script for figure generation (along with the pre-generated results of running ``PyEvoMotion``) is available under:
.. code-block:: bash
/home/pyevomotion/pyevomotion-*/share
Running Tests in Docker
^^^^^^^^^^^^^^^^^^^^^^^
Once inside the container, run:
.. code-block:: bash
cd pyevomotion-*
pytest
This will execute the test suite included with the source.
Reproducing the Figure from the Original Manuscript
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To reproduce the figure from the original manuscript, run:
.. code-block:: bash
cd pyevomotion-*
python share/manuscript_figure.py export
The figure will be saved in the ``share`` directory.