packing_defect.core.interactions

interactions.py

Tools for detecting protein–defect interactions in lipid membrane simulations. This module can process multiple lipid types, identify protein residues that interact with packing defects within a distance cutoff, and write results to a CSV.

Functions

process_multiple(input_dirs, output_csv, cutoff)

Process multiple lipid-type directories and record protein–defect interactions.

run(input_dirs[, cutoff, output_csv, ...])

Compute protein–defect interactions, write the CSV, and return results.

Classes

ProteinDefectInteractions([cutoff])

Tracks protein–defect interactions in a single trajectory.

class packing_defect.core.interactions.ProteinDefectInteractions(cutoff=0.1)[source]

Bases: object

Tracks protein–defect interactions in a single trajectory.

Parameters:

cutoff (float, optional) – Minimum distance in Å between a protein residue center of mass and any defect atom for the residue to be counted as interacting. Default is 0.1 Å.

Variables:
  • cutoff (float) – Interaction distance threshold in Å.

  • results (dict) – Mapping from frame index → list of (resid, resname) tuples for interacting residues.

track_frame(universe, frame_index)[source]

Analyze a single frame and record protein residues near defects.

Parameters:
  • universe (MDAnalysis.Universe) – Universe containing the current frame.

  • frame_index (int or str) – Index or identifier for the current frame.

Notes

  • All protein residues whose center of mass lies within cutoff Å of any defect atom are recorded.

  • Defect atoms are defined as all atoms not belonging to the protein.

packing_defect.core.interactions.process_multiple(input_dirs, output_csv, cutoff)[source]

Process multiple lipid-type directories and record protein–defect interactions.

Parameters:
  • input_dirs (list of str) – Paths to directories containing .gro or .pdb files for each lipid type. Each directory is treated as a separate lipid type, and its basename is used as the lipid label in the output.

  • output_csv (str) – Path to the CSV file to be written. Parent directories will be created if necessary.

  • cutoff (float) – Distance cutoff in Å for protein–defect interactions.

  • Format (Output CSV)

  • -----------------

  • type

    • type : lipid type (directory name)

    • frame : frame index (int or str extracted from filename)

    • resid : residue ID of interacting protein residue

    • resname : residue name of interacting protein residue

  • frame

    • type : lipid type (directory name)

    • frame : frame index (int or str extracted from filename)

    • resid : residue ID of interacting protein residue

    • resname : residue name of interacting protein residue

  • resid

    • type : lipid type (directory name)

    • frame : frame index (int or str extracted from filename)

    • resid : residue ID of interacting protein residue

    • resname : residue name of interacting protein residue

  • resname

    • type : lipid type (directory name)

    • frame : frame index (int or str extracted from filename)

    • resid : residue ID of interacting protein residue

    • resname : residue name of interacting protein residue

Notes

  • Frame index is parsed from the filename by extracting the last underscore-delimited component before the extension. If parsing fails, the filename stem is used as-is.

  • The CSV rows are sorted by lipid type (order given in input_dirs), then frame index, then residue ID.

packing_defect.core.interactions.run(input_dirs, cutoff=1.0, output_csv='combined_interactions.csv', as_dataframe=True)[source]

Compute protein–defect interactions, write the CSV, and return results.

Parameters:
  • input_dirs (list of str) – Directories containing .gro/.pdb frames, one per lipid type.

  • cutoff (float, optional) – Distance cutoff in Å. Default 1.0.

  • output_csv (str, optional) – Output CSV path. Default “combined_interactions.csv”.

  • as_dataframe (bool, optional) – If True and pandas is available, return a pandas DataFrame. Otherwise return a list of dicts.

Returns:

Rows with columns: type, frame, resid, resname.

Return type:

pandas.DataFrame or list[dict]