Skip to main content

Predict the minimum free energy structure of nucleic acids

Project description

seqfold

PyPI version DOI

Predict the minimum free energy structure of nucleic acids.

seqfold is an implementation of the Zuker, 1981 dynamic programming algorithm, the basis for UNAFold/mfold, with energy functions from SantaLucia, 2004 (DNA) and Turner, 2009 (RNA).

The folding/Tm engine is written in Rust and exposed to Python through PyO3/maturin.

Installation

pypy3 (recommended)

pypy3 -m ensurepip
pypy3 -m pip install seqfold

For a 200bp sequence (on my laptop), pypy3 takes 2.5 seconds versus 15 seconds for CPython.

Conda

conda install -c bioconda seqfold

Thank you to @jonas-fuchs for this.

pip

pip install seqfold

Prebuilt wheels include the compiled Rust extension, so no Rust toolchain is needed to install.

Usage

Python

from seqfold import fold, dg, dg_cache, dot_bracket

# just returns minimum free energy
dg("GGGAGGTCGTTACATCTGGGTAACACCGGTACTGATCCGGTGACCTCCC", temp = 37.0)  # -13.4

# `fold` returns a list of `seqfold.Struct` from the minimum free energy structure
structs = fold("GGGAGGTCGTTACATCTGGGTAACACCGGTACTGATCCGGTGACCTCCC")
print(sum(s.e for s in structs))  # -13.4, same as dg()
for struct in structs:
    print(struct)  # prints the i, j, ddg, and description of each structure

# `dg_cache` returns a 2D array where each (i,j) combination returns the MFE from i to j inclusive
cache = dg_cache("GGGAGGTCGTTACATCTGGGTAACACCGGTACTGATCCGGTGACCTCCC")

# `dot_bracket` returns a dot_bracket representation of the folding
print(dot_bracket(seq, structs))  # ((((((((.((((......))))..((((.......)))).))))))))

CLI

usage: seqfold [-h] [-t FLOAT] [-d] [-r] [--version] SEQ

Predict the minimum free energy (kcal/mol) of a nucleic acid sequence

positional arguments:
  SEQ                   nucleic acid sequence to fold

optional arguments:
  -h, --help            show this help message and exit
  -t FLOAT, --celcius FLOAT
                        temperature in Celsius
  -d, --dot-bracket     write a dot-bracket of the MFE folding to stdout
  -r, --sub-structures  write each substructure of the MFE folding to stdout
  --version             show program's version number and exit

Examples

$ seqfold GGGAGGTCGTTACATCTGGGTAACACCGGTACTGATCCGGTGACCTCCC --celcius 32
-15.3
$ seqfold GGGAGGTCGTTACATCTGGGTAACACCGGTACTGATCCGGTGACCTCCC --celcius 32 --dot-bracket --sub-structures
GGGAGGTCGTTACATCTGGGTAACACCGGTACTGATCCGGTGACCTCCC
((((((((.((((......))))..((((.......)))).))))))))
   i    j    ddg  description
   0   48   -1.9  STACK:GG/CC
   1   47   -1.9  STACK:GG/CC
   2   46   -1.4  STACK:GA/CT
   3   45   -1.4  STACK:AG/TC
   4   44   -1.9  STACK:GG/CC
   5   43   -1.6  STACK:GT/CA
   6   42   -1.4  STACK:TC/AG
   7   41   -0.5  BIFURCATION:4n/3h
   9   22   -1.1  STACK:TT/AA
  10   21   -0.7  STACK:TA/AT
  11   20   -1.6  STACK:AC/TG
  12   19    3.0  HAIRPIN:CA/GG
  25   39   -1.9  STACK:CC/GG
  26   38   -2.3  STACK:CG/GC
  27   37   -1.9  STACK:GG/CC
  28   36    3.2  HAIRPIN:GT/CT
-15.3

Notes

  • The type of nucleic acid, DNA or RNA, is inferred from the input sequence.
  • seqfold is case-insensitive with the input sequence.
  • The default temperature is 37 degrees Celsius for both the Python and CLI interface.

Motivation

Secondary structure prediction is used for making PCR primers, designing oligos for MAGE, and tuning RBS expression rates.

