Collection of scripts and tools for MGnify pipelines
Project description
mgnify-pipelines-toolkit
This Python package contains a collection of scripts and tools for including in MGnify pipelines. Scripts stored here are mainly for:
- One-off production scripts that perform specific tasks in pipelines
- Scripts that have few dependencies
- Scripts that don't have existing containers built to run them
- Scripts for which building an entire container would be too bulky of a solution to deploy in pipelines
This package is built and uploaded to PyPi and bioconda. The package bundles scripts and makes them executable from the command-line when this package is installed.
How to install
This package is available both on PyPi and bioconda.
To install from PyPi with pip:
pip install mgnify-pipelines-toolkit
To install from bioconda with conda/mamba:
conda install -c bioconda mgnify-pipelines-toolkit
You should then be able to run the packages from the command-line. For example to run the get_subunits.py script:
get_subunits -i ${easel_coords} -n ${meta.id}
Development
Quick Start with uv and Taskfile
This project uses uv for fast Python environment management and Task for task automation.
Prerequisites:
Common tasks:
task: Available tasks for this project:
* clean: Clean up generated files and caches
* lint: Run linters (ruff check only)
* lint-fix: Run linters and fix issues automatically
* pre-commit: Install pre-commit hooks
* run: Run toolkit scripts with uv (usage: task run -- <script_name> [args])
* test: Run tests with uv
* testk: Run specific tests from a file (usage: task testk -- test_path)
* venv: Create a virtual environment with uv
When doing these steps above, you ensure that the code you add will be linted and formatted properly.
New script requirements
There are a few requirements for your script:
- It needs to have a named main function of some kind. See
mgnify_pipelines_toolkit/analysis/shared/get_subunits.pyand themain()function for an example - Because this package is meant to be run from the command-line, make sure your script can easily pass arguments using tools like
argparseorclick - A small amount of dependencies. This requirement is subjective, but for example if your script only requires a handful of basic packages like
Biopython,numpy,pandas, etc., then it's fine. However if the script has a more extensive list of dependencies, a container is probably a better fit.
How to add a new script
To add a new Python script, first copy it over to the mgnify_pipelines_toolkit directory in this repository, specifically to the subdirectory that makes the most sense. If none of the subdirectories make sense for your script, create a new one. If your script doesn't have a main() type function yet, write one.
Then, open pyproject.toml as you will need to add some bits. First, add any missing dependencies (include the version) to the dependencies field.
Then, if you created a new subdirectory to add your script in, go to the packages line under [tool.setuptools] and add the new subdirectory following the same syntax.
Then, scroll down to the [project.scripts] line. Here, you will create an alias command for running your script from the command-line. In the example line:
get_subunits = "mgnify_pipelines_toolkit.analysis.shared.get_subunits:main"
get_subunitsis the aliasmgnify_pipelines_toolkit.analysis.shared.get_subunitswill link the alias to the script with the pathmgnify_pipelines_toolkit/analysis/shared/get_subunits.py:mainwill specifically call the function namedmain()when the alias is run.
When you have setup this command, executing get_subunits on the command-line will be the equivalent of doing:
from mgnify_pipelines_toolkit.analysis.shared.get_subunits import main; main()
You should then write at least one unit test for your addition. This package uses pytest at the moment for this purpose. A GitHub Action workflow will run all of the unit tests whenever a commit is pushed to any branch.
Finally, you will need to bump up the version in the version line.
At the moment, these should be the only steps required to setup your script in this package (which is subject to change).
Building and uploading to PyPi
The building and pushing of the package is automated by GitHub Actions, which will activate only on a new release. Bioconda should then automatically pick up the new PyPi release and push it to their recipes, though it's worth keeping an eye on their automated pull requests just in case here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mgnify_pipelines_toolkit-1.4.17.tar.gz.
File metadata
- Download URL: mgnify_pipelines_toolkit-1.4.17.tar.gz
- Upload date:
- Size: 97.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd8093ca68336276a77dbe0c93e8cd6b516b5abc8e7a36d64a9e13e785f4719e
|
|
| MD5 |
ee44e82fd0d8f23437dac691371f7752
|
|
| BLAKE2b-256 |
3b3aacf27412bacae7afc1296570fa02d094596cca25960c6a2b26441fc35673
|
Provenance
The following attestation bundles were made for mgnify_pipelines_toolkit-1.4.17.tar.gz:
Publisher:
python-publish.yml on EBI-Metagenomics/mgnify-pipelines-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgnify_pipelines_toolkit-1.4.17.tar.gz -
Subject digest:
cd8093ca68336276a77dbe0c93e8cd6b516b5abc8e7a36d64a9e13e785f4719e - Sigstore transparency entry: 985682843
- Sigstore integration time:
-
Permalink:
EBI-Metagenomics/mgnify-pipelines-toolkit@5ab39bd76bb26779e2d8f64cafd98f4ae368fd21 -
Branch / Tag:
refs/tags/v1.4.17 - Owner: https://github.com/EBI-Metagenomics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5ab39bd76bb26779e2d8f64cafd98f4ae368fd21 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mgnify_pipelines_toolkit-1.4.17-py3-none-any.whl.
File metadata
- Download URL: mgnify_pipelines_toolkit-1.4.17-py3-none-any.whl
- Upload date:
- Size: 133.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
328c2badb035a09306942de2c84a6dea0862e495bc42c15b13a565009c875c5b
|
|
| MD5 |
9139f109faccd42a031d70669709dadc
|
|
| BLAKE2b-256 |
21c4e7ac47926c87099da4f43bd9eaf16a7a7a210e20303789f630300c6df3d9
|
Provenance
The following attestation bundles were made for mgnify_pipelines_toolkit-1.4.17-py3-none-any.whl:
Publisher:
python-publish.yml on EBI-Metagenomics/mgnify-pipelines-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgnify_pipelines_toolkit-1.4.17-py3-none-any.whl -
Subject digest:
328c2badb035a09306942de2c84a6dea0862e495bc42c15b13a565009c875c5b - Sigstore transparency entry: 985682915
- Sigstore integration time:
-
Permalink:
EBI-Metagenomics/mgnify-pipelines-toolkit@5ab39bd76bb26779e2d8f64cafd98f4ae368fd21 -
Branch / Tag:
refs/tags/v1.4.17 - Owner: https://github.com/EBI-Metagenomics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5ab39bd76bb26779e2d8f64cafd98f4ae368fd21 -
Trigger Event:
release
-
Statement type: