https://github.com/althonos/pyopal

Cython bindings and Python interface to Opal, a SIMD-accelerated database search aligner.

https://github.com/althonos/pyopal

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: pubmed.ncbi, ncbi.nlm.nih.gov
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.9%) to scientific vocabulary

Keywords

bioinformatics cython-library cython-wrapper genomics needleman-wunsch python-bindings python-library sequence-alignment simd smith-waterman

Keywords from Contributors

metagenomes
Last synced: 5 months ago · JSON representation

Repository

Cython bindings and Python interface to Opal, a SIMD-accelerated database search aligner.

Basic Info
Statistics
  • Stars: 10
  • Watchers: 3
  • Forks: 1
  • Open Issues: 0
  • Releases: 20
Topics
bioinformatics cython-library cython-wrapper genomics needleman-wunsch python-bindings python-library sequence-alignment simd smith-waterman
Created over 3 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog Contributing License

README.md

🐍🌈🪨 PyOpal Stars

Cython bindings and Python interface to Opal, a SIMD-accelerated database search aligner.

Actions Coverage License PyPI Bioconda AUR Wheel Python Versions Python Implementations Source Mirror Issues Docs Changelog Downloads

🗺️ Overview

Opal is a sequence aligner enabling fast sequence similarity search using either of the Smith-Waterman, semi-global or Needleman-Wunsch algorithms. It is used part of the SW#db method[1] to align a query sequence to multiple database sequences on CPU, using the multi-sequence vectorization method described in SWIPE[2]

PyOpal is a Python module that provides bindings to Opal using Cython. It implements a user-friendly, Pythonic interface to query a database of sequences and access the search results. It interacts with the Opal interface rather than with the CLI, which has the following advantages:

  • no binary dependency: PyOpal is distributed as a Python package, so you can add it as a dependency to your project, and stop worrying about the Opal binary being present on the end-user machine.
  • no intermediate files: Everything happens in memory, in a Python object you control, so you don't have to invoke the Opal CLI using a sub-process and temporary files.
  • better portability: Opal uses SIMD to accelerate alignment scoring, but doesn't support dynamic dispatch, so it has to be compiled on the local machine to be able to use the full capabilities of the local CPU. PyOpal ships several versions of Opal instead, each compiled with different target features, and selects the best one for the local platform at runtime.
  • wider platform support: The Opal code has been backported to work on SSE2 rather than SSE4.1, allowing PyOpal to run on older x86 CPUs (all x86 CPUs support it since 2003). In addition, Armv7 and Aarch64 CPUs are also supported if they implement NEON extensions. Finally, the C++ code of Opal has been modified to compile on Windows.

🔧 Installing

PyOpal is available for all modern versions (3.6+), optionally depending on the lightweight Python package archspec for runtime CPU feature detection.

It can be installed directly from PyPI, which hosts some pre-built x86-64 wheels for Linux, MacOS, and Windows, Aarch64 wheels for Linux and MacOS, as well as the code required to compile from source with Cython: console $ pip install pyopal

Otherwise, PyOpal is also available as a Bioconda package: console $ conda install -c bioconda pyopal

Check the install page of the documentation for other ways to install PyOpal on your machine.

💡 Example

All classes are imported in the main namespace pyopal: python import pyopal

pyopal can work with sequences passed as Python strings, as well as with ASCII strings in bytes objects: python query = "MAGFLKVVQLLAKYGSKAVQWAWANKGKILDWLNAGQAIDWVVSKIKQILGIK" database = [ "MESILDLQELETSEEESALMAASTVSNNC", "MKKAVIVENKGCATCSIGAACLVDGPIPDFEIAGATGLFGLWG", "MAGFLKVVQILAKYGSKAVQWAWANKGKILDWINAGQAIDWVVEKIKQILGIK", "MTQIKVPTALIASVHGEGQHLFEPMAARCTCTTIISSSSTF", ]

If you plan to reuse the database across several queries, you can store it in a Database, which will keep sequences encoded according to an Alphabet:

python database = pyopal.Database(database)

The top-level function pyopal.align can be used to align a query sequence against a database, using multithreading to process chunks of the database in parallel: python for result in pyopal.align(query, database): print(result.score, result.target_index, database[result.target_index])

See the API documentation for more examples, including how to use the internal API, and detailed reference of the parameters and result types.

🧶 Thread-safety

Database objects are thread safe through a C++17 read/write lock that prevents modification while the database is searched. In addition, the Aligner.align method is re-entrant and can be safely used to query the same database in parallel with different queries across different threads:

