MembraneCurvature is an MDAnalysis MDAKit to calculate membrane curvature from Molecular Dynamics simulations.
With MembraneCurvature you can:
- Derive 2D surface profiles from MD simulations using an atom selection as reference with twodifferent methods: binning or Fourier.
- Calculate the mean and Gaussian curvatures of the derived surfaces.
- Get per-frame or averaged results for surface, mean and Gaussian curvature.
- Live a happier life.
MembraneCurvature is available via pip and conda. Please refer to the Installation section in the Getting Started Documentation page for detailed installation instructions.
MembraneCurvature is available via pip:
pip install membrane-curvatureOr to install from source:
git clone https://github.com/MDAnalysis/membrane-curvature.git
cd membrane-curvature
python -m pip install -e .MembraneCurvature is available via conda:
conda install -c conda-forge membrane-curvatureOr 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 MDAnalysisDataor via pip:
pip install --upgrade MDAnalysisTests MDAnalysisDataThis 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.gaussianIn 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.
To access the per-frame arrays for the example above, use results.z_surface[<frame_id>], results.mean[<frame_id>], and results.gaussian[<frame_id>]:
# to access the surface for the first frame
surface_first_frame = curvature_upper_leaflet.results.z_surface[0]
# access the mean curvature for the last frame
mean_last_frame = curvature_upper_leaflet.results.mean[-1]
# access the Gaussian curvature for the frame 10
gaussian_frame_10 = curvature_upper_leaflet.results.gaussian[10]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.gaussianYou can find more examples on how to run MembraneCurvature in the Usage page. To plot results from MembraneCurvature please check the Visualization page.
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.
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 pytestThis 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 uv:
uv sync --extra dev
uv run pre-commit installOr with pip:
pip install -e ".[dev]"
pre-commit installInterested 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.
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.