While UNAFold and mfold are the most widely used applications for nucleic acid secondary structure prediction, their format and license are restrictive. seqfold is meant to be an open-source, minimalist alternative for predicting minimum free energy secondary structure.

seqfold mfold UNAFold
License MIT Academic Non-commercial $200-36,000
OS Linux, MacOS, Windows Linux, MacOS Linux, MacOS, Windows
Format python, CLI python CLI binary CLI binary
Dependencies none (mfold_util) Perl, (gnuplot, glut/OpenGL)
Graphical no yes (output) yes (output)
Heterodimers no yes yes
Constraints no yes yes

Citations

Papers, and how they helped in developing seqfold, are listed below.

Nussinov, 1980

Nussinov, Ruth, and Ann B. Jacobson. "Fast algorithm for predicting the secondary structure of single-stranded RNA." Proceedings of the National Academy of Sciences 77.11 (1980): 6309-6313.

Framework for the dynamic programming approach. It has a conceptually helpful "Maximal Matching" example that demonstrates the approach on a simple sequence with only matched or unmatched bp.

Zuker, 1981

Zuker, Michael, and Patrick Stiegler. "Optimal computer folding of large RNA sequences using thermodynamics and auxiliary information." Nucleic acids research 9.1 (1981): 133-148.

The most cited paper in this space. Extends further than Nussinov, 1980 with a nearest neighbor approach to energies and a consideration of each of stack, bulge, internal loop, and hairpin. Their data structure and traceback method are both more intuitive than Nussinov, 1980.

Jaeger, 1989

Jaeger, John A., Douglas H. Turner, and Michael Zuker. "Improved predictions of secondary structures for RNA." Proceedings of the National Academy of Sciences 86.20 (1989): 7706-7710.

Zuker and colleagues expand on the 1981 paper to incorporate penalties for multibranched loops and dangling ends.

SantaLucia, 2004

SantaLucia Jr, John, and Donald Hicks. "The thermodynamics of DNA structural motifs." Annu. Rev. Biophys. Biomol. Struct. 33 (2004): 415-440.

The paper from which almost every DNA energy function in seqfold comes from (with the exception of multibranch loops). Provides neighbor entropies and enthalpies for stacks, mismatching stacks, terminal stacks, and dangling stacks. Ditto for bulges, internal loops, and hairpins.

Turner, 2009

Turner, Douglas H., and David H. Mathews. "NNDB: the nearest neighbor parameter database for predicting stability of nucleic acid secondary structure." Nucleic acids research 38.suppl_1 (2009): D280-D282.

Source of RNA nearest neighbor change in entropy and enthalpy parameter data. In /data.

Ward, 2017

Ward, M., Datta, A., Wise, M., & Mathews, D. H. (2017). Advanced multi-loop algorithms for RNA secondary structure prediction reveal that the simplest model is best. Nucleic acids research, 45(14), 8541-8550.

An investigation of energy functions for multibranch loops that validates the simple linear approach employed by Jaeger, 1989 that keeps runtime within O(n³).

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

seqfold-0.10.0.tar.gz (51.6 kB view details)

Uploaded Source

Built Distributions

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

seqfold-0.10.0-cp38-abi3-win_arm64.whl (250.1 kB view details)

Uploaded CPython 3.8+Windows ARM64

seqfold-0.10.0-cp38-abi3-win_amd64.whl (263.0 kB view details)

Uploaded CPython 3.8+Windows x86-64

