Skip to content

Repository files navigation

MembraneCurvature

Powered by MDAnalysis GitHub Actions Status codecov docs Ruff ty License

Python versions PyPI Conda version

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

Features

With MembraneCurvature you can:

  • Derive 2D surface profiles from MD simulations using an atom selection as reference with three different methods via the surface_method parameter: 'fourier' (default), 'binning', or 'binning_nearest'.
  • Calculate mean and Gaussian curvature from the derived surface.
  • Choose where curvature is evaluated with the curvature_on parameter: 'per_frame', to get per-frame curvature maps, or 'average_surface', to get curvature from the time-averaged surface.
  • Control the surface calculation for the binning methods with two optional parameters:
    • padding: periodic edge padding to reduce finite difference artifacts.
    • fft_filter: a brick-wall FFT filter to remove high-frequency noise from the averaged surface.

Installation

MembraneCurvature is available via pip and conda. Please refer to the Installation section in the Getting Started Documentation page for detailed installation instructions.

With pip

MembraneCurvature is available via pip:

pip install membrane-curvature

Or to install from source:

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

With conda

MembraneCurvature is available via conda:

conda install -c conda-forge membrane-curvature

Or to install from source:

git clone https://github.com/MDAnalysis/membrane-curvature.git
cd membrane-curvature
conda env create -f devtools/conda-envs/environment.yaml
conda activate 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

Basic usage

MembraneCurvature requires at least two inputs: a universe and an atom selection. The universe is the object with coordinates and trajectory information, and the atom selection is the atoms of reference to derive the surface from.

The following example shows how to run MembraneCurvature with the default surface method (Fourier) using the PO4 beads in the upper leaflet as atoms of reference to derive curvature:

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 all default values
curvature_upper_leaflet = MembraneCurvature(universe,
                                            select='resid 1-225 and name PO4',
                                            ).run()

average_surface = curvature_upper_leaflet.results.average_z_surface

mean_upper_leaflet = curvature_upper_leaflet.results.average_mean

gaussian_upper_leaflet = curvature_upper_leaflet.results.average_gaussian

MembraneCurvature supports three surface methods: Fourier, binning, and binning-nearest. Each method has its own set of parameters that can be used to control the surface calculation. For more examples on how to run MembraneCurvature using the different surface methods, please check 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 follows the MDAnalysis AI Policy. As a scientific software package, contributions should show real understanding of the code and the science. Please read the Contributing page before opening a pull request. Pull requests that are evidently LLM-generated may be closed at the maintainers' discretion.

If you are interested in contributing to MembraneCurvature, installation of the development dependencies is required.

There are three dependency groups defined in pyproject.toml:

  • dev: development tools (includes tests and docs).
  • tests: testing dependencies.
  • docs: documentation build dependencies (e.g. Sphinx, themes).

Note that by installing the dev group, the tests and docs dependency groups are also installed.

We recommend using uv as a development environment for MembraneCurvature. To set up a uv dev environment, clone the repository and move to the root directory:

git clone https://github.com/MDAnalysis/membrane-curvature.git
cd membrane-curvature

To create a new uv environment and install the dependencies included in the dev group, run:

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

By syncing the dev group with uv, all the development dependencies are installed. MembraneCurvature 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 run the hooks manually without committing:

uv run pre-commit run --all-files

For instructions on how to create a development environment with pip, see the Installing development dependencies with pip page.

For more information on how to contribute to MembraneCurvature, see the Contributing page.

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.

About

MDAnalysis tool to calculate membrane curvature.

Topics

Resources

Code of conduct

Contributing

Stars

36 stars

Watchers

7 watching

Forks

Releases

Used by

Contributors

Languages