Skip to content

Commit

Permalink
add frame_df
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenChM committed Dec 10, 2024
1 parent 56ef2fa commit 7b75442
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions biobb_mem/fatslim/fatslim_membranes.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def display_fatslim(input_top_path: str, lipid_sel: str, input_traj_path: str =
output_ndx_path (str, optional): Path to the output index file containing leaflet information. Default is "leaflets.ndx".
leaflets (bool, optional): If True, visualize individual leaflets. If False, visualize entire membranes. Default is True.
colors (list of str, optional): List of colors to use for visualizing the leaflets or membranes. Default is ['blue', 'cyan', 'yellow', 'orange', 'purple', 'magenta'].
non_mem_color (str, optional): Color to use for visualizing lipids not in the membrane. Default is 'red'.
Returns:
nglview.NGLWidget: An NGLView widget displaying the membrane leaflets.
"""
Expand Down
25 changes: 25 additions & 0 deletions biobb_mem/lipyphilic_biobb/lpp_zpositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,30 @@ def main():
properties=properties)


def frame_df(output_positions_path):
"""
Processes a CSV file containing z-position data and calculates the mean positive, mean negative,
thickness, and standard deviation of thickness for each frame.
Args:
output_positions_path (str): Path to the CSV file containing z-position data.
Returns:
pandas.DataFrame: A DataFrame with the following columns:
- mean_positive: Mean of positive z-positions for each frame.
- mean_negative: Mean of negative z-positions for each frame.
- thickness: Difference between mean_positive and mean_negative for each frame.
- std_thickness: Standard deviation of the absolute z-positions for each frame.
"""

df = pd.read_csv(output_positions_path)
grouped = df.groupby('frame')['zposition'].agg(
mean_positive=lambda x: x[x > 0].mean(),
mean_negative=lambda x: x[x < 0].mean()
)
grouped['thickness'] = grouped['mean_positive'] - grouped['mean_negative']
grouped['std_thickness'] = df.groupby('frame')['zposition'].apply(lambda x: x.abs().std())
return grouped


if __name__ == '__main__':
main()

0 comments on commit 7b75442

Please sign in to comment.