Skip to main content

MDAnalysis tool to calculate membrane curvature from MD simulations.

Project description

Membrane Curvature

Powered by MDAnalysis GitHub Actions Status codecov docs Ruff ty License

Python versions PyPI Conda version

MembraneCurvature is an MDAnalysis tool to calculate membrane curvature from Molecular Dynamics simulations.

Features

With MembraneCurvature you can:

  • Calculate mean and Gaussian curvature from MD simulations.
  • Derive 2D curvature profiles from atoms of reference with two different methods: binning or Fourier-based.
  • Get per-frame or averaged results for surface, mean and Gaussian curvature.
  • Live a happier life.

Installation

The main dependency in MembraneCurvature is MDAnalysis. You can find instructions to install the latest stable version of MDAnalysis in the UserGuide.

MembraneCurvature is available via pip:

pip install membrane-curvature

To install from source:

git clone https://github.com/MDAnalysis/membrane-curvature.git
cd membrane-curvature
python -m pip install -e .

Some of the examples included in the MembraneCurvature documentation use test data from MDAnalysisTests and MDAnalysisData. To install these dependencies with conda, run:

conda install -c conda-forge MDAnalysisTests MDAnalysisData

or via pip:

pip install --upgrade MDAnalysisTests MDAnalysisData

Usage

This is a quick example on how to run MembraneCurvature with the default surface method (Fourier):

import MDAnalysis as mda
from membrane_curvature import MembraneCurvature
from MDAnalysis.tests.datafiles import Martini_membrane_gro

universe = mda.Universe(Martini_membrane_gro)

# run with the default surface_method - Fourier
curvature_upper_leaflet = MembraneCurvature(universe,
                                            select='resid 1-225 and name PO4'
                                            ).run()

# extract average mean curvature
mean_upper_leaflet = curvature_upper_leaflet.results.z_surface

# extract average mean curvature
mean_upper_leaflet = curvature_upper_leaflet.results.mean

# extract average Gaussian curvature
gaussian_upper_leaflet = curvature_upper_leaflet.results.gaussian

In this example, we use the PO4 beads in the upper leaflet as reference to derive a surface and calculate its respective mean and Gaussian curvature. If you want per-frame arrays instead, use results.z_surface, results.mean, and results.gaussian.

The same example run with the binning surface method looks like:

import MDAnalysis as mda
from membrane_curvature import MembraneCurvature
from MDAnalysis.tests.datafiles import Martini_membrane_gro

universe = mda.Universe(Martini_membrane_gro)

# run with the binning surface_method
curvature_upper_leaflet_binning = MembraneCurvature(universe,
                                                    select='resid 1-225 and name PO4',
                                                    surface_method='binning',
                                                    n_x_bins=8,
                                                    n_y_bins=8,
                                                    wrap=True).run()

# extract average mean curvature
mean_upper_leaflet_binning = curvature_upper_leaflet_binning.results.z_surface

# extract average mean curvature
mean_upper_leaflet_binning = curvature_upper_leaflet_binning.results.mean

# extract average Gaussian curvature
gaussian_upper_leaflet_binning = curvature_upper_leaflet_binning.results.gaussian

You can find more examples on how to run MembraneCurvature in the Usage page. To plot results from MembraneCurvature please check the Visualization page.

Documentation

To help you get the most out of MembraneCurvature, we have documentation available where you can find:

  • The standard API documentation.
  • Quick examples of how to run MembraneCurvature in the Usage page.
  • Detailed explanation of the Algorithm implemented in MembraneCurvature.
  • Examples on how to plot the results obtained from MembraneCurvature in the Visualization page.
  • Detailed Tutorials to run MembraneCurvature in membrane-only and membrane-protein systems.

Contributing

Contributions are very welcome!

MembraneCurvature is compatible with uv (recommended for development):

# create an environment and install the project + dev tools
uv sync --extra dev

# add test dependencies and run the test suite
uv sync --extra dev --extra tests
uv run pytest

This repository uses pre-commit hooks to run quick checks before commits such as whitespace cleanup, TOML/YAML validation, and Ruff linting/formatting. Using these hooks is highly encouraged because it helps catch common issues early and keeps pull requests easier to review.

To set up hooks locally, with with uv:

uv sync --extra dev
uv run pre-commit install

Or with pip:

pip install -e ".[dev]"
pre-commit install

Interested in becoming a maintainer? We welcome your passion and expertise to help shape and grow this open-source project! Please contact estefania@ojeda-e.com for more details.

License

Source code included in this project is available in the GitHub repository https://github.com/MDAnalysis/membrane-curvature under the GNU General Public License v3 (see LICENSE).

MembraneCurvature was developed as a Google Summer of Code 2021 project with MDAnalysis and it is linked to a Code of Conduct.

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

membrane_curvature-2.0.0rc1.tar.gz (4.3 MB view details)

Uploaded Source

Built Distribution

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

membrane_curvature-2.0.0rc1-py3-none-any.whl (4.3 MB view details)

Uploaded Python 3

File details

Details for the file membrane_curvature-2.0.0rc1.tar.gz.

File metadata

  • Download URL: membrane_curvature-2.0.0rc1.tar.gz
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for membrane_curvature-2.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 dcdcdc97ee067484ccb7b00b958e74f7a2d05d16fd9470e02755d1a840a86bce
MD5 8a77b8ef2ca6abe2c120df11b44c9c66
BLAKE2b-256 7094b1cf6be47d7185ddff63d1eae5d861ea93dd675ec79aa25fe3cb3206942b

See more details on using hashes here.

Provenance

The following attestation bundles were made for membrane_curvature-2.0.0rc1.tar.gz:

Publisher: deploy.yaml on MDAnalysis/membrane-curvature

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file membrane_curvature-2.0.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for membrane_curvature-2.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec8e3c33a966a853db4bc04958b500c221335851ba22a9f2dc422aad2c222134
MD5 ed66006c8b4d02df9257129215f235cf
BLAKE2b-256 802a998b40ab5f5012b46f133c157b2cb11eed1c363ecb68ff0427f2f84f7842

See more details on using hashes here.

Provenance

The following attestation bundles were made for membrane_curvature-2.0.0rc1-py3-none-any.whl:

Publisher: deploy.yaml on MDAnalysis/membrane-curvature

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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