Flip#

Flipping a molecular system over a specified plane or normal vector.

The function molsysmt.structure.flip() reflects the coordinates of a molecular system over a plane defined by an anchor point and a normal vector.

Added in version 1.0.0.

Basic usage#

Let’s show how to flip a POPC lipid molecule across a plane passing through the origin. We first orient its longest principal axis along the vertical \(y\)-axis using molsysmt.structure.align_principal_axes() and center it on its phosphorus atom:

import molsysmt as msm
import numpy as np
crd = msm.systems['POPC']['popc.crd']
psf = msm.systems['POPC']['popc.psf']
molsys = msm.convert([crd, psf], to_form='molsysmt.MolSys')
molsys = msm.structure.align_principal_axes(molsys, axes=[[0, 1, 0], [0, 0, 1], [1, 0, 0]])
molsys = msm.structure.center(molsys, selection='all', center_of_selection='atom_name=="P"')

We inspect the initial 3D orientation of the lipid molecule (with the headgroup pointing upwards along \(+y\)):

msm.view(molsys)

We now reflect the coordinates across the horizontal \(xz\)-plane (normal vector [0, 1, 0], inverting the vertical \(y\)-axis) passing through the origin:

molsys_flipped = msm.structure.flip(molsys, vector=[0, 1, 0], point='[0, 0, 0] nm')

Visualizing the flipped system confirms that the lipid is inverted vertically (\(y \to -y\)):

msm.view(molsys_flipped)