Skip to content

Repository files navigation

MultiStructRNA

Python 3.10+ License: MIT Tests

MultiStructRNA is a unified Python interface for RNA secondary structure prediction using multiple state-of-the-art algorithms. It provides a consistent API for predicting RNA secondary structures, calculating thermodynamic properties, and visualizing results.

Features

  • Unified API: Single interface for multiple prediction algorithms
  • Multiple Algorithms: Support for LinearFold, LinearPartition, ViennaRNA, and RNAstructure
  • SHAPE Support: Incorporate experimental SHAPE reactivity data
  • Visualization: Generate publication-ready structure plots
  • Metrics: Calculate thermodynamic properties and structural metrics
  • CLI: Command-line interface for quick predictions

Supported Algorithms

Algorithm Type Description
linearfold MFE Fast linear-time MFE structure prediction
linearpartition Partition Fast linear-time partition function calculation
viennafold MFE ViennaRNA MFE structure prediction
viennapartition Partition ViennaRNA partition function calculation
rnastructurefold MFE RNAstructure MFE prediction
rnastructurepartition Partition RNAstructure partition function

Installation

Using pixi (recommended)

pixi install
pixi run setup-deps  # Install external binaries

Using pip

pip install multistructrna
multistructrna setup  # Install external binaries

Using uv

uv pip install multistructrna

From source

git clone https://github.com/modernatx/multistructrna.git
cd multistructrna
pip install -e ".[dev]"

External Dependencies

Some algorithms require external binaries. Run the setup command to install them:

multistructrna setup

This will install:

  • LinearFold/LinearPartition: Cloned and compiled from GitHub
  • ViennaRNA: Check installation (install via conda: conda install -c bioconda viennarna)
  • RNAstructure: Instructions for manual installation

MXFold2 is optional. For the most stable baseline setup:

multistructrna setup --no-mxfold2

If you need MXFold2 later, follow the dedicated environment instructions in docs/howto/installation.md.

Quick Start

Python API

from multistructrna import MSRNA

# Create an RNA object
rna = MSRNA(seq="GUCACUAGUCCCAUUUCCUUGGCCUGAAAUGGUUUGUGAGGAGUCCGCGU", name="my_sequence")

# Predict structure using LinearPartition
rna.predict(algorithm="linearpartition", output_dir="/tmp")

# Access results
print(f"Structure: {rna.dotbracket}")
print(f"Free Energy of Ensemble: {rna.fee} kcal/mol")
print(f"Average Unpaired Probability: {rna.aup:.4f}")
print(f"Maximum Ladder Distance: {rna.mld}")

# Visualize the structure
rna.plot(plot_type="secondary_structure", output_dir="./output", show=True)

Using SHAPE Data

# Predict with SHAPE reactivity constraints
rna.predict(
    algorithm="linearpartition",
    output_dir="/tmp",
    shape="/path/to/shape_file.shape",
)

Command Line

# Predict structure
multistructrna predict AUGCUAGCUAGCUAGC --algorithm linearfold

# Predict with options
multistructrna predict AUGCUAGCUAGCUAGC \
    --algorithm linearpartition \
    --name my_sequence \
    --output-dir ./results \
    --temperature 37.0

# Show version
multistructrna version

Output Metrics

Depending on the algorithm, MultiStructRNA provides:

Metric Description Algorithms
dotbracket Secondary structure in dot-bracket notation All
mfe Minimum Free Energy (kcal/mol) Fold algorithms
fee Free Energy of Ensemble (kcal/mol) Partition algorithms
aup Average Unpaired Probability Partition algorithms
mld Maximum Ladder Distance All
bpps_matrix Base Pair Probability Matrix Partition algorithms
avg_shannon_entropy Average Shannon Entropy Partition algorithms

Documentation

For full documentation, visit the docs directory or run:

mkdocs serve

Development

Setup Development Environment

# Using pixi
pixi install -e dev
pixi run test

# Using pip
pip install -e ".[dev]"
pytest tests/

Running Tests

pytest tests/ -v

Code Quality

# Format code
black multistructrna tests

# Lint code
ruff check multistructrna tests

# Type checking
mypy multistructrna

Citation

If you use MultiStructRNA in your research, please cite:

@software{multistructrna,
  title = {MultiStructRNA: A Unified Interface for RNA Secondary Structure Prediction},
  author = {Jadeja, Yashrajsinh},
  year = {2024},
  url = {https://github.com/modernatx/multistructrna}
}

Please also cite the underlying tools you use:

  • LinearFold/LinearPartition: Huang et al., 2019
  • ViennaRNA: Lorenz et al., 2011
  • RNAstructure: Mathews Lab

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Acknowledgments

  • LinearFold/LinearPartition: Liang Huang Lab
  • ViennaRNA: TBI Vienna
  • RNAstructure: Mathews Lab, University of Rochester
  • RiboGraphViz: Das Lab, Stanford
  • RNAvigate: Weeks Lab, UNC Chapel Hill

About

MultiStructRNA is a unified Python interface for RNA secondary structure prediction using multiple state-of-the-art algorithms. It provides a consistent API for predicting RNA secondary structures, calculating thermodynamic properties, and visualizing results.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages