Skip to main content

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

Project description

🐍🌈🪨 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.

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.
  • 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.

🔧 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyopal-0.2.0.tar.gz (102.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyopal-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (356.0 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pyopal-0.2.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl (221.6 kB view details)

Uploaded PyPymacOS 10.12+ x86-64

pyopal-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (359.2 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pyopal-0.2.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl (221.9 kB view details)

Uploaded PyPymacOS 10.12+ x86-64

pyopal-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (360.0 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pyopal-0.2.0-pp37-pypy37_pp73-macosx_10_12_x86_64.whl (222.0 kB view details)

Uploaded PyPymacOS 10.12+ x86-64

pyopal-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyopal-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyopal-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

pyopal-0.2.0-cp310-cp310-macosx_10_15_x86_64.whl (318.5 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

pyopal-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyopal-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

pyopal-0.2.0-cp39-cp39-macosx_10_15_x86_64.whl (318.5 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

pyopal-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pyopal-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

pyopal-0.2.0-cp38-cp38-macosx_10_15_x86_64.whl (315.4 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

pyopal-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

pyopal-0.2.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ ARM64

pyopal-0.2.0-cp37-cp37m-macosx_10_15_x86_64.whl (313.3 kB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

pyopal-0.2.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

pyopal-0.2.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ ARM64

pyopal-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl (316.5 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file pyopal-0.2.0.tar.gz.

File metadata

  • Download URL: pyopal-0.2.0.tar.gz
  • Upload date:
  • Size: 102.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for pyopal-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ada82e9c286073600aec1e70273311d30a21a49f905079680a86d460035c972b
MD5 23b93f426a4402f85e72c1ada0a79444
BLAKE2b-256 d5d79d5e4c009a9d67b6987f4766fe86cec8dce2d550c062dad7168bba987016

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 67854d0aa0dd10d37440dff228c42fc538ac4e95532839be529686df603404a2
MD5 3f92e4abcfcb0ce401d41d781947c986
BLAKE2b-256 32b7ff75b8879b4956a575543f6175bcbc37245ae3ef01f4ce8fab0f8604a657

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e21e6cd5e4816d1201ef0d83f4b05c36041110041458e3164e907c5a14502120
MD5 41a9ff477a235e41d8d304153d8f4ca0
BLAKE2b-256 a56789bfbb1c9746f03aa92aa6eb1fac55a74c470333f24ed8f1c54bdf9feb5b

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2aecdc78b0acb8b67b0fb22b55a95e96652834f999390ca3f7c294bf76a1ef75
MD5 182776d9473dc143d849e94602ef73d7
BLAKE2b-256 454428090ad8e61f2fd37ad10b717bd88c32a280c5fb2982846320ddca8930e5

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 44cd06cc983a8f16b2429ee0ec920beada11bf7c8d0a976905a3ad76dd1d3194
MD5 a6307200529fc56c7e2647c0dd80de64
BLAKE2b-256 0d5506d1a77c4afeb8bb4d63a8e3d1bacc9b259cc1cfbd0e7d31387eb16ed43d

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9f60d76b26e8412a65091cdd4e312b83f4a331d22a31ce6fa0404b173362ab1
MD5 69abaa1ddcbb14fb9c96501ff7143130
BLAKE2b-256 31d056cd6a742db503e72e2a58c54209abacdedd20fd73901d8d42d7fa37611b

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-pp37-pypy37_pp73-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-pp37-pypy37_pp73-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6f9cdd46e48d89d218f81a4b2df0d220c6137e069de64c9055f92a0d247fad2d
MD5 0755668ceb1c8e0d88cfa6be5388b67f
BLAKE2b-256 05cf927c302b71c30967eafa276abfdaf447132f895cd9ceda96077a189991b6

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e4e88cc36a79e91547f1196041cc0525abfd6f90b0016acde42b258a3e365f4
MD5 06a58836f52c2025fe5b3477b4db7357
BLAKE2b-256 39183c5a94696b21ba7158640597279150cebdd8f16ea6526625815d8545d29b

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 448845fc3c26c9a54b0dfeed87bfdf29d704040cb4f5abbf347b6974de6a88e3
MD5 738d1584b3d6573a32fdefff30a3e3c9
BLAKE2b-256 5e875a8cec9daeb60c6a8a362b384a640f0dcabca0381c626183cc3340a0d213

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 490298b7d1edb9f15117de7fdb6ee36720f001d08f43ab5eac9c6171a3aa1b9c
MD5 75a674f356c02f763e58c892313bfc91
BLAKE2b-256 be1b14d2e9878182897d7168726dcd7ea5f1ff44f022fcfe92fa0007b7b4d55b

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 1a104c589dc67c8371450b7f7e37c127d2715bde6da471e9931beb7a8de14643
MD5 7f9e380f4fe3a133df9b0281cdc3797a
BLAKE2b-256 77619eade408a978fb64594fc51e29ec12777d4461e854db0efd59906c633501

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0272729a9f261a1bf55315d7355b1ee165bc328fc8ed2e037661cd9bdeeb4b2b
MD5 8bb7ef594c27d846bde58ce0f251508f
BLAKE2b-256 fcb9893376454c7fe2245285dae105f9286106c22a8355cb127d3f529a659560

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c313e5b270698ebd3fd833853dbcc5c57b852ae81e198b1c289e49780d3503ae
MD5 f3ec3652782616198833dcfa366b323f
BLAKE2b-256 e8d34e4f0957b4228bc3591d913abe7ee9219457028d707d02f8abdab7fa57bf

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9bd4e30f77082d132c6f1bec77b218553f1c5b9d12fecb680d19a9433c6c8d1e
MD5 8fcf0219384b5562653231e75da2b363
BLAKE2b-256 41ac4c891660ed03934c31dc0a1e76092ca086d9bb5926e8d9b6eca22021cbbb

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 822e4df6b3456bf46b55e2e87a5f71dc7804c02017f9ade603eb9866a75e0f04
MD5 fe7988abceb4c4aab8b8008a69253b0d
BLAKE2b-256 da938babb64b9b5dbaeb8f703be7db7c0f541250a037f74f97c794e857ee50c5

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5d65bb551365b07d39bd2127901c8c121fd0d871ac06fb6030da76d7de4ea026
MD5 d1b19614e76eeaefcfccfdc5b7f1acd1
BLAKE2b-256 aaf8051c0f3dba57e388191e1c25b4bdfef32e622726e6796a4b261b913c77d5

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ff9e12b91ac3ed0445c9f54b597aca07739ec6082f5b99b93106fd4936f05924
MD5 54c54ac70b88e6b0b245f71417850169
BLAKE2b-256 9d7ddc3335847183ad140a0a97d58b152150232f520552956ccdca7858026927

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed131c3b626f55ccc22927fcf69fc67b3aea2b20c5f237101902706957690c58
MD5 b003c4a56c63ee6fe9e8a6de6ebea0a0
BLAKE2b-256 aa55a86cc4bcea7664b684b2851dcc6c314e242f5c0985473faeeeb5873b2ff4

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c1f6882441b1f8afb29e7852e04078938ce68a6f541962f1f30d59b09d47fd15
MD5 372b0eb7fa77a7fde1572acaa62ddd3a
BLAKE2b-256 335f88c73215e099ea5a07c5a3c058d815acbeaf88fa4507f94e7a5e8c40b272

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ed55bd660cd19a22f63639a2af0439b5e91597fd41def868ca91ae1fd29201c9
MD5 cd5346c178429d94f3d00e9c39bb5b17
BLAKE2b-256 0a699934a8e288c4b6706bce994297c27f49de1e7f00bfa8d6002804ef258f7d

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5eb8395a255ef76b9578d494f2020f4515da3eff5616a9ac11eee0e491b4fa02
MD5 320d4cfb2522797ea9c359b3b660ad60
BLAKE2b-256 bce3fa7568bad820c5dcba4e1a659b54b95e5ac8e5538f93e28abe8ab023060a

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8d4601d491493c505d5e471e33b8634f597fb1ae2e5b8af9e6b9cb404e288647
MD5 8f4cc19f6366f5305ff123e255c3ff00
BLAKE2b-256 d91ffe1061e3391de610a0483004c6f7453a8aeec3181621e01ceccf001e43fc

See more details on using hashes here.

File details

Details for the file pyopal-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for pyopal-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 06419a02e9e8a577a5506e088c0a0f605e4e394083186bdbac78e755955ebc88
MD5 16867b1ef31c8cd09f0da8f2bddd0238
BLAKE2b-256 c407d9c0fd391acfcb89967d91b9e5bf962644f4524aee193f4d027e9a779021

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page