### Install Rust Source: https://lipyphilic.readthedocs.io/en/latest/contributing.html Installs Rust using the official script and sets up the environment variables. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env ``` -------------------------------- ### Initialize AssignLeaflets Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/leaflets/assign_leaflets.html Create an AssignLeaflets object with a universe and lipid selection. This is the basic setup for leaflet assignment. ```python import MDAnalysis as mda import lipyphilic as lpp u = mda.Universe(tpr, trajectory) leaflets = lpp.AssignLeaflets( universe=u, lipid_sel="name GL1 GL2 ROH" ) ``` -------------------------------- ### Flip Flop Analysis Setup and Execution Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/flip_flop.html Sets up trajectory frames, prepares for analysis, iterates through residues, performs single-frame analysis, and concludes the process. Use this for detailed flip-flop analysis of molecular dynamics trajectories. ```python def run(self, start=None, stop=None, step=1): """ Run the flip-flop analysis. Parameters ---------- start : int, optional The starting frame of the trajectory. stop : int, optional The ending frame of the trajectory. step : int, optional number of frames to skip between each analysed frame """ self._setup_frames(self._trajectory, start, stop, step) self._prepare() for residue_index, residue_leaflets in tqdm(enumerate(self.leaflets), total=self.membrane.n_residues): self._residue_index = residue_index self._residue_leaflets = residue_leaflets self._single_frame() self._conclude() return self ``` -------------------------------- ### Install Lipyphilic with Mamba Source: https://lipyphilic.readthedocs.io/en/latest/_sources/installation.rst.txt Use this command to create a new conda environment named 'lipyphilic' and install the package from the conda-forge channel. This method installs lipyphilic along with all its dependencies. ```bash mamba create -n lipyphilic -c mamba-forge python=3.11 lipyphilic mamba activate lipyphilic ``` -------------------------------- ### Install Lipyphilic with Pip Source: https://lipyphilic.readthedocs.io/en/latest/_sources/installation.rst.txt Install the lipyphilic package from the Python Package Index using pip. This is a standard method for installing Python packages. ```bash python -m pip install lipyphilic ``` -------------------------------- ### Install LiPyphilic with Mamba Source: https://lipyphilic.readthedocs.io/en/latest/index.html Installs LiPyphilic and its dependencies using Mamba from the conda-forge channel. This is the recommended installation method for ease of use. ```bash mamba install -c conda-forge lipyphilic ``` -------------------------------- ### Install In-Development Version of Lipyphilic with Pip Source: https://lipyphilic.readthedocs.io/en/latest/_sources/installation.rst.txt Install the latest in-development version of lipyphilic directly from its GitHub repository using pip. This is useful for testing the newest features or bug fixes. ```bash python -m pip install https://github.com/p-j-smith/lipyphilic/archive/main.zip ``` -------------------------------- ### Create and Run AreaPerLipid Object Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/areas.html Instantiate the `AreaPerLipid` class with the universe, lipid selection, and leaflet data. Then, run the analysis, optionally specifying start, stop, and step frames, and enabling a progress bar. ```python areas = AreaPerLipid( universe=u, lipid_sel="name GL1 GL2 ROH", leaflets=leaflets.leaflets ) areas.run( start=None, stop=None, step=None, verbose=True ) ``` -------------------------------- ### Setup Trajectory Frames for Analysis Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/flip_flop.html Configures the trajectory for analysis, ensuring the number of frames to be analyzed matches the provided leaflet data. This method is crucial for aligning trajectory frames with leaflet assignments. ```python def _setup_frames(self, trajectory, start=None, stop=None, step=None): """ Pass a Reader object and define the desired iteration pattern through the trajectory Parameters ---------- trajectory : MDAnalysis.Reader A trajectory Reader start : int, optional start frame of analysis stop : int, optional stop frame of analysis step : int, optional number of frames to skip between each analysed frame """ self._trajectory = trajectory start, stop, step = trajectory.check_slice_indices(start, stop, step) self.start = start self.stop = stop self.step = step n_frames = len(range(start, stop, step)) if self.leaflets.shape[1] != n_frames: _msg = "The frames to analyse must be identical to those used in assigning lipids to leaflets." raise ValueError(_msg) self.n_frames = n_frames self.frames = np.arange(start, stop, step) ``` -------------------------------- ### Initialize SCC Analysis Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/order_parameter.html Set up parameters for calculating the SCC order parameter. Requires an MDAnalysis Universe and a selection string for tail atoms. Optional membrane normals can be provided. ```python from MDAnalysis.analysis.base import AnalysisBase import numpy as np from lipyphilic.plotting import ProjectionPlot __all__ = [ "SCC", ] class SCC(AnalysisBase): """Calculate coarse-grained acyl tail order parameter.""" def __init__(self, universe, tail_sel, normals=None): """Set up parameters for calculating the SCC. Parameters ---------- universe : Universe MDAnalysis Universe object tail_sel : str Selection string for atoms in either the sn1 **or** sn2 tail of lipids in the membrane normals : numpy.ndarray, optional Local membrane normals, a 3D array of shape (n_residues, n_frames, 3), containing `x`, `y` and `z` vector components of the local membrane normals. """ super().__init__(universe.trajectory) self.u = universe self.tails = self.u.select_atoms(tail_sel, updating=False) # For fancy slicing of atoms for each species self.tail_atom_mask = { species: self.tails.resnames == species for species in np.unique(self.tails.resnames) } # For assigning Scc to correct lipids self.tail_residue_mask = { species: self.tails.residues.resnames == species for species in np.unique(self.tails.resnames) } normals = np.array(normals) if normals.ndim not in [0, 3]: _msg = ( "'normals' must be a 3D array containing local membrane normals of each lipid at each frame." ) raise ValueError(_msg) if normals.ndim > 0 and len(normals) != self.tails.n_residues: _msg = "The shape of 'normals' must be (n_residues, n_frames, 3)" raise ValueError(_msg) self.normals = normals self.results.SCC = None ``` -------------------------------- ### Initialize SCC Calculation Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/order_parameter.html Create an MDAnalysis Universe and import the SCC class to begin order parameter calculations. ```python import MDAnalysis as mda from lipyphilic.analysis.order_parameter import SCC u = mda.Universe(tpr, trajectory) ``` -------------------------------- ### Initialize Universe and Registration Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/registration.html Create an MDAnalysis Universe and initialize the Registration object. Ensure you have the necessary trajectory and topology files. ```python import MDAnalysis as mda from lipyphilic.analysis.registration import Registration u = mda.Universe(tpr, trajectory) ``` -------------------------------- ### Build Documentation with Tox Source: https://lipyphilic.readthedocs.io/en/latest/contributing.html Checks that the project documentation builds correctly using tox. ```bash tox -e docs ``` -------------------------------- ### Create and Activate Development Environment Source: https://lipyphilic.readthedocs.io/en/latest/contributing.html Creates a Python virtual environment using uv and activates it. Specifies Python 3.11. ```bash uv venv --python=3.11 source venv/bin/activate ``` -------------------------------- ### Get Registration Results Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/registration.html Provides access to the calculated registration values. The results are stored in `self.results.registration` after processing frames. ```python registration_values = self.registration ``` -------------------------------- ### Initialize MDAnalysis Universe Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/flip_flop.html Before using FlipFlop, an MDAnalysis Universe object must be created. This requires the paths to the topology (tpr) and trajectory files. ```python import MDAnalysis as mda from lipyphilic.leaflets.assign_leaflets import AssignLeaflets from lipyphilic.analysis.flip_flop import FlipFlop u = mda.Universe(tpr, trajectory) ``` -------------------------------- ### Get Atom Areas Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/area_per_lipid.html Calculates the area per atom using Voronoi tessellation based on xy coordinates of atomic positions. ```python def _get_atom_areas(self, positions): """Calculate area per atom. Given xy coordinates of atomic positions, perform a Voronoi ``` -------------------------------- ### Initialize FlipFlop Analysis Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/flip_flop.html Instantiate the FlipFlop class with the Universe, lipid selection, and filtered leaflet data. The lipid_sel should match the molecules of interest for flip-flop detection. ```python flip_flop = FlipFlop( universe=u, lipid_sel="name ROH", leaflets=leaflets.filter_leaflets("name ROH") # pass only the relevant leaflet data ) ``` -------------------------------- ### JointDensity Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/plotting/plotting.html Used for plotting a 2D PMF of cholesterol orientation and height in a lipid membrane. Refer to Gu et al. (2019) for an example. ```APIDOC ## JointDensity ### Description This class can be used, for example, to plot a 2D PMF of cholesterol orientation and height in a lipid membrane. See Gu et al. (2019) for an example of the this 2D PMF. ### Class JointDensity ### Methods (No methods are explicitly documented in the provided source for direct user invocation beyond initialization.) ``` -------------------------------- ### Initialize MDAnalysis Universe Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/memb_thickness.html An MDAnalysis Universe object must be created before using MembThickness. This sets up the simulation data for analysis. ```python import MDAnalysis as mda from lipyphilic.analysis.memb_thickness import MembThickness u = mda.Universe(tpr, trajectory) ``` -------------------------------- ### Run Flip-Flop Calculation Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/flip_flop.html Executes the flip-flop analysis over a specified range of trajectory frames. This method orchestrates the setup, frame processing, and conclusion of the analysis. ```python def run(self, start=None, stop=None, step=None): """Perform the calculation Parameters ---------- start : int, optional start frame of analysis stop : int, optional stop frame of analysis ``` -------------------------------- ### Initialize MembThickness Analyzer Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/memb_thickness.html Instantiate the MembThickness class with trajectory data, leaflet assignments, and optional parameters for lipid selection and grid binning. Ensure the simulation box is orthorhombic. ```python from lipyphilic.analysis.memb_thickness import MembThickness # Assuming 'universe' is a MDAnalysis Universe object and 'leaflets' is a numpy array # with leaflet assignments (-1 for lower, 1 for upper, 0 for midplane) # Example initialization try: memb_thickness_analyzer = MembThickness(universe, leaflets, n_bins=10, interpolate=True, return_surface=True) except ValueError as e: print(f"Error initializing MembThickness: {e}") ``` -------------------------------- ### Get Residue Indices of Largest Cluster Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/neighbours.html Retrieves not only the size of the largest cluster but also the specific residue indices of the lipids belonging to that cluster at each frame. ```APIDOC ## largest_cluster with index return ### Description Finds the largest cluster and returns the residue indices of the lipids within that cluster for each frame. ### Method `neighbours.largest_cluster(cluster_sel, return_indices=True)` ### Parameters * `cluster_sel` (str): A selection string for the lipid species to consider for clustering (e.g., "resname CHOL DPPC"). * `return_indices` (bool, optional): If True, returns the residue indices of lipids in the largest cluster. Defaults to False. ### Response Returns two values: 1. A numpy.ndarray containing the number of lipids in the largest cluster at each frame. 2. A list of numpy.ndarray arrays, where each array contains the residue indices of lipids in the largest cluster for a given frame. ### Request Example ```python largest_cluster, largest_cluster_indices = neighbours.largest_cluster( cluster_sel="resname CHOL DPPC", return_indices=True ) ``` ``` -------------------------------- ### Initialize MembThickness with Default Resolution Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/memb_thickness.html Create a MembThickness object using the assigned leaflets and a lipid selection. The default resolution uses 1 bin per dimension. ```python memb_thickness = MembThickness( universe=u, leaflets=leaflets.filter_leaflets("resname DOPC and DPPC"), # exclude cholesterol from thickness calculation lipid_sel="resname DPPC DOPC and name PO4" ) ``` -------------------------------- ### Calculate Diffusion Coefficient Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/lateral_diffusion.html Compute the lateral diffusion coefficient (D_xy) by fitting a linear region of the MSD plot. Specify the start and end points for the fit. ```python d, sem = msd.diffusion_coefficient( start_fit=400, end_fit=600 ) ``` -------------------------------- ### Initialize MembThickness with Custom Resolution Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/memb_thickness.html Configure MembThickness with a specified number of bins (n_bins) for higher resolution grid calculations. This affects the discretization of the leaflet surfaces. ```python memb_thickness = MembThickness( universe=u, leaflets=leaflets.filter_leaflets("resname DOPC and DPPC"), # exclude cholesterol from thickness calculation lipid_sel="resname DPPC DOPC and name PO4", n_bins=10 ) ``` -------------------------------- ### Run Flip-flop Detection Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/flip_flop.html Execute the flip-flop detection analysis for a specified range of frames. Use None for start, stop, and step to analyze the entire trajectory. ```python flip_flop.run( start=None, stop=None, step=None ) ``` -------------------------------- ### Get Residue Indices of Largest Cluster Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/neighbours.html Identify the specific lipids belonging to the largest cluster at each frame. Returns both the cluster size and the residue indices of the lipids within that cluster. ```python largest_cluster, largest_cluster_indices = neighbours.largest_cluster( cluster_sel="resname CHOL DPPC", return_indices=True ) ``` -------------------------------- ### Initialize ZPositions Analysis Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/z_positions.html Initialize the ZPositions analysis with trajectory, lipid selection, and height selection. Requires an orthorhombic box. ```python from lipyphilic.analysis import ZPositions # Assuming 'universe' is a pre-loaded MDAnalysis Universe object # and 'lipid_sel' and 'height_sel' are valid selection strings # Example initialization # zpos_analysis = ZPositions(universe, lipid_sel='resname POPC', height_sel='resname POPC and name PO4', n_bins=10, return_midpoint=True) ``` -------------------------------- ### Flip-flop Data Structure Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/flip_flop.html The flip-flop data is returned as a numpy.ndarray. Each row represents a flip-flop event with columns for residue index, start frame, end frame, and direction of movement. ```python flip_flops = [ [ , , , ], ... ] ``` -------------------------------- ### Initialize MembThickness with Custom Grid Resolution Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/memb_thickness.html Configure MembThickness to use a specified number of bins for discretizing the leaflet surfaces, affecting the resolution of the 2D grid. ```python memb_thickness = MembThickness( universe=u, leaflets=leaflets.filter_leaflets("resname DOPC and DPPC"), # exclude cholesterol from thickness calculation lipid_sel="resname DPPC DOPC and name PO4", n_bins=10 ) ``` -------------------------------- ### Diffusion Coefficient Calculation Parameters Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/lateral_diffusion.html Defines the parameters for calculating the diffusion coefficient, including optional start and stop times for fitting the MSD curve and a lipid selection string. ```python start_fit: float | None = None, stop_fit: float | None = None, lipid_sel: str | None = None, ``` -------------------------------- ### Create MembThickness Object Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/memb_thickness.html Instantiate MembThickness with the universe, filtered leaflet data, and lipid selection for thickness calculation. ```python memb_thickness = MembThickness( universe=u, leaflets=leaflets.filter_leaflets("resname DOPC and DPPC"), # exclude cholesterol from thickness calculation lipid_sel="resname DPPC DOPC and name PO4" ) ``` -------------------------------- ### Calculate Lateral Diffusion Coefficient Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/lateral_diffusion.html Calculates the lateral diffusion coefficient (Dxy) using the Einstein relation. Requires specifying the start and end points for the linear fit of the MSD curve. ```python d, sem = msd.diffusion_coefficient( start_fit=400, end_fit=600 ) ``` -------------------------------- ### Initialize Universe and Assign Leaflets Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/flip_flop.html Create an MDAnalysis Universe and use AssignLeaflets to determine lipid leaflet membership per frame. Ensure correct atom selections and midplane cutoff are used. ```python import MDAnalysis as mda from lipyphilic.leaflets.assign_leaflets import AssignLeaflets from lipyphilic.analysis.flip_flop import FlipFlop u = mda.Universe(tpr, trajectory) leaflets = AssignLeaflets( universe=u, lipid_sel="name GL1 GL2 ROH" # assuming we are using the MARTINI forcefield midplane_sel="name ROH", # only cholesterol is allowed to flip-flop midplane_cutoff=8.0, # buffer size for assigning molecules to the midplane ) leaflets.run() ``` -------------------------------- ### Assign lipids to upper/lower leaflets with midplane consideration Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/leaflets/assign_leaflets.html This example demonstrates how to initialize AssignCurvedLeaflets for a phospholipid/cholesterol mixture. It specifies atom selections for lipids and cholesterol, and distance cutoffs for leaflet and midplane assignment. ```python leaflets = AssignCurvedLeaflets( universe=u, lipid_sel="name GL1 GL2 ROH", lf_cutoff=12.0, midplane_sel="name ROH", midplane_cutoff=10.0 ) ``` -------------------------------- ### SCC Class Initialization Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/order_parameter.html Initializes the SCC class to calculate coarse-grained acyl tail order parameters. It requires an MDAnalysis Universe object and a selection string for the tail atoms. ```APIDOC ## SCC ### Description Calculate coarse-grained acyl tail order parameter. Set up parameters for calculating the SCC. ### Parameters * **universe** (Universe) – MDAnalysis Universe object * **tail_sel** (str) – Selection string for atoms in either the sn1 or sn2 tail of lipids in the membrane * **normals** (numpy.ndarray, optional) – Local membrane normals, a 3D array of shape (n_residues, n_frames, 3), containing x, y and z vector components of the local membrane normals. ``` -------------------------------- ### Run Registration Calculation Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/registration.html Execute the registration calculation for the specified frames. The results are stored in the 'registration' attribute. Use verbose=True to display a progress bar. ```python registration.run( start=None, stop=None, step=None, verbose=True ) ``` -------------------------------- ### Get Largest Lipid Cluster Indices Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/neighbours.html Retrieves the residue indices of lipids in the largest cluster for each frame. This method requires `Neighbours.run()` to be called beforehand. It can optionally filter lipids based on provided criteria. ```python if self.results.neighbours is None: _msg = ".neighbours attribute is None: use .run() before calling .largest_cluster()" raise NoDataError(_msg) if filter_by is not None and np.array(filter_by).ndim not in [1, 2]: _msg = "'filter_by' must either be a 1D array containing non-changing boolean" "values for each lipid, or a 2D array of shape (n_residues, n_frames)" " containing a boolean value for each lipid at each frame.", raise ValueError(_msg) if filter_by is not None and len(filter_by) != self.membrane.n_residues: _msg = "The shape of 'filter_by' must be (n_residues,)" raise ValueError(_msg) # determine which lipids to use in the analysis at each frame if filter_by is None: filter_by = np.full( (self.membrane.n_residues, self.n_frames), fill_value=True, dtype=bool, ) elif filter_by.ndim == 1: filter_by = np.full( (self.membrane.n_residues, self.n_frames),\n fill_value=filter_by[:, np.newaxis], dtype=bool, ) # also create mask based on `cluster_sel` if cluster_sel is None: filter_lipids = np.full( self.membrane.n_residues, fill_value=True, dtype=bool, ) else: lipids = self.u.select_atoms(cluster_sel).residues if lipids.n_residues == 0: _msg = "'cluster_sel' produces empty AtomGroup. Please check the selection string." raise ValueError(_msg) filter_lipids = np.isin( self.membrane.residues.resindices, lipids.resindices, ) # combine the masks filter_by[filter_lipids == False] = False # noqa: E712 # output arrays largest_cluster = np.zeros(self.n_frames, dtype=int) largest_cluster_resindices = np.full(self.n_frames, fill_value=0, dtype=object) for frame_index, neighbours in tqdm(enumerate(self.results.neighbours), total=self.n_frames): frame_filter = filter_by[:, frame_index] frame_neighbours = neighbours[frame_filter][:, frame_filter] # find all connected components _, com_labels = scipy.sparse.csgraph.connected_components(frame_neighbours) unique_com_labels, counts = np.unique(com_labels, return_counts=True) largest_label = unique_com_labels[np.argmax(counts)] # largest cluster and resindices of lipids in the cluster largest_cluster[frame_index] = max(counts) frame_resindices = self.membrane.residues.resindices[frame_filter] largest_cluster_resindices[frame_index] = frame_resindices[com_labels == largest_label] if return_indices is True: return largest_cluster, largest_cluster_resindices return largest_cluster ``` -------------------------------- ### Get Area Per Lipid Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/area_per_lipid.html Calculates the area per lipid for a given leaflet. It involves wrapping atoms, setting z-coordinates to 0, removing overlapping atoms in the xy-plane, and performing Voronoi tessellation. ```python def _single_frame(self): # Atoms must be wrapped before creating a lateral grid of the membrane self.membrane.wrap(inplace=True) frame_leaflets = self.leaflets[:, self._frame_index] if self.leaflets.ndim == 2 else self.leaflets # Calculate area per lipid for the lower (-1) and upper (1) leaflets # Areas cannot be calculated for midplane (0) molecules. for leaflet_sign in [-1, 1]: # freud.order.Voronoi requires z positions set to 0 leaflet = self.membrane.residues[frame_leaflets == leaflet_sign].atoms atoms = leaflet.atoms.intersection(self.membrane) pos = atoms.positions pos[:, 2] = 0 # Check whether any atoms are overlapping in the xy-plane self._remove_overlapping(positions=pos) # Voronoi tessellation to get area per atom areas = self._get_atom_areas(positions=pos) # Calculae area per lipid in the current leaflet # by considering the contribution of each # atom of a given lipid self._get_area_per_lipid( atoms=atoms, atom_areas=areas, ) ``` -------------------------------- ### Initialize ZAngles Analysis Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/z_angles.html Initialize the ZAngles class with an MDAnalysis Universe, atom selection strings for atoms A and B, and an option to return angles in radians. ```python import MDAnalysis as mda from lipyphilic.analysis.z_angles import ZAngles u = mda.Universe(tpr, trajectory) z_angles = ZAngles( universe=u, atom_A_sel="name ROH", atom_B_sel="name R5" ) ``` -------------------------------- ### Run SN1 Tail Order Parameter Calculation Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/order_parameter.html Execute the order parameter calculation for the sn1 tails. Options include specifying start, stop, and step frames, and enabling a progress bar with verbose=True. ```python scc_sn1.run( start=None, stop=None, step=None, verbose=True ) ``` -------------------------------- ### Prepare Results Arrays Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/flip_flop.html Initializes the results arrays for storing flip-flop events and success flags before the analysis begins. ```python def _prepare(self): # Output array self.results.flip_flops = [[], [], [], []] self.results.flip_flop_success = [] ``` -------------------------------- ### Check Package Build with Tox Source: https://lipyphilic.readthedocs.io/en/latest/contributing.html Verifies that the lipyphilic package builds correctly using tox. ```bash tox -e package ``` -------------------------------- ### Run Flip-flop Analysis Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/flip_flop.html Execute the flip-flop analysis using the run method. Optionally specify start, stop, and step parameters to analyze specific frames of the trajectory. The results are stored in the flip_flop.flip_flops attribute. ```python flip_flop.run( start=None, stop=None, step=None ) ``` -------------------------------- ### get_supported_backends Class Method Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/leaflets.html Tuple with backends supported by the core library for a given class. User can pass either one of these values as `backend=...` to `run()` method, or a custom object that has `apply` method. ```APIDOC ## classmethod get_supported_backends() ### Description Tuple with backends supported by the core library for a given class. User can pass either one of these values as `backend=...` to `run()` method, or a custom object that has `apply` method (see documentation for `run()`): * ‘serial’: no parallelization * ‘multiprocessing’: parallelization using multiprocessing.Pool * ‘dask’: parallelization using dask.delayed.compute(). Requires installation of mdanalysis[dask] If you want to add your own backend to an existing class, pass a `backends.BackendBase` subclass (see its documentation to learn how to implement it properly), and specify `unsupported_backend=True`. ### Returns * tuple - names of built-in backends that can be used in `run(backend=...)()` ### Added in version 2.8.0 ``` -------------------------------- ### Prepare for Thickness Calculation Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/memb_thickness.html Call the _prepare method to initialize result arrays for membrane thickness and thickness grid. This method checks frame consistency if leaflet assignments are dynamic. ```python # Assuming 'memb_thickness_analyzer' is an instance of MembThickness # Prepare the analyzer for calculations memb_thickness_analyzer._prepare() # Results are stored in memb_thickness_analyzer.results.memb_thickness # and memb_thickness_analyzer.results.memb_thickness_grid if return_surface is True ``` -------------------------------- ### Running Leaflet Assignment with Progress Bar Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/leaflets.html Execute the leaflet assignment process using the run method. This allows specifying the trajectory range (start, stop, step) and enables a progress bar for long simulations. ```python leaflets.run( start=None, stop=None, step=None, verbose=True ) ``` -------------------------------- ### Process Single Frame for Flip-Flop Events Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/flip_flop.html Analyzes a single frame to detect flip-flop events using the `_lipyferric.molecule_flip_flop` function. It records the start and end frames, end leaflets, and success status for each detected event. ```python def _single_frame(self): # Skip if the molecule never changes leaflet if np.min(np.diff(self._residue_leaflets)) == np.max(np.diff(self._residue_leaflets)) == 0: return start_frames, end_frames, end_leaflets, success = _lipyferric.molecule_flip_flop( leaflets=self._residue_leaflets, frame_cutoff=self.frame_cutoff, ) n_events = len(start_frames) resindex = self.membrane[self._residue_index].resindex self.results.flip_flops[0].extend([resindex for _ in range(n_events)]) self.results.flip_flops[1].extend(start_frames) self.results.flip_flops[2].extend(end_frames) self.results.flip_flops[3].extend(end_leaflets) self.results.flip_flop_success.extend(success) ``` -------------------------------- ### Importing Libraries and Creating Universe Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/leaflets.html Before using AssignCurvedLeaflets, import necessary libraries and create an MDAnalysis Universe object. This sets up the simulation data for analysis. ```python import MDAnalysis as mda from lipyphilic.leaflets.assign_leaflets import AssignLeaflets u = mda.Universe(tpr, trajectory) ``` -------------------------------- ### Prepare Registration Results Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/registration.html Prepares the results array for storing registration values for each frame. Initializes the array with NaN values. ```python self._prepare() ``` -------------------------------- ### ZThickness Class Initialization and Usage Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/z_thickness.html Demonstrates how to initialize and use the ZThickness class to calculate lipid z-thickness. It requires an MDAnalysis Universe and a lipid selection string. The `run` method performs the calculation, and results are stored in the `z_thickness` attribute. ```APIDOC ## ZThickness Class ### Description Calculates the thickness in z of lipids in a bilayer. This is useful for detecting phase separation in lipid bilayers using Hidden Markov Models. ### Initialization ```python ZThickness(universe, lipid_sel) ``` #### Parameters - **universe** (Universe) - Required - An MDAnalysis Universe object. - **lipid_sel** (str) - Required - A selection string for atoms to use in calculating lipid thicknesses. ### Method: run Analyzes the trajectory to calculate z-thickness for each lipid. ```python run(start=None, stop=None, step=None, verbose=True) ``` #### Parameters - **start** (int, optional) - The starting frame of the trajectory to analyze. - **stop** (int, optional) - The stopping frame of the trajectory to analyze. - **step** (int, optional) - The step size between frames to analyze. - **verbose** (bool, optional) - If True, displays a progress bar during analysis. ### Attribute: z_thickness Stores the calculated z-thickness data. - **z_thickness** (numpy.ndarray) - The thickness in z of each lipid in the bilayer. The array has the shape (n_residues, n_frames). Each row corresponds to an individual lipid and each column to an individual frame. ``` -------------------------------- ### Configure and Run Registration Analysis Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/registration.html Instantiate the Registration object with lipid selections and leaflet assignments. Run the analysis to calculate interleaflet registration. The results indicate the degree of correlation between leaflets. ```python registration = Registration( upper_sel="resname CHOL and name ROH", lower_sel="resname CHOL and name ROH", leaflets=leaflets.filter_leaflets("resname CHOL and name ROH") ) registration.run( start=None, stop=None, step=None, verbose=True ) ``` -------------------------------- ### Initialize FlipFlop Object Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/flip_flop.html Create a FlipFlop object, passing the MDAnalysis Universe and the relevant lipid selection. Filter the leaflet data to include only the lipids being analyzed. ```python flip_flop = FlipFlop( universe=u, lipid_sel="name ROH", leaflets=leaflets.filter_leaflets("name ROH") # pass only the relevant leaflet data ) ``` -------------------------------- ### Clone Forked Repository Source: https://lipyphilic.readthedocs.io/en/latest/contributing.html Clones your forked lipyphilic repository locally and navigates into the project directory. ```bash git clone git@github.com:YOURGITHUBNAME/lipyphilic.git cd lipyphilic ``` -------------------------------- ### MSD Class Initialization Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/lateral_diffusion.html Initializes the MSD class with an MDAnalysis Universe, a lipid selection string, and optional parameters for center-of-mass removal and time step. ```python from MDAnalysis import Universe from MDAnalysis.analysis.base import AnalysisBase import numpy as np import scipy.stats import tidynamics # Assuming 'universe' is an MDAnalysis Universe object # Example initialization: # msd_calculator = MSD(universe, lipid_sel="resname POPC") ``` -------------------------------- ### Initialize FlipFlop with Residence Time Cutoff Source: https://lipyphilic.readthedocs.io/en/latest/_modules/lipyphilic/analysis/flip_flop.html Configure FlipFlop to consider only successful flip-flops where the molecule resides in the new leaflet for a minimum number of frames. Set frame_cutoff to the desired minimum frame count. ```python flip_flop = FlipFlop( universe=u, lipid_sel="name ROH", leaflets=leaflets.filter_leaflets("name ROH"), frame_cutoff=10, ) ``` -------------------------------- ### Run ZThickness analysis Source: https://lipyphilic.readthedocs.io/en/latest/reference/analysis/z_thickness.html Execute the ZThickness analysis on the selected frames. Set verbose=True to display a progress bar during computation. ```python z_thickness_sn1.run( start=None, stop=None, step=None, verbose=True ) ```