seqfold-0.10.0-cp38-abi3-musllinux_1_2_x86_64.whl (597.1 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

seqfold-0.10.0-cp38-abi3-musllinux_1_2_aarch64.whl (557.0 kB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

seqfold-0.10.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (382.6 kB view details)

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

seqfold-0.10.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (380.9 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

seqfold-0.10.0-cp38-abi3-macosx_11_0_arm64.whl (346.8 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

seqfold-0.10.0-cp38-abi3-macosx_10_12_x86_64.whl (357.6 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file seqfold-0.10.0.tar.gz.

File metadata

  • Download URL: seqfold-0.10.0.tar.gz
  • Upload date:
  • Size: 51.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for seqfold-0.10.0.tar.gz
Algorithm Hash digest
SHA256 93c09d4557818ec221f5663b853bab7b3b7faa1471a004fbe9a67df255dcda3f
MD5 436d5e7169c5d54fd4a25c1cf665b114
BLAKE2b-256 3acb40a9a41cd51b534c028452f26d064aa291a8693e65a48a2750ebdad9a52e

See more details on using hashes here.

File details

Details for the file seqfold-0.10.0-cp38-abi3-win_arm64.whl.

File metadata

  • Download URL: seqfold-0.10.0-cp38-abi3-win_arm64.whl
  • Upload date:
  • Size: 250.1 kB
  • Tags: CPython 3.8+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for seqfold-0.10.0-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 c64394d1b69808be3574c8def17b04527506f918d224006042f783ec4456177c
MD5 334807740ca030ef6fd6c5abd990dde0
BLAKE2b-256 5fb082f6b74d9a2412d937e3d4964038ca4c6df376331ab290bae4a574ede69f

See more details on using hashes here.

File details

Details for the file seqfold-0.10.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: seqfold-0.10.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 263.0 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for seqfold-0.10.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c8ce1e98911b379b6a49516e599c72ced4a8caf37538568e11b48792eda6c5b2
MD5 d568bdf52a2b6926bc8df59157e9d1bc
BLAKE2b-256 e5d24238cfc0a8969211b8b0795c554de8a77768c975b92c071c04f783192474

See more details on using hashes here.

File details

Details for the file seqfold-0.10.0-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: seqfold-0.10.0-cp38-abi3-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 597.1 kB
  • Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for seqfold-0.10.0-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b39a2289e3d5bd20ad3973804d3fe948dfada7d1521823174bc546636dbb65ec
MD5 727f164ed80f84c1ca8d57e2d25779a4
BLAKE2b-256 d3f57d5572078de09d55ade7965ae9ca8a254126099a1839e43c88598b04c119

See more details on using hashes here.

File details

Details for the file seqfold-0.10.0-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

  • Download URL: seqfold-0.10.0-cp38-abi3-musllinux_1_2_aarch64.whl
  • Upload date:
  • Size: 557.0 kB
  • Tags: CPython 3.8+, musllinux: musl 1.2+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for seqfold-0.10.0-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a5ef5a967c24efb08e2760030f128bbf334fbc26377a462c60770ef08e93e13c
MD5 f658e51a1ea3f7a5453b95c1c07f8314
BLAKE2b-256 fee8bd184cc1185db0fdf675a9b9ff8461e8a22331c782d8702e68472b26efc9

See more details on using hashes here.

File details

Details for the file seqfold-0.10.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: seqfold-0.10.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 382.6 kB
  • Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for seqfold-0.10.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f7f20d385ab998220462340e8fadd53a824541b06a02c6b2b766a58912a40c9
MD5 03561153d977c4c01e44643218ffcaaa
BLAKE2b-256 8233de991991f3a608fdba09598f89d398dd8ce85dda54bb8e1b4a37738342dd

See more details on using hashes here.

File details

Details for the file seqfold-0.10.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: seqfold-0.10.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 380.9 kB
  • Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for seqfold-0.10.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5f49c6a54e8f261cae55b6c1d6ea6183f066bf22d8d0da2f3cd06688ede13f92
MD5 daef33a2269c7dd3887c5a9acf9fb5f7
BLAKE2b-256 acbd77b94a39de654d6ef8527b6d88ccf045378598926750ef754653d8a3d240

See more details on using hashes here.

File details

Details for the file seqfold-0.10.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: seqfold-0.10.0-cp38-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 346.8 kB
  • Tags: CPython 3.8+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for seqfold-0.10.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe69a43c39a8616644d50a5e9d207684bfe4e1cbe44cb0e16a747013e6f73ce0
MD5 2fce6e2eb84094f00e68e1653859f200
BLAKE2b-256 cbdb576e216177bb562f8cb296532da822d2a2e2b49674e5658e3e50a22ca10e

See more details on using hashes here.

File details

Details for the file seqfold-0.10.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: seqfold-0.10.0-cp38-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 357.6 kB
  • Tags: CPython 3.8+, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for seqfold-0.10.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e4b4e4bbe0f08d23881c532f64eeadd3c211ba9fcb5d53f17cb7cf224dd17c1b
MD5 65247112a5fd4bce572d0f5f9ccad4c4
BLAKE2b-256 9672c441aa80df15ac28d6fa296da749a0474890ce975856778fc9758a68c16a

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