Skip to main content

Cython bindings and Python interface to the MEME suite.

Project description

🐍Ⓜ️ pyMEMEsuite Stars

Cython bindings and Python interface to the MEME suite, a collection of tools for the analysis of sequence motifs.

Actions Coverage PyPI Wheel Python Versions Python Implementations License Source GitHub issues Docs Changelog Downloads

🗺️ Overview

The MEME suite is a collection of tools used for discovery and analysis of biological sequence motifs.

pymemesuite is a Python module, implemented using the Cython language, that provides bindings to the MEME suite. It directly interacts with the MEME internals, which has the following advantages over CLI wrappers:

  • single dependency: If your software or your analysis pipeline is distributed as a Python package, you can add pymemesuite as a dependency to your project, and stop worrying about the MEME binaries being properly setup on the end-user machine.
  • no intermediate files: Everything happens in memory, in Python objects you have control on, making it easier to pass your inputs to MEME without needing to write them to a temporary file. Output retrieval is also done in memory.

This library is still a work-in-progress, and in an experimental stage, but it should already pack enough features to run biological analyses or workflows involving FIMO.

🔧 Installing

pymemesuite can be installed from PyPI, which hosts some pre-built CPython wheels for x86-64 Linux, as well as the code required to compile from source with Cython:

$ pip install pymemesuite

💡 Example

Use MotifFile to load a motif from a MEME motif file, and display the consensus motif sequence followed by the letter frequencies:

from pymemesuite.common import MotifFile

with MotifFile("tests/data/fimo/prodoric_mx000001_meme.txt") as motif_file:
    motif = motif_file.read()

print(motif.name.decode())
print(motif.consensus)

for row in motif.frequencies:
    print(" ".join(f'{freq:.2f}' for freq in row))

Then use FIMO to find occurences of this particular motif in a collection of sequences, and show coordinates of matches:

import Bio.SeqIO
from pymemesuite.common import Sequence
from pymemesuite.fimo import FIMO

sequences = [
    Sequence(str(record.seq), name=record.id.encode())
    for record in Bio.SeqIO.parse("tests/data/fimo/mibig-genes.fna", "fasta")
]

fimo = FIMO(both_strands=False)
pattern = fimo.score_motif(motif, sequences, motif_file.background)

for m in pattern.matched_elements:
    print(
        m.source.accession.decode(),
        m.start,
        m.stop,
        m.strand,
        m.score,
        m.pvalue,
        m.qvalue
    )

You should then get a single matched element on the forward strand:

BGC0002035.1_3425_15590 6700 6714 + 9.328571428571422 1.1024163606971822e-05 0.6174858127445146

📋 Features

🧶 Thread-safety

FIMO objects are thread-safe, and the FIMO.score_motif and FIMO.score_pssm methods are re-entrant. This means you can search occurences of several motifs in parallel with a ThreadPool and a single FIMO instance:

from multiprocessing.pool import ThreadPool
from pymemesuite.fimo import FIMO

fimo = FIMO()
with ThreadPool() as pool:
    patterns = pool.map(
        lambda motif: fimo.score_motif(motif, sequences, background),
        motifs
    )

📌 Roadmap

  • error management: Make sure to catch exceptions raised by the MEME core without exiting forcefully.
  • transfac: Support for TRANSFAC motifs in addition to MEME motifs.
  • meme: Motif discovery through enrichment analysis between two collections of sequences.

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

⚖️ License

This library is provided under the MIT License. The MEME suite code is available under an academic license which allows distribution and non-commercial usage. See vendor/meme/COPYING for more information.

Test sequence data were obtained from MIBiG and are distributed under the CC BY 4.0 license. Test motifs were obtained from PRODORIC and are distributed under the CC BY-NC 4.0 license.

This project is in no way affiliated, sponsored, or otherwise endorsed by the original MEME suite 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

pymemesuite-0.1.0a1.tar.gz (3.6 MB view hashes)

Uploaded Source

Built Distributions

pymemesuite-0.1.0a1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (2.3 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pymemesuite-0.1.0a1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (2.3 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pymemesuite-0.1.0a1-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

pymemesuite-0.1.0a1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (2.3 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pymemesuite-0.1.0a1-pp36-pypy36_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ x86-64

pymemesuite-0.1.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (8.6 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

pymemesuite-0.1.0a1-cp310-cp310-macosx_10_15_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

pymemesuite-0.1.0a1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (8.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

pymemesuite-0.1.0a1-cp39-cp39-macosx_10_15_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

pymemesuite-0.1.0a1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (8.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

pymemesuite-0.1.0a1-cp38-cp38-macosx_10_15_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

pymemesuite-0.1.0a1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (8.6 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

pymemesuite-0.1.0a1-cp37-cp37m-macosx_10_15_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

pymemesuite-0.1.0a1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (8.6 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

pymemesuite-0.1.0a1-cp36-cp36m-macosx_10_14_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

Supported by

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