Cython bindings and Python interface to Opal, a SIMD-accelerated pairwise aligner.
Project description
🐍🌈🪨 PyOpal ![Stars](https://pypi-camo.freetls.fastly.net/6002ffc99af719821762b56ca9f0be429b3f5a66/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f616c74686f6e6f732f70796f70616c2e7376673f7374796c653d736f6369616c266d61784167653d33363030266c6162656c3d53746172)
Cython bindings and Python interface to Opal, a SIMD-accelerated database search aligner.
🗺️ Overview
Opal is a sequence aligner enabling fast sequence similarity search using either of the Smith-Waterman, semi-global or Needleman-Wunsch algorithms.
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:
- single 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.
🔧 Installing
PyOpal is available for all modern versions (3.6+), with no external dependencies.
It can be installed directly from PyPI, which hosts some pre-built wheels for the x86-64 architecture (Linux/OSX) and the Aarch64 architecture (Linux only), as well as the code required to compile from source with Cython:
$ pip install pyopal
💡 Example
Create a database from some reference sequences:
import pyopal
database = pyopal.Database([
"MESILDLQELETSEEESALMAASTVSNNC", # goadvionin A
"MKKAVIVENKGCATCSIGAACLVDGPIPDFEIAGATGLFGLWG", # subtilosin A
"MAGFLKVVQILAKYGSKAVQWAWANKGKILDWINAGQAIDWVVEKIKQILGIK", # lacticin Z
"MTQIKVPTALIASVHGEGQHLFEPMAARCTCTTIISSSSTF", # plantazolicin
])
Then search it with a query sequence, and show the target sequence with the highest score:
results = database.search("MAGFLKVVQLLAKYGSKAVQWAWANKGKILDWLNAGQAIDWVVSKIKQILGIK")
best = max(results, key=lambda result: result.score)
print(best.score, best.target_index, database[best.target_index])
You can also get the alignment for every target, but this must be enabled when searching the database:
results = database.search("MESVLDLQELETSEEESALMAASTISQNC", mode="full")
for result in results:
print(result.score, result.identity(), result.cigar())
🧶 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
Database.search
method is re-entrant and can be safely used to query the same
database in parallel with different queries across different threads:
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/test_data/db/uniprot_sprot12071.fasta", "fasta")
])
with multiprocessing.pool.ThreadPool() as pool:
hits = dict(pool.map(lambda q: (q, database.search(q)), 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.
The cpu_features
library was written by Guillaume Chatelet and is
licensed under the terms of the Apache License 2.0.
See vendor/cpu_features/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.
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 Distributions
Hashes for pyopal-0.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5018f47e903d60a347936256f9718395d28882460296f21afc16525f71968ab |
|
MD5 | 1829a2cf1d36d2351b4def59516a07cc |
|
BLAKE2b-256 | 1d19b8170ee1ced18008414f7f5300ee69bc10fdb222f1b2bc141734988f454e |
Hashes for pyopal-0.1.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 951b18cfea7453f4c58e5e237b940570a3416d1f5418ec4f06c9f7558af1bb33 |
|
MD5 | 90b5bd99ba7fde8728d713edf81e53e6 |
|
BLAKE2b-256 | 2ca2e7c38982b641790e7588feb22c22d06473278193b76eaaa0f45b834f0491 |
Hashes for pyopal-0.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a9ae344f3f0380b95bacdbb7bbff95da9f30d8ea507c8280203e13f1e1cf0e4 |
|
MD5 | 45994f5e681f241dab7a5218c9174a55 |
|
BLAKE2b-256 | ffbf9b8ffbcdec80d552b9aa17fc9e25e1ff7c32183791e3e98de8aa7cb5139a |
Hashes for pyopal-0.1.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88ac57bde21216d5135fd3d9534f66b0feb8647af0c4dcefee36b7f1aeba0ed5 |
|
MD5 | 2f8bd32c63dd48b99f7f002e28e318e8 |
|
BLAKE2b-256 | 7f4f359da9666a17f27f6053b93384299b2641804c99e0f5223ed76287c0d52a |
Hashes for pyopal-0.1.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 607eb8abc95ac063e9ec13fa294d8a451686116e373324ca4d9eadf5d433994b |
|
MD5 | 5aca9f33a3925fec1a6442d521abe55a |
|
BLAKE2b-256 | f0e94752dfc3b47bd8076fdd5d5a9e1447a06d1d94186808f0103489f8a16fb5 |
Hashes for pyopal-0.1.0-pp37-pypy37_pp73-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d086474adc6cd4d54ce2a8f619a3a78ff9d768a19b0e41214587ca112445461f |
|
MD5 | b8acae218b77f83f2b0f1e38bbcbcf06 |
|
BLAKE2b-256 | d5250fc784190093feca6e1fbc4d3810f4f775ba07f35ffaec7723cf6f941e93 |
Hashes for pyopal-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26870b85456e7df0c84d21874d7e79e45ed961481898f487915f1efb2d1adb61 |
|
MD5 | d56f02d9896e0fe3b5176391c06697f8 |
|
BLAKE2b-256 | ee8bc93703669a5e5fe776d9157a2cbcec740034f77feb19c1d8ab7dcc8f9d62 |
Hashes for pyopal-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f639a5c4772f3faf28d1c0acaa5c15ab6a84ff1127940c2123ac7dd30e57a8fe |
|
MD5 | 0d887064612b7099526fdf6210e85569 |
|
BLAKE2b-256 | 125e49548fd7aca9b136e2f89dd7487833054475d652e0bf559278470be1426b |
Hashes for pyopal-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cbf6ed116ec5928b91cac66f57b45f7dad2b4ca1f262173f36f468bdb371901 |
|
MD5 | 703ea418fba4cdc683d6ef550e71a2c4 |
|
BLAKE2b-256 | 0e872b286f3f27813c63e44ce328b267cda1d608374d43ca17649b868ea9c667 |
Hashes for pyopal-0.1.0-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f18c22653f2ec4abe67cb7265a16751eb598a69705c177aabcc5dda246e999e8 |
|
MD5 | dae070208c97fa0efc38d3d319152802 |
|
BLAKE2b-256 | 5f2e0bc8373635874cce4968c0d394d783d076db7d81f73f8bb7058787e1dcbd |
Hashes for pyopal-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3772a963d8afa58d56d83a4e247454effc4b6b2e82171ea1458ab6d61318c7f |
|
MD5 | 97b9889c144e3ef0c7026a78d8a5ea52 |
|
BLAKE2b-256 | 0a9e6fa239554e6cff88cfed23d4504349a2cb8ae731e86288671d159a2f355e |
Hashes for pyopal-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 116c8b3489441cf885847a844ad27fbadc75a136053c07054551fcfe4000c528 |
|
MD5 | 8c2fb22c3b7e46517a3543565271ab83 |
|
BLAKE2b-256 | a3cb318409d20ea9840571ea3e3b37968161005fe367d1cc6bb06decc83871e3 |
Hashes for pyopal-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b4fd962e199a6b3ab16d225e2b9fa84f312dba03c4073abb9bf9aa9844dd7ce |
|
MD5 | dfe3498465ba6535a606e1be94922a87 |
|
BLAKE2b-256 | 7fad363c0ac2235088d42a240e60d5493c4a90b9d2cf745bbb9e9ef37fa42f29 |
Hashes for pyopal-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95d2be11df8b22b92d1c13365975fc2f07bd0623d75c11f9caf32c5b6539d9ee |
|
MD5 | 8cb5f36a7d8a2483cf1e8475ce0cdb2d |
|
BLAKE2b-256 | b35bfe6f79f3dac091d58fdfb9aa96890fccbf2370f1ad49f7ad3a3c8dff22c1 |
Hashes for pyopal-0.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2b9bb4b6635c4bccefe875ed4a357a17577c6236ff788671297eb1673c01af5 |
|
MD5 | 506ba4cb0b1fa1a8c08fbbe81717bb3c |
|
BLAKE2b-256 | 6a75ad3a0b154ad5d230b2505e266fd941ef433787e5fd99d51480515966d513 |
Hashes for pyopal-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22aafc703d4c0156db5e6cc492bf1f2b9304fb3a2326b7857c6ad426bbb93a5b |
|
MD5 | 77cbeb763fe2c7cfc7d219dba3929ab1 |
|
BLAKE2b-256 | 41e6748885c96d48ae8d530cdf5546efde8c5e8923aa4b6480e34e41baf7a2cd |
Hashes for pyopal-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 440e56b3e9b2163dbabb638cff15fffff022434d58131639c3823db4d0d57d0d |
|
MD5 | 456770fa290205f531be4c50fb4ed45a |
|
BLAKE2b-256 | 709b72042fc94cd350441a772f658f7f485fc9a0d2acd51b53866cd47bf9762a |
Hashes for pyopal-0.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db7a366cd44c05eee65b12b3a303b93c6a67a1dbb0025bb7bd91a2f5fe01d98f |
|
MD5 | 0b2aa5de01f6dc5b75197a99677fe322 |
|
BLAKE2b-256 | bf3bd1116df5f792757d5e80770a9c6acfb4b9e2b1718e7fe6f6013fd812880e |
Hashes for pyopal-0.1.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ce6bc56115dd24c7ffc46df8903f54f2a0e19151537a16cb7b7dc4dc1cb8c0c |
|
MD5 | f84da89bc2ad29a6ff1242510ebbe4ab |
|
BLAKE2b-256 | 23ccf8a6627ef98bab5ce4758f4690f764d261233e73b088a0b206fca3f2d68b |
Hashes for pyopal-0.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae024302f664978fe2eff5a37aa8d595430d7983bf81ec0d54521b7ebf107c4b |
|
MD5 | fcb0f796a09c11e7b8ca1190be9f0146 |
|
BLAKE2b-256 | 3d74c095dbb3b8c8fd15fe768b59b274bd9d96858ccc2d5941f7043efd1422cc |
Hashes for pyopal-0.1.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f34b6e5ee61a0422a1087eae444c2425fb84f098d11f672247c2fb84792c444 |
|
MD5 | 2e0fbc8041d9efd2b68f8c5c6e88972f |
|
BLAKE2b-256 | 154b6daa830869b772c1aea5e80ec04230230449a28f95c71004d71393a2e641 |
Hashes for pyopal-0.1.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9c18853130f2f14d8b00ba6132c3fe471bf41be582f4fc2ad51cfe5ebedb0d1 |
|
MD5 | 6a8981200ff80cdee07daf11f29da6e4 |
|
BLAKE2b-256 | 5c30fe82484e9b0b504aea85b2a9a1376516ab8d4ca0347607c2836129353243 |