```python import multiprocessing.pool import pyopal import Bio.SeqIO

queries = [ "MEQQIELDVLEISDLIAGAGENDDLAQVMAASCTTSSVSTSSSSSSS", "MTQIKVPTALIASVHGEGQHLFEPMAARCTCTTIISSSSTF", "MGAIAKLVAKFGWPIVKKYYKQIMQFIGEGWAINKIIDWIKKHI", "MGPVVVFDCMTADFLNDDPNNAELSALEMEELESWGAWDGEATS", ]

database = pyopal.Database([ str(record.seq) for record in Bio.SeqIO.parse("vendor/opal/testdata/db/uniprotsprot12071.fasta", "fasta") ])

aligner = pyopal.Aligner() with multiprocessing.pool.ThreadPool() as pool: hits = dict(pool.map(lambda q: (q, aligner.align(q, database)), queries)) ```

💭 Feedback

⚠️ Issue Tracker

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker if you need to report or ask something. If you are filing in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.

🏗️ Contributing

Contributions are more than welcome! See CONTRIBUTING.md for more details.

📋 Changelog

This project adheres to Semantic Versioning and provides a changelog in the Keep a Changelog format.

⚖️ License

This library is provided under the MIT License. Opal is developed by Martin Šošić and is distributed under the terms of the MIT License as well. See vendor/opal/LICENSE for more information.

This project is in no way not affiliated, sponsored, or otherwise endorsed by the Opal authors. It was developed by Martin Larralde during his PhD project at the European Molecular Biology Laboratory in the Zeller team.

📚 References

Owner

  • Name: Martin Larralde
  • Login: althonos
  • Kind: user
  • Location: Heidelberg, Germany
  • Company: EMBL / LUMC, @zellerlab

PhD candidate in Bioinformatics, passionate about programming, SIMD-enthusiast, Pythonista, Rustacean. I write poems, and sometimes they are executable.

GitHub Events

Total
  • Create event: 5
  • Issues event: 1
  • Release event: 3
  • Watch event: 2
  • Delete event: 1
  • Issue comment event: 1
  • Push event: 28
Last Year
  • Create event: 5
  • Issues event: 1
  • Release event: 3
  • Watch event: 2
  • Delete event: 1
  • Issue comment event: 1
  • Push event: 28

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 227
  • Total Committers: 2
  • Avg Commits per committer: 113.5
  • Development Distribution Score (DDS): 0.004
Past Year
  • Commits: 144
  • Committers: 2
  • Avg Commits per committer: 72.0
  • Development Distribution Score (DDS): 0.007
Top Committers
Name Email Commits
Martin Larralde m****e@e****e 226
Valentyn Bezshapkin 6****z 1
Committer Domains (Top 20 + Academic)
embl.de: 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 6
  • Total pull requests: 1
  • Average time to close issues: 5 days
  • Average time to close pull requests: 3 days
  • Total issue authors: 3
  • Total pull request authors: 1
  • Average comments per issue: 1.83
  • Average comments per pull request: 1.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: about 24 hours
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • valentynbez (4)
  • LotusIodid (1)
  • RayHackett (1)
Pull Request Authors
  • valentynbez (1)
Top Labels
Issue Labels
bug (6) external (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 6,908 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 21
  • Total maintainers: 1
pypi.org: pyopal

Cython bindings and Python interface to Opal, a SIMD-accelerated pairwise aligner.

  • Homepage: https://github.com/althonos/pyopal/
  • Documentation: https://pyopal.readthedocs.io/en/stable/
  • License: MIT License Copyright (c) 2022-2025 Martin Larralde <martin.larralde@embl.de> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Latest release: 0.7.3
    published 7 months ago
  • Versions: 21
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 6,908 Last month
Rankings
Dependent packages count: 10.1%
Downloads: 17.0%
Average: 18.6%
Dependent repos count: 21.6%
Stargazers count: 21.6%
Forks count: 22.7%
Maintainers (1)
Last synced: 7 months ago

Dependencies

.github/workflows/requirements.txt pypi
  • auditwheel *
  • biopython *
  • codecov *
  • coverage *
  • cython *
  • importlib-resources *
  • setuptools >=46.4.0
  • wheel *
.github/workflows/package.yml actions
  • KSXGitHub/github-actions-deploy-aur v2.2.5 composite
  • actions-rs/toolchain v1 composite
  • actions/checkout v3 composite
  • actions/download-artifact v2 composite
  • actions/setup-python v2 composite
  • actions/upload-artifact v3 composite
  • actions/upload-artifact v2 composite
  • docker/setup-qemu-action v2 composite
  • pypa/cibuildwheel v2.11.3 composite
  • pypa/gh-action-pypi-publish master composite
  • rasmus-saks/release-a-changelog-action v1.0.1 composite
.github/workflows/test.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v3 composite
docs/requirements.txt pypi
  • cython *
  • ipykernel *
  • ipython *
  • nbsphinx *
  • pygments *
  • pygments-style-monokailight *
  • recommonmark *
  • semantic_version *
  • setuptools >=46.4
  • sphinx *
pyproject.toml pypi
setup.py pypi